The only thing I can think of is to set KeepAlive to false - see code below
>Recently, to make sure that a FTP connection failure would not hold objects in memory, I adjusted my FTP.GetDirectory() method to use a Using\End Using syntax. Because, before, when such situation was happening, on the next minute, when the same robot task was executing again, it was never able to succeed.
>
>So, the main code in that method is as follow:
>
>
> Dim loFtpWebRequest As System.Net.FtpWebRequest = Nothing
> Dim loStringBuilder As Framework.StringBuilderFile = New Framework.StringBuilderFile(oApp)
>
> Try
>
> ' FTP setup
> loFtpWebRequest = System.Net.FtpWebRequest.Create(New Uri(lcURI))
loFtpWebRequest.KeepAlive = false
> loFtpWebRequest.Credentials = New System.Net.NetworkCredential(cUsername, cPassword)
> loFtpWebRequest.Method = System.Net.WebRequestMethods.Ftp.ListDirectoryDetails
>
> Using loFtpWebResponse = loFtpWebRequest.GetResponse()
>
> Using loStream As System.IO.Stream = loFtpWebResponse.GetResponseStream()
>
> Using loStreamReader As New StreamReader(loStream)
>
> ' Load the files into the string builder
> loStringBuilder.LoadString(loStreamReader.ReadToEnd())
>
> End Using
>
> End Using
>
> End Using
>
>
>The code in the application is as follow:
>
>
> Dim loFTP As Framework.Framework.FTP = New Framework.Framework.FTP(oApp)
>
> ' Initiate FTP settings
> loFTP.cHost = lcHost
> loFTP.cUsername = lcUsername
> loFTP.cPassword = lcPassword
> loFTP.cRemoteDirectory = lcDirectory
>
> ' If we cannot get the directory
> If Not loFTP.GetDirectory() Then
>
> ' This is where it ends up because the loFTP.GetDirectory() fails and I have some code to do the logging here
>
> Continue For
> End If
>
>
>However, recently, we got a timeout when trying to execute that robot task. So, we had a message like this:
>
>"The operation has timed out."
>
>So, on the next loop, it tried again to continue. But, it continued to end up in that situation. However, at the same time, someone decided to check manually with a FTP client and he succeeded to connect to the server. So, the server went back online. But, during that timeframe, even if the server went back online, my code was never able to execute. It is only when the EXE was stopped and restarted that it started to work again. So, something got stucked in memory.
>
>My perception is that this failed on the "Using loFtpWebResponse = loFtpWebRequest.GetResponse()" line. However, this should clear out any memory object related to it. So, I do not know what much more I can do here to make sure the memory is completely released when that method cannot execute. Because, when the FTP server cannot respond for a few minutes, when the FTP comes back online after, my EXE can no longer gain access to it. I have to stop and start it again. We need to find the cause and a solution to this. Anyone see what is wrong here?
Gregory