rsp icon indicating copy to clipboard operation
rsp copied to clipboard

SSH Connection doesn't recover

Open nikosch86 opened this issue 4 years ago • 1 comments

It looks like if the SSH Connection is interrupted it never recovers, the connections are still in the pool and lead to the following error.
In my case I have rsp running in a screen, similar to how I use autossh, which survives connectivity interruption as it just reconnects automatically.
I tried messing with the code to make rsp re-establish the SSH Connection if it catches the SSH connection closed exception, but I can't seem to make it work.

2021-05-16 07:16:35 INFO     SocksListener: Client ('127.0.0.1', 60386) connected
2021-05-16 07:16:35 INFO     SocksListener: Client ('127.0.0.1', 60386) requested connection to duckduckgo.com:443
2021-05-16 07:16:35 ERROR    SocksListener: Connection handler stopped with exception: SSH connection closed
Traceback (most recent call last):
  File "/home/wurzelsepp/.local/lib/python3.8/site-packages/rsp/sockslistener.py", line 157, in handler
    dst_reader, dst_writer = await asyncio.wait_for(
  File "/usr/lib/python3.8/asyncio/tasks.py", line 491, in wait_for
    return fut.result()
  File "/home/wurzelsepp/.local/lib/python3.8/site-packages/asyncssh/connection.py", line 3548, in open_connection
    chan, session = await self.create_connection(SSHTCPStreamSession,
  File "/home/wurzelsepp/.local/lib/python3.8/site-packages/asyncssh/connection.py", line 3520, in create_connection
    chan = self.create_tcp_channel(encoding, errors, window, max_pktsize)
  File "/home/wurzelsepp/.local/lib/python3.8/site-packages/asyncssh/connection.py", line 2287, in create_tcp_channel
    return SSHTCPChannel(self, self._loop, encoding,
  File "/home/wurzelsepp/.local/lib/python3.8/site-packages/asyncssh/channel.py", line 110, in __init__
    self._recv_chan = conn.add_channel(self)
  File "/home/wurzelsepp/.local/lib/python3.8/site-packages/asyncssh/connection.py", line 943, in add_channel
    raise ChannelOpenError(OPEN_CONNECT_FAILED,
asyncssh.misc.ChannelOpenError: SSH connection closed
2021-05-16 07:16:35 INFO     SocksListener: Client ('127.0.0.1', 60386) disconnected

nikosch86 avatar May 16 '21 03:05 nikosch86

Also trying to mess with this to add reconnection. Did you have any luck? Alternatively, I wonder if we could use a bash script, but this might have to test the connection periodically, adding overhead.

gitterspec avatar Mar 19 '22 22:03 gitterspec