Results 1 to 4 of 4

Thread: FTP Problem

  1. #1

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    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."
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  2. #2
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    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?

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  4. #4

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    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...
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width