Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autossh reconnection issue with sish #309

Open
manprint opened this issue Jun 17, 2024 · 6 comments
Open

Autossh reconnection issue with sish #309

manprint opened this issue Jun 17, 2024 · 6 comments

Comments

@manprint
Copy link

Hi @antoniomika,

I think I found an issue when using sish with autossh.
After starting sish with autossh with the following command, for example:

autossh -M 0 -p 2222 -R pico16-a:80:localhost:8004 sish.mydomain.link

When you want to stop the tunnel, since autossh automatically reconnects the tunnel, you have to press CTRL+C several times in rapid succession to stop sish session and exit autossh.

if you try to reconnect to the same domain sish says:

Warning: remote port forwarding failed for listen port 80
The subdomain pico16-a.sish.mydomain.link is unavailable.

In order to reuse the blocked domain, sish must be restarted
the problem is probably due to the fact that sish is very quick to reconnect.
I managed to replicate the issue several time.

A possible solution to mitigate the problem could be a parameter to delay the ssh connection when ssh is invoked? (--ssh-connection-delay=5s)

If you need to do further tests I can help you.

Best,
Fabio.

@manprint
Copy link
Author

Hi,
I did further tests and when what I described above happens, this is in the sish server logs:

2024/06/17 - 18:58:35 | Accepted SSH connection for: 172.18.0.3:53570
2024/06/17 - 18:58:35 | HTTP forwarding started: http://test.dev.synclabapps.link -> /tmp/172.18.0.3_53564_80332338001 for client: 172.18.0.3:53564
2024/06/17 - 18:58:35 | HTTPS forwarding started: https://test.dev.synclabapps.link -> /tmp/172.18.0.3_53564_80332338001 for client: 172.18.0.3:53564
2024/06/17 - 18:58:35 | Error replying to port forwarding request: read tcp 172.18.0.2:2222->172.18.0.3:53564: use of closed network connection
2024/06/17 - 18:58:36 | EOF
2024/06/17 - 18:58:51 | Accepted SSH connection for: 172.18.0.3:35654
2024/06/17 - 18:58:51 | Login attempt: 172.18.0.3:35654, user fabio key: ssh-rsa (REDACTED)
2024/06/17 - 18:58:51 | Error setting up HTTPListener: error assigning requested subdomain to tunnel

Step to reproduce the issue:

  1. start tunnel with autossh -M0 -p 2222 -R test:80:localhost:8080 dev.mydomain.link
  2. wait for 30+ seconds for the gate time (AUTOSSH_GATETIME=30 (default)) to finish
  3. repeatedly press or hold CTRL+C to stop sish session and autossh

I hope it helps you.
Best,
Fabio

@zk-steve
Copy link
Contributor

sish will close unused connections (include closed ones) by default, unless you mess something up with your configuration.

Otherwise, you can try to set:

force-requested-subdomains = true,

@antoniomika
Copy link
Owner

Agree with setting force-requested-subdomains.

I’m still looking into this as I’m wondering if maybe it has something to do with autossh’s monitor port.

@synclab-srl
Copy link

Hi,
I tried the setting you recommended, but it didn't work. The problem persists.
I attach a video of the test case in which the problem is highlighted.
I hope it can be of use to you.

sish_issue.mp4

Best,
Fabio

@synclab-srl
Copy link

synclab-srl commented Aug 7, 2024

Hi @antoniomika

In the past weeks I did some tests and with the help of a developer friend of mine, we found a way to solve the issue.

We added, to line 64 of sshmuxer/channel.go and to line 87 of utils/conn.go a sleep of 3 seconds.

In this way, the issue disappears: reconnections and stop/start tunnel with autossh work correctly.

I attach the modified files.

I did not make a pull request, because I think the fix is ​​dirty, surely you will have a better and more elegant way to solve the problem :D

Best,
Fabio.

modified_files_go.zip

@llapthorn
Copy link

Hello,
Just to confirm we see same behaviour on our side.
It can also be triggered when autossh have to reconnect due to a disconnection.
When the error "The alias xyz is unavailable", the only fix we found at the moment is to restart sish.
Regards,
Léo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants