Webservice FTP fails


K

kpg

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
 
Ad

Advertisements

K

kpg

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top