By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,696 Members | 1,486 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,696 IT Pros & Developers. It's quick & easy.

FtpWebRequest: ListDirectoryDetails with "Unable to connect to theremote server"

P: n/a
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...
Sep 24 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Any guru's out there?
Oct 9 '08 #2

P: n/a
On Sep 24, 2:58*pm, "Patrick.Sim...@intecsoft.com"
<Patrick.Sim...@intecsoft.comwrote:
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...
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://msdn.microsoft.com/en-us/libr...t.timeout.aspx

Hope this helps,

Onur Güzel
Oct 9 '08 #3

P: n/a
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....
Oct 13 '08 #4

P: n/a
On Oct 13, 5:44 pm, "Patrick.Sim...@intecsoft.com"
<Patrick.Sim...@intecsoft.comwrote:
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....
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üzel
Oct 13 '08 #5

P: n/a
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?

Oct 14 '08 #6

P: n/a
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.

Oct 20 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.