-
FTP Problem
I seem to be having a problem with the FTPWebRequest. I get an error (see below code) when it executes the emboldened line. Any ideas?
Code:
Dim uploadRequest As FtpWebRequest = WebRequest.Create(uploadUrl)
uploadRequest.Method = WebRequestMethods.Ftp.UploadFile
If strUserName <> "" And strPassword <> "" Then
uploadRequest.Credentials = New System.Net.NetworkCredential(strUserName, strPassword)
End If
uploadRequest.EnableSsl = blnSecure
uploadRequest.KeepAlive = True
uploadRequest.UsePassive = blnPassive
uploadRequest.Proxy = Nothing
RequestStream = uploadRequest.GetRequestStream()
fileStream = File.Open(fileName, FileMode.Open)
Dim buffer(1024) As Byte
Dim bytesRead As Integer
While True
bytesRead = fileStream.Read(buffer, 0, buffer.Length)
If bytesRead = 0 Then
Exit While
End If
requestStream.Write(buffer, 0, bytesRead)
End While
' The request stream must be closed before getting the response.
requestStream.Close()
uploadResponse = uploadRequest.GetResponse()
"The server returned an address in response to the PASV command that is different than the address to which the FTP connection was made."
-
Re: FTP Problem
Ugh, never seen that one. Is this in a test-bed situation or live? Do you know your network route to the server? Are there anything like proxy servers, firewalls or anything else in between that could be passing you a different IP?
-
Re: FTP Problem
Is the server you're talking to on multiple IP addresses? Try accessing it by IP address rather than relying on DNS resolutions.
-
Re: FTP Problem
In answer to the above questions:
I am accessing it with an IP address rather than a DNS.
This is a testbed situation.
there are no proxy servers but there is a firewall.
I should have stated originally that this problem occurs when I am setting EnableSsl to True. I am also using passive mode (because I heard somewhere that you have to when using encryption). If I set EnableSsl to False, it uploads fine.
Further note, I have connected to the FTP server in question fine using a client tool (such as SmartFTP) with Explicit SSL and Passive mode switched on. The client tool works but the .NET code doesn't...