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

Paramiko Transport hangs during initialization (with proposed solution) #1677

Open
kvancamp opened this issue May 5, 2020 · 0 comments
Open

Comments

@kvancamp
Copy link

kvancamp commented May 5, 2020

I have been experiencing intermittent timeouts in my AWS lambda function using python 3.7 and paramiko 2.7.1. It happens on the very first line of my code where I'm setting up the transport:

logging.info("Creating transport...")
self.transport = paramiko.Transport(self.sftpServer, self.sftpPort)
logging.info("Transport created, attempting to connect...")
...

Most of the time it works fine, but when it hangs then the transport initializer never returns. Eventually my lambda times out.

Through some debugging I found that it was hanging on line 409 of transport.py (of Paramiko 2.7.1):
retry_on_signal(lambda: sock.connect((hostname, port)))
It seems that the call to sock.settimeout() doesn't come until after this line, so my fix was to add the following immediately before line 409:
sock.settimeout(self._active_check_timeout)

I'm not sure this is the preferred solution since it puts sock.settimeout() call in 2 places, but it fixes the problem (I couldn't find any easy way to move the other call up since there are multiple paths to create the sock object).

This looks similar to issue #462 but seems to be different, so I'm opening a new issue.

I'm going to create a pull request with my fix. (Please be gentle, it's my first time contributing to any project on github :-). Feel free to reject it if there's a better solution.
Thanks
Ken

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

1 participant