B4J Question Secure websocket connection won't connect at first attempt

Chris2

Active Member
Licensed User
Hello everyone.
I'm having a problem getting a secure websocket connection (B4J client to B4J server) to connect consistently....

Based on the various examples in the forum, I've merged the Websocket Push framework with the SQLite version of jRDC2 created by @OliverA, and created a client B4J app to connect to it using Basic Authentication.
That works fine.

I'm now been trying to change it to use secure connections (https and wss) using a self-signed certificate based on the info in:

When not using SSL the connection from the client app to the RDC app via https & wss is established OK every time.
But when using SSL, the websocket connection errors on the first connection attempt with the following error in the logs, but then usually connects successfully when the ReconnectTimer kicks in. The https connection still connects OK every time.

Waiting for debugger to connect...
Program started.
(Http client initialized with accept all option.)
Create
2022-08-11 12:30:47.606:INFO::JavaFX Application Thread: Logging initialized @4102ms to org.eclipse.jetty.util.log.StdErrLog
UpdateStatus: false
org.eclipse.jetty.websocket.api.UpgradeException: 0 null
at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.onComplete(WebSocketUpgradeRequest.java:515)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:193)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:185)
at org.eclipse.jetty.client.HttpReceiver.terminateResponse(HttpReceiver.java:464)
at org.eclipse.jetty.client.HttpReceiver.abort(HttpReceiver.java:545)
at org.eclipse.jetty.client.HttpReceiver.responseFailure(HttpReceiver.java:436)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.failAndClose(HttpReceiverOverHTTP.java:369)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.earlyEOF(HttpReceiverOverHTTP.java:338)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1476)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.shutdown(HttpReceiverOverHTTP.java:209)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:147)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:73)
at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:133)
at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:155)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:291)
at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:151)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:760)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:678)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.io.EOFException: HttpConnectionOverHTTP@6d5ea1e5(l:/127.0.0.1:51238 <-> r:localhost/127.0.0.1:17179,closed=false)=>HttpChannelOverHTTP@35e689a7(exchange=HttpExchange@7d953507 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@2d39e3c4(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@30825cf6{s=START}],recv=HttpReceiverOverHTTP@31a850f0(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]<-DecryptedEndPoint@561ffc02{localhost/127.0.0.1:17179<->/127.0.0.1:51238,OPEN,fill=-,flush=-,to=11/0}->HttpConnectionOverHTTP@6d5ea1e5(l:/127.0.0.1:51238 <-> r:localhost/127.0.0.1:17179,closed=false)=>HttpChannelOverHTTP@35e689a7(exchange=HttpExchange@7d953507 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@2d39e3c4(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@30825cf6{s=START}],recv=HttpReceiverOverHTTP@31a850f0(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]->SocketChannelEndPoint@38868f10{localhost/127.0.0.1:17179<->/127.0.0.1:51238,ISHUT,fill=-,flush=-,to=10/0}{io=0/0,kio=0,kro=1}->SslConnection@1bd261fe{NEED_WRAP,eio=-1/-1,di=-1}=>HttpConnectionOverHTTP@6d5ea1e5(l:/127.0.0.1:51238 <-> r:localhost/127.0.0.1:17179,closed=false)=>HttpChannelOverHTTP@35e689a7(exchange=HttpExchange@7d953507 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@2d39e3c4(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@30825cf6{s=START}],recv=HttpReceiverOverHTTP@31a850f0(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]
... 21 more
org.eclipse.jetty.websocket.api.UpgradeException: 0 null
at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.onComplete(WebSocketUpgradeRequest.java:522)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:193)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:185)
at org.eclipse.jetty.client.HttpReceiver.terminateResponse(HttpReceiver.java:464)
at org.eclipse.jetty.client.HttpReceiver.abort(HttpReceiver.java:545)
at org.eclipse.jetty.client.HttpReceiver.responseFailure(HttpReceiver.java:436)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.failAndClose(HttpReceiverOverHTTP.java:369)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.earlyEOF(HttpReceiverOverHTTP.java:338)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1476)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.shutdown(HttpReceiverOverHTTP.java:209)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:147)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:73)
at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:133)
at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:155)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:291)
at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:151)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:760)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:678)
at java.base/java.lang.Thread.run(Thread.java:834)
java.util.concurrent.ExecutionException: org.eclipse.jetty.websocket.api.UpgradeException: 0 null
at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
at anywhersoftware.b4j.objects.WebSocketClientWrapper.Close(WebSocketClientWrapper.java:102)
at anywhersoftware.b4j.objects.WebSocketClientWrapper$WSHandler.onWebSocketError(WebSocketClientWrapper.java:151)
at org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver.onError(JettyListenerEventDriver.java:112)
at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.incomingError(AbstractEventDriver.java:96)
at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.handleException(WebSocketUpgradeRequest.java:528)
at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.onComplete(WebSocketUpgradeRequest.java:522)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:193)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:185)
at org.eclipse.jetty.client.HttpReceiver.terminateResponse(HttpReceiver.java:464)
at org.eclipse.jetty.client.HttpReceiver.abort(HttpReceiver.java:545)
at org.eclipse.jetty.client.HttpReceiver.responseFailure(HttpReceiver.java:436)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.failAndClose(HttpReceiverOverHTTP.java:369)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.earlyEOF(HttpReceiverOverHTTP.java:338)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1476)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.shutdown(HttpReceiverOverHTTP.java:209)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:147)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:73)
at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:133)
at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:155)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:291)
at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:151)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:760)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:678)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.eclipse.jetty.websocket.api.UpgradeException: 0 null
at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.onComplete(WebSocketUpgradeRequest.java:515)
... 27 more
Caused by: java.io.EOFException: HttpConnectionOverHTTP@6d5ea1e5(l:/127.0.0.1:51238 <-> r:localhost/127.0.0.1:17179,closed=false)=>HttpChannelOverHTTP@35e689a7(exchange=HttpExchange@7d953507 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@2d39e3c4(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@30825cf6{s=START}],recv=HttpReceiverOverHTTP@31a850f0(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]<-DecryptedEndPoint@561ffc02{localhost/127.0.0.1:17179<->/127.0.0.1:51238,OPEN,fill=-,flush=-,to=11/0}->HttpConnectionOverHTTP@6d5ea1e5(l:/127.0.0.1:51238 <-> r:localhost/127.0.0.1:17179,closed=false)=>HttpChannelOverHTTP@35e689a7(exchange=HttpExchange@7d953507 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@2d39e3c4(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@30825cf6{s=START}],recv=HttpReceiverOverHTTP@31a850f0(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]->SocketChannelEndPoint@38868f10{localhost/127.0.0.1:17179<->/127.0.0.1:51238,ISHUT,fill=-,flush=-,to=10/0}{io=0/0,kio=0,kro=1}->SslConnection@1bd261fe{NEED_WRAP,eio=-1/-1,di=-1}=>HttpConnectionOverHTTP@6d5ea1e5(l:/127.0.0.1:51238 <-> r:localhost/127.0.0.1:17179,closed=false)=>HttpChannelOverHTTP@35e689a7(exchange=HttpExchange@7d953507 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@2d39e3c4(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@30825cf6{s=START}],recv=HttpReceiverOverHTTP@31a850f0(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]
... 21 more
WebSocket Closed: 0 null
UpdateStatus: false
org.eclipse.jetty.websocket.api.UpgradeException: 0 null
at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.onComplete(WebSocketUpgradeRequest.java:515)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:193)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:185)
at org.eclipse.jetty.client.HttpReceiver.terminateResponse(HttpReceiver.java:464)
at org.eclipse.jetty.client.HttpReceiver.abort(HttpReceiver.java:545)
at org.eclipse.jetty.client.HttpReceiver.responseFailure(HttpReceiver.java:436)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.failAndClose(HttpReceiverOverHTTP.java:369)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.earlyEOF(HttpReceiverOverHTTP.java:338)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1476)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.shutdown(HttpReceiverOverHTTP.java:209)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:147)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:73)
at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:133)
at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:155)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:291)
at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:151)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:760)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:678)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.io.EOFException: HttpConnectionOverHTTP@7e070747(l:/127.0.0.1:51246 <-> r:localhost/127.0.0.1:17179,closed=false)=>HttpChannelOverHTTP@339ac900(exchange=HttpExchange@3d5d2103 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@3962a270(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@7c602b38{s=START}],recv=HttpReceiverOverHTTP@19d73f7d(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]<-DecryptedEndPoint@4d56507d{localhost/127.0.0.1:17179<->/127.0.0.1:51246,OPEN,fill=-,flush=-,to=8/0}->HttpConnectionOverHTTP@7e070747(l:/127.0.0.1:51246 <-> r:localhost/127.0.0.1:17179,closed=false)=>HttpChannelOverHTTP@339ac900(exchange=HttpExchange@3d5d2103 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@3962a270(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@7c602b38{s=START}],recv=HttpReceiverOverHTTP@19d73f7d(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]->SocketChannelEndPoint@610b1a85{localhost/127.0.0.1:17179<->/127.0.0.1:51246,ISHUT,fill=-,flush=-,to=6/0}{io=0/0,kio=0,kro=1}->SslConnection@1c4fd477{NEED_WRAP,eio=-1/-1,di=-1}=>HttpConnectionOverHTTP@7e070747(l:/127.0.0.1:51246 <-> r:localhost/127.0.0.1:17179,closed=false)=>HttpChannelOverHTTP@339ac900(exchange=HttpExchange@3d5d2103 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@3962a270(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@7c602b38{s=START}],recv=HttpReceiverOverHTTP@19d73f7d(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]
... 21 more
org.eclipse.jetty.websocket.api.UpgradeException: 0 null
at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.onComplete(WebSocketUpgradeRequest.java:522)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:193)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:185)
at org.eclipse.jetty.client.HttpReceiver.terminateResponse(HttpReceiver.java:464)
at org.eclipse.jetty.client.HttpReceiver.abort(HttpReceiver.java:545)
at org.eclipse.jetty.client.HttpReceiver.responseFailure(HttpReceiver.java:436)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.failAndClose(HttpReceiverOverHTTP.java:369)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.earlyEOF(HttpReceiverOverHTTP.java:338)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1476)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.shutdown(HttpReceiverOverHTTP.java:209)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:147)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:73)
at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:133)
at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:155)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:291)
at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:151)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:760)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:678)
at java.base/java.lang.Thread.run(Thread.java:834)
java.util.concurrent.ExecutionException: org.eclipse.jetty.websocket.api.UpgradeException: 0 null
at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
at anywhersoftware.b4j.objects.WebSocketClientWrapper.Close(WebSocketClientWrapper.java:102)
at anywhersoftware.b4j.objects.WebSocketClientWrapper$WSHandler.onWebSocketError(WebSocketClientWrapper.java:151)
at org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver.onError(JettyListenerEventDriver.java:112)
at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.incomingError(AbstractEventDriver.java:96)
at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.handleException(WebSocketUpgradeRequest.java:528)
at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.onComplete(WebSocketUpgradeRequest.java:522)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:193)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:185)
at org.eclipse.jetty.client.HttpReceiver.terminateResponse(HttpReceiver.java:464)
at org.eclipse.jetty.client.HttpReceiver.abort(HttpReceiver.java:545)
at org.eclipse.jetty.client.HttpReceiver.responseFailure(HttpReceiver.java:436)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.failAndClose(HttpReceiverOverHTTP.java:369)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.earlyEOF(HttpReceiverOverHTTP.java:338)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1476)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.shutdown(HttpReceiverOverHTTP.java:209)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:147)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:73)
at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:133)
at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:155)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:291)
at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:151)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:760)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:678)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.eclipse.jetty.websocket.api.UpgradeException: 0 null
at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.onComplete(WebSocketUpgradeRequest.java:515)
... 27 more
Caused by: java.io.EOFException: HttpConnectionOverHTTP@7e070747(l:/127.0.0.1:51246 <-> r:localhost/127.0.0.1:17179,closed=false)=>HttpChannelOverHTTP@339ac900(exchange=HttpExchange@3d5d2103 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@3962a270(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@7c602b38{s=START}],recv=HttpReceiverOverHTTP@19d73f7d(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]<-DecryptedEndPoint@4d56507d{localhost/127.0.0.1:17179<->/127.0.0.1:51246,OPEN,fill=-,flush=-,to=8/0}->HttpConnectionOverHTTP@7e070747(l:/127.0.0.1:51246 <-> r:localhost/127.0.0.1:17179,closed=false)=>HttpChannelOverHTTP@339ac900(exchange=HttpExchange@3d5d2103 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@3962a270(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@7c602b38{s=START}],recv=HttpReceiverOverHTTP@19d73f7d(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]->SocketChannelEndPoint@610b1a85{localhost/127.0.0.1:17179<->/127.0.0.1:51246,ISHUT,fill=-,flush=-,to=6/0}{io=0/0,kio=0,kro=1}->SslConnection@1c4fd477{NEED_WRAP,eio=-1/-1,di=-1}=>HttpConnectionOverHTTP@7e070747(l:/127.0.0.1:51246 <-> r:localhost/127.0.0.1:17179,closed=false)=>HttpChannelOverHTTP@339ac900(exchange=HttpExchange@3d5d2103 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@3962a270(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@7c602b38{s=START}],recv=HttpReceiverOverHTTP@19d73f7d(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]
... 21 more
WebSocket Closed: 0 null
UpdateStatus: false
WebSocket Connected <------- when the ReconnectTimer tries again to connect the websocket
wsh.ws.Connected=true
UpdateStatus: true
wsh_NewMessage
msgID= 14
msgText= connection is secure
Main.NewMessage

I've created and attached simple example apps that demonstrate the problem:
jRDC-withWS.zip is the server app. I've put a copy of the self created keystore file in the .../Objects/ folder which is where the app looks for it when run through the IDE (File.DirApp)

SecureWStest.zip is the client app:
Commenting/uncommenting line 40/41 in Main will switch it between using http & https
Commenting/uncommenting line 47/48 in WSPushService will switch it between using ws & wss for the websocket.
I've also attached a blank SQLite database which the RDC app expects to find in C:\B4J\ (lines 33 & 34 in RDCConnector in jRDC-WS)

Can anyone tell me why the websocket connection fails with SSL on the first connection attempt every time?
 

Attachments

  • SecureWStest.zip
    7.9 KB · Views: 116
  • jRDC-withWS.zip
    19.8 KB · Views: 113
  • sqlitedb.zip
    270 bytes · Views: 107
Last edited:

OliverA

Expert
Licensed User
Longtime User
Upvote 0

Chris2

Active Member
Licensed User
Thanks both.

See the note in the below link about sessions not being automatically created in the new jServer implementation.
This doesn't seem to make much difference for me in the test apps, although I'm getting inconsistent results. Ocassionally the websocket connects on app start, but usually it only connects after the reconnect timer kicks in.

Please make a test and run the server with jServer3 instead of jServer. Does it make any difference?
Using jServer3 seems to make it more likely that the initial websocket connection is successful, but again it is not 100% consistent.
 
Upvote 0

Chris2

Active Member
Licensed User
Just to reiterate as well, everything is fine if I use a non-secure websocket connection (ws://...). That way the websocket connects successfully on app start consistantly, whether using jServer 3 or 4.

It's only when I switch to a secure connection (wss://...) that it starts to fail to connect on app start.
 
Last edited:
Upvote 0

Chris2

Active Member
Licensed User
Hmm, OK, thanks again for looking at this, @Erel and @OliverA .
I'll post back if I find a definitive answer as to why it's unreliable for me.

It is always better to assume that connections can fail and retry to connect.
Absolutely. I will of course check the connection before trying to use it.
It just seemed strange to me that the https connection always connects first time but the wss one doesn't.
 
Upvote 0
Top