Heya and thanks so much for this awesome library!
I'm actually using it in a Xamarin.iOS project (Shared Library) and evertyhing is working fine.
For testing purposes I'm forwarding my local port 8356 to 192.168.1.5's remote port 8080:
```
client.KeepAliveInterval = new TimeSpan(0, 0, 5);
client.Connect ();
port2 = new ForwardedPortLocal ("localhost", 8356, "192.168.1.5", 8080);
client.AddForwardedPort (port2);
port2.Exception += delegate(object sender, ExceptionEventArgs e)
{
Console.WriteLine(e.Exception.ToString());
};
port2.RequestReceived += delegate(object sender, PortForwardEventArgs e)
{
Console.WriteLine(e.OriginatorHost + ":" + e.OriginatorPort);
};
port2.Start ();
```
So I open localhost:8356 in my browser and the expected webpage appears. But approx. 5 secs after that, I get a SocketException: "The socket is not connected" in ForwardedPortLocal.NET.cs in
```
private static void CloseSocket(Socket socket)
```
at
```
socket.Shutdown(SocketShutdown.Both);
```
So just to make sure I modified it to:
```
if (socket.Connected)
{
socket.Shutdown(SocketShutdown.Both);
socket.Close();
}
```
strange enough, socket.Connected is true and exception is still thrown.
So as a rough fix I removed in FordwaredPortlocal.NET.cs in func private void AcceptCallback(IAsyncResult ar), line 102
```
channel.Close();
```
as well as CloseSocket(clientSocket); in the catch.
Anyone knows why this happens?
Comments: ** Comment from web user: drieseng **
I'm actually using it in a Xamarin.iOS project (Shared Library) and evertyhing is working fine.
For testing purposes I'm forwarding my local port 8356 to 192.168.1.5's remote port 8080:
```
client.KeepAliveInterval = new TimeSpan(0, 0, 5);
client.Connect ();
port2 = new ForwardedPortLocal ("localhost", 8356, "192.168.1.5", 8080);
client.AddForwardedPort (port2);
port2.Exception += delegate(object sender, ExceptionEventArgs e)
{
Console.WriteLine(e.Exception.ToString());
};
port2.RequestReceived += delegate(object sender, PortForwardEventArgs e)
{
Console.WriteLine(e.OriginatorHost + ":" + e.OriginatorPort);
};
port2.Start ();
```
So I open localhost:8356 in my browser and the expected webpage appears. But approx. 5 secs after that, I get a SocketException: "The socket is not connected" in ForwardedPortLocal.NET.cs in
```
private static void CloseSocket(Socket socket)
```
at
```
socket.Shutdown(SocketShutdown.Both);
```
So just to make sure I modified it to:
```
if (socket.Connected)
{
socket.Shutdown(SocketShutdown.Both);
socket.Close();
}
```
strange enough, socket.Connected is true and exception is still thrown.
So as a rough fix I removed in FordwaredPortlocal.NET.cs in func private void AcceptCallback(IAsyncResult ar), line 102
```
channel.Close();
```
as well as CloseSocket(clientSocket); in the catch.
Anyone knows why this happens?
Comments: ** Comment from web user: drieseng **
Can you provide the full stack trace of both the exception that was thrown (if any), and the exception that was signaled using the Exception event ?
Also, please specify which version of SSH.NET you're using.
If you're using beta 2 (or SSH.NET built from TFS/SVN), then removing the channel.Close() is ok, as we now perform the same actions in the Dispose method.
I'll try to reproduce this issue tomorrow.
Thanks!