sshj icon indicating copy to clipboard operation
sshj copied to clipboard

Failed to connect to higher version OpenSSL server after configuring KeepAliveInterval

Open 2211898719 opened this issue 11 months ago • 3 comments

ssh.getConnection().getKeepAlive().setKeepAliveInterval(60);

image

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>

2211898719 avatar Mar 06 '24 02:03 2211898719

image

2211898719 avatar Mar 06 '24 02:03 2211898719

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

derklaro avatar Mar 06 '24 18:03 derklaro

How to customize it

2211898719 avatar Mar 07 '24 02:03 2211898719