tyrus
tyrus copied to clipboard
Handshake response not received
Environment
I tried to use the standalone client JDK as shown here https://tyrus.java.net/dependencies.html
And this is the exception I receive. But when I used javascript to connect server, it worked well.
Exception in thread "main" java.lang.RuntimeException: javax.websocket.DeploymentException: Handshake response not received.
at test.ChatClientEndpoint.
Java code: public static void main(String[] args) throws Exception { final ChatClientEndpoint clientEndPoint = new ChatClientEndpoint(new URI("ws://localhost:9000")); clientEndPoint.addMessageHandler(new ChatClientEndpoint.MessageHandler() { public void handleMessage(String message)
{ System.out.println(message); }
}); while (true)
{ // clientEndPoint.sendMessage(getMessage("Hi There!!")); clientEndPoint.sendMessage("Hi There!!"); Thread.sleep(30000); }
}
Server side: bash-4.1# python server.py No handlers could be found for logger "trollius" WebSocket connection closed: connection was closed uncleanly (WebSocket opening handshake timeout (peer did not finish the opening handshake in time))
Affected Versions
[1.13]
- Issue Imported From: https://github.com/tyrus-project/tyrus/issues/613
- Original Issue Raised By:@glassfishrobot
- Original Issue Assigned To: @pavelbucek
@glassfishrobot Commented Reported by hplemon
@glassfishrobot Commented This issue was imported from java.net JIRA TYRUS-436
This issue has been reported in 2016 and is marked with priority "blocker" and there is no feedback on it. Is Tyrus still actively maintained? What's the state of this project?
@polarapfel The entire transfer from Oracle to Eclipse took a lot of time (it's technically still in progress even) and stalled the development of many projects. Things are slowly getting more active again.
@arjantijms What's the best way to report issues? I stumbled across this issue as it shares a similar stack trace to an issue I stumbled across.
I'm looking at a websocket client using Tyrus standalone (latest artifact in Maven). It connects to a wss endpoint. The connection fails when the client is in specific last mile networks and it works when in other networks.
When it fails, it comes back with this stacktrace:
javax.websocket.DeploymentException: Handshake response not received. at org.glassfish.tyrus.client.ClientManager$3$1.run(ClientManager.java:699) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.tyrus.client.ClientManager$3.run(ClientManager.java:717) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_171] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_171] at org.glassfish.tyrus.client.ClientManager$SameThreadExecutorService.execute(ClientManager.java:871) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112) ~[?:1.8.0_171] at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:516) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:378) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at com.microsoft.speechtranslationclient.Client.Connect(Client.java:151) [MachineTranslationSample-1.0-SNAPSHOT.jar:?] at com.microsoft.speechtranslationcli.SpeechTranslationCli.main(SpeechTranslationCli.java:36) [MachineTranslationSample-1.0-SNAPSHOT.jar:?] 11:36:02.138 [Grizzly(1)] ERROR com.microsoft.speechtranslationclient.Client - Error while sending message. java.io.IOException: Connection closed at org.glassfish.grizzly.asyncqueue.TaskQueue.onClose(TaskQueue.java:331) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.grizzly.nio.AbstractNIOAsyncQueueWriter.onClose(AbstractNIOAsyncQueueWriter.java:501) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.grizzly.nio.transport.TCPNIOTransport.closeConnection(TCPNIOTransport.java:402) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.grizzly.nio.NIOConnection.doClose(NIOConnection.java:647) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.grizzly.nio.NIOConnection$7.failed(NIOConnection.java:631) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.grizzly.nio.DefaultSelectorHandler$RunnableTask.cancel(DefaultSelectorHandler.java:513) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.grizzly.nio.DefaultSelectorHandler.addPendingTask(DefaultSelectorHandler.java:283) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.grizzly.nio.DefaultSelectorHandler.execute(DefaultSelectorHandler.java:248) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.grizzly.nio.NIOConnection.terminate0(NIOConnection.java:607) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.grizzly.nio.transport.TCPNIOConnection.terminate0(TCPNIOConnection.java:291) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.grizzly.nio.NIOConnection.terminateSilently(NIOConnection.java:467) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.grizzly.nio.SelectorRunner.shutdownSelector(SelectorRunner.java:237) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.grizzly.nio.SelectorRunner.run(SelectorRunner.java:296) ~[MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591) [MachineTranslationSample-1.0-SNAPSHOT.jar:?] at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) [MachineTranslationSample-1.0-SNAPSHOT.jar:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171] Caused by: java.io.IOException: Locally closed
I ran Wireshark on the client machine executing the websocket client in both cases. I can see the handshake response from the server on the TCP/IP stack of the client in both cases.
After throwing out Tyrus and replacing it with the websocket client implementation from Jetty, I can see that the communication to the wss endpoint works without issues in those networks causing errors with Tyrus.
This looks like a bug in Tyrus to me. It's nasty as it only manifests itself under particular conditions depending on the client network.