Webservice FTP fails

Discussion in 'ASP .Net Web Services' started by kpg, May 27, 2008.

  1. kpg

    kpg Guest

    Hi all,

    I have an ASP.NET 2.0 web service running on a Windows 2003 server that
    accepts data that it then FTP's to a remote FTP site, so it is acting as a
    data relay, of a sort.

    Usually once a day it begins to have trouble accessing the FTP site, it
    times out when trying to upload the file.

    I discovered that the FTP site was actually up and running, and when the
    web service was reset (via modifying the web.config file) then web service
    was once again was able to access the FTP site.

    I want this to work however I can get it to work.

    Is there a programatic way to 'reset' the webservice after each transfer?

    If this works around the problem it will give me some time to find the
    real problem.

    Thanks,
    kpg
    kpg, May 27, 2008
    #1
    1. Advertising

  2. kpg

    kpg Guest

    Some new info:

    The web service will upload to the FTP site 12 times. The 13th time
    it will timeout. Once the webservice is reset - that is modified in
    some way that IIS is forced to unload and JIT, then it will upload
    an additional 12 times.

    Note it does not matter what FTP site I upload to. I tested against
    a server on my local LAN and it fails the same way.

    This behavior leads me to believe that some session limit is being
    reached, however the FTP site will allow 100,000 connections, and
    in the test I uploaed once each second, but in production the files
    come in hours apart. The Web service will function normally for
    many hours (sometimes days) until 12 uploads are done, then I get
    FTP server timeouts.

    Note that the FTP server is up and running with no problems while
    the webservice is failing.

    Any ideas? This is driving me nuts.

    Thanks,
    kpg


    Here is the FTP upload code:

    Private Function Upload(ByVal FTPPath As String, ByVal Data As
    String, Optional ByVal UserName As String = "", Optional ByVal Password
    As String = "") As Boolean

    Try

    Dim buffer As Byte() = Encoding.UTF8.GetBytes(Data)

    Dim ftp As FtpWebRequest = CType(FtpWebRequest.Create
    (FTPPath), FtpWebRequest)
    If UserName.Length <> 0 Then
    ftp.Credentials = New NetworkCredential(UserName,
    Password)
    End If

    ftp.KeepAlive = False
    ftp.UseBinary = True
    ftp.Method = WebRequestMethods.Ftp.UploadFile
    ftp.GetRequestStream().Write(buffer, 0, buffer.Length)

    Upload = True

    Catch ex As Exception

    WriteToLog("Upload Error: " & ex.Message)

    End Try

    End Function
    kpg, May 28, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. someone

    FTP over SSL vs FTP over SSH

    someone, Apr 24, 2004, in forum: Java
    Replies:
    1
    Views:
    4,579
    iksrazal
    Apr 25, 2004
  2. Replies:
    3
    Views:
    5,621
  3. Nico Grubert
    Replies:
    0
    Views:
    637
    Nico Grubert
    Nov 24, 2005
  4. Nico Grubert
    Replies:
    0
    Views:
    443
    Nico Grubert
    Nov 25, 2005
  5. D. Buck
    Replies:
    2
    Views:
    477
    D. Buck
    Jun 29, 2004
Loading...

Share This Page