FtpWebRequest

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can you find anything wrong with the code below? It blows up in io =
request.GetRequestStream.
It worked fine with one FTP server and not with another.

Dim request As FtpWebRequest
Dim password As String
Dim response As FtpWebResponse
password = ConfigurationManager.AppSettings("ftppwd")
request = WebRequest.Create(FTPlocation.Text)
request.Method = WebRequestMethods.Ftp.UploadFile
request.Credentials = New NetworkCredential(FTPAccount.Text,
password)
Dim io As Stream
buff = out.ToString
Dim b As Byte()
b = Encoding.ASCII.GetBytes(buff)
request.ContentLength = b.Length
io = request.GetRequestStream
io.Write(b, 0, b.Length)
io.Close()
 
System.Net.WebException: The remote server returned an error: 227 Entering
Passive Mode (209,98,235,43,4,4) . ---> System.Net.Sockets.SocketException: A
connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because
connected host has failed to respond at
 
Hmm, it seems that remote server didn't allow you to connect to it. There
can be a lot of reasons why remote server refused connection.

To get more details about this situation it will be a good idea to enable
network tracing and see what network I/O is happening.

See, the details at

( http://msdn2.microsoft.com/a6sbz1dx.aspx )
 
Vadym,
I can connect fine with a program called LeechFTP. I can't connect with a
program. I can't connect with a response file and command line ftp.
 
That is why I've recommended you to use network tracing functionality.
It can be configured so that you can log all the traffic between your app
and
remote FTP server. Having this info you can determine the reason (analyze
traffic log), why FTP server
refuses connection.
 
Back
Top