Fix closed connection in pool #487
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @leehambley
This is the PR that aims to partially solve #483.
Sorry for the delay.
The change will do a simple polling (
process(0)) to check if the connection is still alive before we reuse it. If the connection is closed by remote, the polling will get<IOError: closed stream>which will be caught and consider the connection is already closed. It partially fixes #483 since when the keepalive check fails and remote host closes the connection, the connection won't be reused.However, it will not completely fix the issue because the keepalive packet should be responded by
ssh-kit/net-sshbut it doesn't. This could be fixed by introducing another thread that keep pooling connections in pool so thatnet-sshwill reply to keepalive packets. But I'm reluctant to do so since it would introduce new threads to maintain and complexity such as interval settings. I would like to fix the closed connection reuse issue first and leave the complete fix to others if it's needed.By the way, you can check out 48d6ff3 and run the test then it will reproduce the #483.