Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.1k views
in .NET FTP by (1.3k points)
Hi,
This may be an issue with our code, but I just wanted to check if there's any known issue with disposing of a connection.

When clsoing an SFTP connection, the following messages appear in our logs:

2012-07-19 12:35:48,323 [17] [(null)] [(null)] [(null)] ERROR EnterpriseDTLog - Cannot access a disposed object.
Object name: 'System.Net.Sockets.Socket'.
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.Socket'.
   at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult, SocketError& errorCode)
   at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
   at Xv8GsRCUgatLkTL5nv.UHGbK3YUXY0VkrdBfY.X5yeGsgxjY(IAsyncResult )


The code being used to dispose of the object is as follows:
       if (ftpClient.IsConnected)
                {
                    // Shut down client                
                    if (log.IsDebugEnabled) log.Debug("Quitting client");
                    try
                    {
                        ftpClient.Dispose();
                    }
                    catch (Exception e)
                    {
                        log.Warn("Error on DisConnect -- ignoring ", e);
                    }
                }


Thanks

1 Answer

0 votes
by (51.4k points)
I think this is happening because Dispose() does an abrupt close of the socket. Try calling Close() before calling dispose. This may take slightly longer since the client sends a QUIT command to the server and waits for a response, but it should avoid the exception.

- Hans (EnterpriseDT)

Categories

...