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

New Post: ObjectDisposedException Exception on SendKeepAlive()

$
0
0
Hello all

I'm using the ssh.net library in a project, which creates quite a lot of SSH connections to a host. For this I am using a pool of open SSH connections and disconnect them after a while if not used.

Establishing a connection is done as follows:
SshClientObject = new SshClient(_Host, _Username, _Password);
SshClientObject.KeepAliveInterval = new TimeSpan(0,0,1,0);
SshClientObject.Connect();
Disconnect is done as follows:
SshClientObject.Disconnect();
SshClientObject.KeepAliveInterval = new TimeSpan(-1);
SshClientObject.Dispose();
SshClientObject = null;
In rare cases I have an unhandled exception, which terminates the application (Windows Service):

at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, SocketError& errorCode)
at Renci.SshNet.Session.SocketWrite(Byte[] data)
at Renci.SshNet.Session.SendMessage(Message message)
at Renci.SshNet.BaseClient.SendKeepAlive()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.TimerQueueTimer.CallCallback()
at System.Threading.TimerQueueTimer.Fire()
at System.Threading.TimerQueue.FireNextTimers()

It seems that even when I set the KeepAliveInterval to -1 (should disable), the KeepAlive timer seems to fired after I have disposed the object.

I would think that disposing an object also stops all timers, expechally when I first disable the KeepAliveInterval.

Any idea how I could prevent this exception?

I'm using the latest stable Version (2013.4.7).

Philipp

Viewing all articles
Browse latest Browse all 1729

Trending Articles



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