Skip to content

SSH Connection doesn't recover #7

@nikosch86

Description

@nikosch86

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

Activity

gitterspec

gitterspec commented on Mar 19, 2022

@gitterspec

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @nikosch86@gitterspec

        Issue actions

          SSH Connection doesn't recover · Issue #7 · Snawoot/rsp