FtpWebRequest: ListDirectoryDetails with "Unable to connect to the remote server"

FtpWebRequest: ListDirectoryDetails with "Unable to connect to the remote server"

Post by Patrick.Si » Thu, 25 Sep 2008 20:58:07


I try to connect a FTPWebRequest through Proxy and VPN to a remote
FTP- server. Sometimes it works sometimes not. When my VB.Net-App
(2005) returns the error on the GetResponse-Method, I'll try to use
the Windows Explorer to go on the FTP-URI and this always works. So
the problem should come from my app.

my simplified code:

Private m_oFTP As FtpWebRequest
Private oResponseDir As FtpWebResponse = Nothing

m_oFTP = FtpWebRequest.Create("ftp://" & m_sFTPIP & "//" &
m_sNetTraDir & "/*.TRA") With m_oFTP
.Credentials = New NetworkCredential(m_sFTPUsr, m_sFTPPwd)
.UseBinary = True
.KeepAlive = True
.Method = WebRequestMethods.Ftp.ListDirectoryDetails
Try
oResponseDir = .GetResponse()
bRc = True
Catch ex As Exception
....
End With

The trace file shows this:

System.Net Verbose: 0 : [3956] WebRequest::Create(ftp://10.70.5.19//
EXPORT/FTP_E02/*.TRA)
System.Net Information: 0 : [3956]
FtpWebRequest#64923656::.ctor(ftp://
10.70.5.19//EXPORT/FTP_E02/*.TRA)
System.Net Verbose: 0 : [3956] Exiting WebRequest::Create() ->
FtpWebRequest#64923656
System.Net Verbose: 0 : [3956] FtpWebRequest#64923656::GetResponse()
System.Net Information: 0 : [3956]
FtpWebRequest#64923656::GetResponse(Method=LIST.)
System.Net Warning: 0 : [3956] WebProxy failed to autodetect a Uri for
a proxy script.
System.Net Warning: 0 : [3956] WebProxy failed to autodetect a Uri for
a proxy script.
System.Net Error: 0 : [3956] Exception in the
FtpWebRequest#64923656::GetResponse - Unable to connect to the remote
server
System.Net Error: 0 : [3956] at
System.Net.FtpWebRequest.GetResponse()
System.Net Verbose: 0 : [3956] Exiting
FtpWebRequest#64923656::GetResponse()


Any ideas...
 
 
 

FtpWebRequest: ListDirectoryDetails with "Unable to connect to the remote server"

Post by Patrick.Si » Fri, 10 Oct 2008 23:48:23

Any guru's out there?

 
 
 

FtpWebRequest: ListDirectoryDetails with "Unable to connect to the remote server"

Post by kimiraikko » Sat, 11 Oct 2008 00:58:21

On Sep 24, 2:58爌m, " XXXX@XXXXX.COM "


Hi,
Just a guess as far as based on your code, it may a trouble because of
your application gets timed out due to absence of Timeout property.
You can try to set a enlarged FtpWebRequest.Timeout property (in
miliseconds) to test it.

http://www.yqcomputer.com/

Hope this helps,

Onur G鼁el
 
 
 

FtpWebRequest: ListDirectoryDetails with "Unable to connect to the remote server"

Post by Patrick.Si » Tue, 14 Oct 2008 23:44:38

It has nothing to do with the Timeout. When the property isn't set,
the timeout is infinite.

What could be the difference between using FtpWebRequest or using the
windows explorer (XP SP3)?

BTW: I use a VPN-connection....
 
 
 

FtpWebRequest: ListDirectoryDetails with "Unable to connect to the remote server"

Post by kimiraikko » Wed, 15 Oct 2008 00:46:51

On Oct 13, 5:44 pm, " XXXX@XXXXX.COM "


Not sure, MSDN says:

"To specify an infinite value, set the Timeout property to Infinite
(-1). "

Thus, you "may" need to set:
System.Threading.Timeout.Infinite


Worth to try.

Onur G鼁el
 
 
 

FtpWebRequest: ListDirectoryDetails with "Unable to connect to the remote server"

Post by Patrick.Si » Wed, 15 Oct 2008 16:01:36

Yes indeed, the default value for the Timeout is not infinite, it's
100000 (100 ms).
But changing it to System.Threading.Timeout.Infinite doesn't change my
problem.

Any other thoughts?
 
 
 

FtpWebRequest: ListDirectoryDetails with "Unable to connect to the remote server"

Post by Patrick.Si » Tue, 21 Oct 2008 15:44:46

I find a solution. It seems that the FTP-server doesn't always want to
answer the FtpWebRequest.GetResponse(), so I made some
pings in a loop to force the server to answer (in VB.Net with
System.Net.NetworkInformation.Ping). After I got the first positive
reply from the ping, the FtpWebRequest.GetResponse() worked fine.