Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Exception while disposing sshclient object

$
0
0
Hello all

I am using the SSH.Net library in a project where I connect to a NetApp host. This generally works very good. However in cases where the host does not answer I get the following exception:
A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied System.Net.Sockets.SocketException (0x80004005): A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied
   at System.Net.Sockets.Socket.Disconnect(Boolean reuseSocket)
   at Renci.SshNet.Session.SocketDisconnectAndDispose()
   at Renci.SshNet.Session.Disconnect(DisconnectReason reason, String message)
   at Renci.SshNet.Session.Dispose(Boolean disposing)
   at Renci.SshNet.BaseClient.Dispose(Boolean disposing)
   at Renci.SshNet.SshClient.Dispose(Boolean disposing)
   at Renci.SshNet.BaseClient.Dispose()
The code snipped I am using. The exception happens on the SshClientObject.Dispose(). Before I check if the object is still connected and then disconnect if needed. But I do not understand whe there is an exception while disposing the object.
if (!done) {
    if (SshClientObject != null) {
        SshClientObject.KeepAliveInterval = new TimeSpan(0, 0, 0, 0, -1);
        if (SshClientObject.IsConnected) {
            SshClientObject.Disconnect();
        }
        SshClientObject.Dispose();            <------ Exception here ....
        SshClientObject = null;
    }
    return false;
}
I am currently using the beta 1 version.

Any idea?
Philipp

Viewing all articles
Browse latest Browse all 1729

Trending Articles