sshj
sshj copied to clipboard
Failed to connect to higher version OpenSSL server after configuring KeepAliveInterval
ssh.getConnection().getKeepAlive().setKeepAliveInterval(60);
net.schmizz.sshj.transport.TransportException: strict KEX violation: unexpected packet type 2 (seqnr 1) at net.schmizz.sshj.transport.TransportImpl.gotDisconnect(TransportImpl.java:548) ~[sshj-0.38.0.jar:na] at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:500) ~[sshj-0.38.0.jar:na] at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:113) ~[sshj-0.38.0.jar:na] at net.schmizz.sshj.transport.Decoder.received(Decoder.java:200) ~[sshj-0.38.0.jar:na] at net.schmizz.sshj.transport.Reader.run(Reader.java:60) ~[sshj-0.38.0.jar:na]
<dependency> <groupId>com.hierynomus</groupId> <artifactId>sshj</artifactId> <version>0.38.0</version> </dependency>
I had the same issue. Fixed by using a custom KeepAlive sender that just waits until the key exchange is completed before starting the hearbeat. This seems to be fixed with the KEEP_ALIVE
keepalive strategy, but not when using HEARTBEAT
:
https://github.com/hierynomus/sshj/blob/c0d1519ee2deb7083aece6dfd0e4c0f6f8696504/src/main/java/net/schmizz/keepalive/KeepAliveRunner.java#L53-L59
How to customize it