Quantcast
Channel: sshnet Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 1026

Closed Issue: Unhandled exception during SftpClient Dispose [1581]

$
0
0
We are facing an unhandled exception during Dispose of the SftpClient.

2013-05-13 12:54:22,711 [2] FATAL - AppDomain.UnhandledException
Renci.SshNet.Common.SshConnectionException: Client not connected.
at Renci.SshNet.Session.SendMessage(Message message)
at Renci.SshNet.Channels.Channel.Close(Boolean wait)
at Renci.SshNet.Channels.ChannelSession.Close(Boolean wait)
at Renci.SshNet.Channels.Channel.Dispose(Boolean disposing)
at Renci.SshNet.Sftp.SubsystemSession.Dispose(Boolean disposing)
at Renci.SshNet.Sftp.SftpSession.Dispose(Boolean disposing)
at Renci.SshNet.SftpClient.Dispose(Boolean disposing)
at Renci.SshNet.BaseClient.Finalize()

This happens when the connection to the Ssh server is lost and affects our ability to gracefully handle situations when servers/connectivity goes down. O

The solution I suggest to swallow any exceptions coming from SftpClient.Dispose() as follows. Not pretty but as a general rule, Dispose shouldnt be throwing exceptions, unless such exceptions are symtomatic of a more serious problem.

Cheers

protected override void Dispose(bool disposing)
{
try
{
if (this._sftpSession != null)
{
this._sftpSession.Dispose();
this._sftpSession = null;
}

if (this._disposeConnectionInfo)
((IDisposable)this.ConnectionInfo).Dispose();

base.Dispose(disposing);
}
catch
{
// swallow it
}
}

Viewing all articles
Browse latest Browse all 1026

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>