Comments: No response, assumed fixed
Comments: No response, assumed fixed
Hi,
I wasn't suggesting the timeout as a solution, it was simply a hack to get it working for us in the meantime since our application should only be run on a local network for the now and therefore 5 seconds is reasonable.
I pulled down the source for 23481 and copied a build of the library over to my test bed (a server and a client VM, both linux, with simulated network cable disconnections to test the ability to maintain a tunnel).
Unfortunately there is still a runaway thread that causes the processor usage to ramp up when exiting the application.
Another similar effect is that the IsConnected property blocks for a very long time if the network cable is disconnected (it does not honour the ConnectionInfo.Timeout value). To help with that situation we have to launch a Task to check the connection and attempt a reconnect which means I can then Wait on the Task with a sensible timeout (yet another hack I'm afraid).
Regards,
Dan
Hi,
Ok, yea, no problem, just wanted to mentioned about this 5000 hack and make sure you aware of side effect.
As far as locking in IsConnected, there is no locking there with exception of this._socket.Poll method call which could potentially wait for a while.
I guess another idea, can you try this commit: 23468?
This is one of my ideas to fix this problem, this way I dont test for is connected but have a special variable to test for disposing situation.
Since it seems you can easily reproduce this error, can you try this commit and let me know if it works?
If it does, I guess I will make this as a solution.
Thanks,
Oleg
string host = "myhost";
string username = "joeschmo";
var agent = new PageantProtocol();
var conn = new AgentConnectionInfo(host,username,agent);
var client = new SshClient(conn));
(Insert appropriate exception handling of course...).
RobertOleg,
I'm afraid the 23468 build does not appear to deal with physical disconnects any differently. The IsConnected property still blocks and the tunnels still leave behind threads.
Regards,
Dan
Hmm,
Well, 23468 doesnt handle disconnect differently, it only insures that IsConnected is not called during disposing.
So may be a problem somewhere else :(:(.
Is it possible for you to create a test case that I can run locally to recreate the problem, or may be if possible to connect to test server that you have where I could recreate this problem. You can send me this info privately if such scenario is possible,
I guess one more idea, to prevent isConnected from blocking is to replace this:
```
isConnected = (!this._isDisconnecting && this._socket != null && this._socket.Connected && this._isAuthenticated && this._messageListenerCompleted != null)
&& this._socket.Poll(-1, SelectMode.SelectWrite);
```
with this:
```
isConnected = (!this._isDisconnecting && this._socket != null && this._socket.Connected && this._isAuthenticated && this._messageListenerCompleted != null);
```
And see if it still hangs on IsConnected
Thanks,
Oleg
[DllImport("user32.dll", EntryPoint = "SendMessageA", CallingConvention = CallingConvention.StdCall,
ExactSpelling = true)]
public static extern IntPtr SendMessage(IntPtr hWnd, int dwMsg, IntPtr wParam, ref COPYDATASTRUCT lParam);
Which is problematic in my view.