Possible race condition with local port forwarding
- Dominant language
- Java
- Stars
- 2.7k
- Forks
- 620
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 11
Description
I'm using sshj 0.17.2 at present and have been using the local port forwarding functionality to tunnel into a test container running a web server to run selenium tests for some time. This had been working fine.
About a week ago I added xvfb into my test infrastructure, to run the firefox instance in a headless fashion. Testing xvfb seemed to go well right up until I pointed it into the tunnelled web server rather than a local one.
I'm now seeing the following error intermittently when running tests which use selenium, normally at the points where the browser is changing pages or loading for a new test.
```
net.schmizz.sshj.connection.ConnectionException: Received data for nonexistent channel 5.
at net.schmizz.sshj.connection.ConnectionException$1.chain(ConnectionException.java:32) ~[sshj-0.15.0.jar:na]
at net.schmizz.sshj.connection.ConnectionException$1.chain(ConnectionException.java:26) ~[sshj-0.15.0.jar:na]
at net.schmizz.concurrent.Promise.deliverError(Promise.java:95) ~[sshj-0.15.0.jar:na]
at net.schmizz.concurrent.Event.deliverError(Event.java:72) ~[sshj-0.15.0.jar:na]
at net.schmizz.concurrent.ErrorDeliveryUtil.alertEvents(ErrorDeliveryUtil.java:34) ~[sshj-0.15.0.jar:na]
at net.schmizz.sshj.connection.channel.AbstractChannel.notifyError(AbstractChannel.java:218) ~[sshj-0.15.0.jar:na]
at net.schmizz.sshj.common.ErrorNotifiable$Util.alertAll(ErrorNotifiable.java:35) ~[sshj-0.15.0.jar:na]
at net.schmizz.sshj.connection.ConnectionImpl.notifyError(ConnectionImpl.java:262) ~[sshj-0.15.0.jar:na]
at net.schmizz.sshj.transport.TransportImpl.die(TransportImpl.java:597) ~[sshj-0.15.0.jar:na]
at net.schmizz.sshj.transport.Reader.run(Reader.java:68) ~[sshj-0.15.0.jar:na]
Caused by: net.schmizz.sshj.transport.TransportException: Received data for nonexistent channel 5.
at net.schmizz.sshj.transport.TransportImpl.gotDisconnect(TransportImpl.java:543) ~[sshj-0.15.0.jar:na]
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:498) ~[sshj-0.15.0.jar:na]
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:107) ~[sshj-0.15.0.jar:na]
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:175) ~[sshj-0.15.0.jar:na]
at net.schmizz.sshj.transport.Reader.run(Reader.java:60) ~[sshj-0.15.0.jar:na]
```
I've tried working around this in my framework by catching the issue, resetting the socket and port forwarder instance and trying the connection again, but it seems once it happens once it's pretty fatal to my test runs. The channel number changes each time I see the issue.
I'm going to spend a bit of time trying to put together some code to reproduce this more reliably, but it's going to involve unpicking a fairly large test framework to get at the relevant code.
I've seen a similar very old issue issue reported relating to the remote port forward functionality (#53), also not sure if it's relevant but I am reusing a single SSHClient per user/host combination and multiplexing any ssh connections via this single client similarly to (#230)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.