clj-commons / clj-commons/clj-ssh
Packet corrupt on connection failure
- Dominant language
- Clojure
- Stars
- 241
- Forks
- 66
- PR merge metrics
- No merged PRs in 30d
Description
Very occasionally, for reasons I don't understand (maybe TCP close?), a session disconnects between two calls to `ssh/invoke`. Works for one command, and a few ms later, another command throws:
```
[2016/08/04 13:37:05.617] Caused by: com.jcraft.jsch.JSchException: Packet corrupt
[2016/08/04 13:37:05.617] at com.jcraft.jsch.Session.start_discard(Session.java:1059)
[2016/08/04 13:37:05.617] at com.jcraft.jsch.Session.read(Session.java:929)
[2016/08/04 13:37:05.617] at com.jcraft.jsch.Session.connect(Session.java:309)
[2016/08/04 13:37:05.617] at com.jcraft.jsch.Session.connect(Session.java:183)
[2016/08/04 13:37:05.617] at clj_ssh.ssh$fn__3689.invoke(ssh.clj:118)
[2016/08/04 13:37:05.617] at clj_ssh.ssh.protocols$fn__3647$G__3614__3656.invoke(protocols.clj:4)
[2016/08/04 13:37:05.617] at clj_ssh.ssh$connect.invoke(ssh.clj:401)
[2016/08/04 13:37:05.617] at clj_ssh.ssh$ssh.invoke(ssh.clj:721)
```
This occurs when `invoke` checks whether the session is `connected?` prior to executing the command. If not, clj-ssh attempts to connect the session again. However, reconnecting closed sessions is illegal, which causes the jsch state machine to explode with "packet corrupt". I thiiink I can work around this by dropping the session and creating a new one in my clj-ssh wrapper, but it's not obvious to me how we can do the same in clj-ssh directly.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.