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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick.Simons@intecsoft.com

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

    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.C reate("ftp://" & m_sFTPIP & "//" &
    m_sNetTraDir & "/*.TRA") With m_oFTP
    .Credentials = New NetworkCredenti al(m_sFTPUsr, m_sFTPPwd)
    .UseBinary = True
    .KeepAlive = True
    .Method = WebRequestMetho ds.Ftp.ListDire ctoryDetails
    Try
    oResponseDir = .GetResponse()
    bRc = True
    Catch ex As Exception
    ....
    End With

    The trace file shows this:

    System.Net Verbose: 0 : [3956] WebRequest::Cre ate(ftp://10.70.5.19//
    EXPORT/FTP_E02/*.TRA)
    System.Net Information: 0 : [3956]
    FtpWebRequest#6 4923656::.ctor( ftp://
    10.70.5.19//EXPORT/FTP_E02/*.TRA)
    System.Net Verbose: 0 : [3956] Exiting WebRequest::Cre ate() ->
    FtpWebRequest#6 4923656
    System.Net Verbose: 0 : [3956] FtpWebRequest#6 4923656::GetRes ponse()
    System.Net Information: 0 : [3956]
    FtpWebRequest#6 4923656::GetRes ponse(Method=LI ST.)
    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#6 4923656::GetRes ponse - Unable to connect to the remote
    server
    System.Net Error: 0 : [3956] at
    System.Net.FtpW ebRequest.GetRe sponse()
    System.Net Verbose: 0 : [3956] Exiting
    FtpWebRequest#6 4923656::GetRes ponse()


    Any ideas...
  • Patrick.Simons@intecsoft.com

    #2
    Re: FtpWebRequest: ListDirectoryDe tails with "Unable to connect tothe remote server"

    Any guru's out there?

    Comment

    • kimiraikkonen

      #3
      Re: FtpWebRequest: ListDirectoryDe tails with "Unable to connect tothe remote server"

      On Sep 24, 2:58 pm, "Patrick.Sim... @intecsoft.com"
      <Patrick.Sim... @intecsoft.comw rote:
      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.C reate("ftp://" & m_sFTPIP & "//" &
      m_sNetTraDir & "/*.TRA") With m_oFTP
            .Credentials = New NetworkCredenti al(m_sFTPUsr, m_sFTPPwd)
            .UseBinary = True
            .KeepAlive = True
            .Method = WebRequestMetho ds.Ftp.ListDire ctoryDetails
            Try
                oResponseDir = .GetResponse()
                bRc = True
            Catch ex As Exception
             ....
      End With
      >
      The trace file shows this:
      >
      System.Net Verbose: 0 : [3956] WebRequest::Cre ate(ftp://10.70.5.19//
      EXPORT/FTP_E02/*.TRA)
      System.Net Information: 0 : [3956]
      FtpWebRequest#6 4923656::.ctor( ftp://
      10.70.5.19//EXPORT/FTP_E02/*.TRA)
      System.Net Verbose: 0 : [3956] Exiting WebRequest::Cre ate()     ->
      FtpWebRequest#6 4923656
      System.Net Verbose: 0 : [3956] FtpWebRequest#6 4923656::GetRes ponse()
      System.Net Information: 0 : [3956]
      FtpWebRequest#6 4923656::GetRes ponse(Method=LI ST.)
      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#6 4923656::GetRes ponse - Unable to connect to the remote
      server
      System.Net Error: 0 : [3956]    at
      System.Net.FtpW ebRequest.GetRe sponse()
      System.Net Verbose: 0 : [3956] Exiting
      FtpWebRequest#6 4923656::GetRes ponse()
      >
      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.T imeout property (in
      miliseconds) to test it.



      Hope this helps,

      Onur Güzel

      Comment

      • Patrick.Simons@intecsoft.com

        #4
        Re: FtpWebRequest: ListDirectoryDe tails with &quot;Unable to connect tothe remote server&quot;

        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....

        Comment

        • kimiraikkonen

          #5
          Re: FtpWebRequest: ListDirectoryDe tails with &quot;Unable to connect tothe remote server&quot;

          On Oct 13, 5:44 pm, "Patrick.Sim... @intecsoft.com"
          <Patrick.Sim... @intecsoft.comw rote:
          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.Threadin g.Timeout.Infin ite


          Worth to try.

          Onur Güzel

          Comment

          • Patrick.Simons@intecsoft.com

            #6
            Re: FtpWebRequest: ListDirectoryDe tails with &quot;Unable to connect tothe remote server&quot;

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

            Any other thoughts?

            Comment

            • Patrick.Simons@intecsoft.com

              #7
              Re: FtpWebRequest: ListDirectoryDe tails with &quot;Unable to connect tothe remote server&quot;

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

              Comment

              Working...