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

Add timeout to ssh connect #146

Closed
TAlonglong opened this issue Dec 12, 2022 · 0 comments · Fixed by #147
Closed

Add timeout to ssh connect #146

TAlonglong opened this issue Dec 12, 2022 · 0 comments · Fixed by #147

Comments

@TAlonglong
Copy link
Collaborator

TAlonglong commented Dec 12, 2022

I have seen ssh connect get stuck when, for some unknown reason, the destination server can not be reached.

This cause the connect to block for a undefined length of time, pending on the underlying system I think. I have seen like 4 minutes before it returns with an exception. And it try this 3 times.

When this happens none of the other clients get their request handled, and when the connection finally get to the next client the file is deleted by the server and any transfer fails.

I want to add a timeout in the SSHClient connect.

Debugging this I to like this:

>>> from trollmoves import movers
>>> m = movers.ScpMover("/tmp/test", "scp://ubuntu@<test-address>:22/home/ubuntu")
>>> m.open_connection()
<paramiko.client.SSHClient object at 0x7f1522682850>
>>> m = movers.ScpMover("/tmp/test", "scp://ubuntu@<test-address>:23/home/ubuntu")
>>> m.open_connection()
Unknown exception at init SSHClient: [Errno 110] Connection timed out
Traceback (most recent call last):
  File "/home/trygveas/pytroll/trollmoves/trollmoves/movers.py", line 310, in open_connection
    ssh_connection.connect(self.destination.hostname,
  File "/home/trygveas/miniconda3/envs/trollmoves/lib/python3.9/site-packages/paramiko/client.py", line 358, in connect
    retry_on_signal(lambda: sock.connect(addr))
  File "/home/trygveas/miniconda3/envs/trollmoves/lib/python3.9/site-packages/paramiko/util.py", line 279, in retry_on_signal
    return function()
  File "/home/trygveas/miniconda3/envs/trollmoves/lib/python3.9/site-packages/paramiko/client.py", line 358, in <lambda>
    retry_on_signal(lambda: sock.connect(addr))
TimeoutError: [Errno 110] Connection timed out

times 3

I'm not 100% this port trick simulates what actually happened, but I looks very like so I will give it a try.

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

Successfully merging a pull request may close this issue.

1 participant