java.lang.IllegalStateException: Unable to find decoder for type <javax.websocket.PongMessage> used in <org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$5>

Spring JIRA | Ralph Schaer | 3 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    I created a simple websocket client application that uses this configuration. {code:java} @Configuration public class Client { @Bean public WebSocketClient webSocketClient() { return new StandardWebSocketClient(); } @Bean public ClientWebSocketHandler clientWebSocketHandler() { return new ClientWebSocketHandler(); } @Bean public WebSocketConnectionManager webSocketConnectionManager(WebSocketClient webSocketClient, WebSocketHandler webSocketHandler) { WebSocketConnectionManager manager = new WebSocketConnectionManager(webSocketClient, webSocketHandler, "ws://localhost:8080/dispatcher/quotes"); manager.setAutoStartup(true); return manager; } public static void main(String[] args) throws InterruptedException { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Client.class); TimeUnit.MINUTES.sleep(1); } } {code} The ClientWebSocketHandler is a subclass of BinaryWebSocketHandler and listens for incoming data. The server is also a spring application running on Tomcat 7.0.47 and is periodically sending data. I tested this with different JSR 356 implementations. Tyrus: org.glassfish.tyrus.bundles:tyrus-standalone-client:1.3.3 Tomcat 7 org.apache.tomcat:tomcat7-websocket:7.0.47 Tomcat 8 org.apache.tomcat:tomcat-websocket:8.0.0-RC5 org.apache.tomcat:tomcat-coyote:8.0.0-RC5 The Jetty 9.1 native WebSocket implementation works fine too. Had to replace StandardWebSocketClient with JettyWebSocketClient. org.eclipse.jetty.websocket:websocket-client:9.1.0.v20131115 The only problem I have is with Jetty 9.1 and their JSR 356 implementation org.eclipse.jetty.websocket:javax-websocket-client-impl:9.1.0.v20131115 When I start the application it throws this exception {code} 08:37:27.520 [WebSocketClient@347453747-18] WARN o.e.j.w.j.e.JsrEndpointEventDriver - Uncaught exception java.lang.IllegalStateException: Unable to find decoder for type <javax.websocket.PongMessage> used in <org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$5> at org.eclipse.jetty.websocket.jsr356.JsrSession.addMessageHandler(JsrSession.java:113) ~[javax-websocket-client-impl-9.1.0.v20131115.jar:9.1.0.v20131115] at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.onOpen(StandardWebSocketHandlerAdapter.java:93) ~[spring-websocket-4.0.0.RELEASE.jar:4.0.0.RELEASE] {code} But after that exception the application works without any further problems. Complete source code of the example is hosted on GitHub Server: https://github.com/ralscha/playground/tree/master/springwebsocket Client: https://github.com/ralscha/playground/tree/master/springwebsocketclient

    Spring JIRA | 3 years ago | Ralph Schaer
    java.lang.IllegalStateException: Unable to find decoder for type <javax.websocket.PongMessage> used in <org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$5>
  2. 0

    I created a simple websocket client application that uses this configuration. {code:java} @Configuration public class Client { @Bean public WebSocketClient webSocketClient() { return new StandardWebSocketClient(); } @Bean public ClientWebSocketHandler clientWebSocketHandler() { return new ClientWebSocketHandler(); } @Bean public WebSocketConnectionManager webSocketConnectionManager(WebSocketClient webSocketClient, WebSocketHandler webSocketHandler) { WebSocketConnectionManager manager = new WebSocketConnectionManager(webSocketClient, webSocketHandler, "ws://localhost:8080/dispatcher/quotes"); manager.setAutoStartup(true); return manager; } public static void main(String[] args) throws InterruptedException { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Client.class); TimeUnit.MINUTES.sleep(1); } } {code} The ClientWebSocketHandler is a subclass of BinaryWebSocketHandler and listens for incoming data. The server is also a spring application running on Tomcat 7.0.47 and is periodically sending data. I tested this with different JSR 356 implementations. Tyrus: org.glassfish.tyrus.bundles:tyrus-standalone-client:1.3.3 Tomcat 7 org.apache.tomcat:tomcat7-websocket:7.0.47 Tomcat 8 org.apache.tomcat:tomcat-websocket:8.0.0-RC5 org.apache.tomcat:tomcat-coyote:8.0.0-RC5 The Jetty 9.1 native WebSocket implementation works fine too. Had to replace StandardWebSocketClient with JettyWebSocketClient. org.eclipse.jetty.websocket:websocket-client:9.1.0.v20131115 The only problem I have is with Jetty 9.1 and their JSR 356 implementation org.eclipse.jetty.websocket:javax-websocket-client-impl:9.1.0.v20131115 When I start the application it throws this exception {code} 08:37:27.520 [WebSocketClient@347453747-18] WARN o.e.j.w.j.e.JsrEndpointEventDriver - Uncaught exception java.lang.IllegalStateException: Unable to find decoder for type <javax.websocket.PongMessage> used in <org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$5> at org.eclipse.jetty.websocket.jsr356.JsrSession.addMessageHandler(JsrSession.java:113) ~[javax-websocket-client-impl-9.1.0.v20131115.jar:9.1.0.v20131115] at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.onOpen(StandardWebSocketHandlerAdapter.java:93) ~[spring-websocket-4.0.0.RELEASE.jar:4.0.0.RELEASE] {code} But after that exception the application works without any further problems. Complete source code of the example is hosted on GitHub Server: https://github.com/ralscha/playground/tree/master/springwebsocket Client: https://github.com/ralscha/playground/tree/master/springwebsocketclient

    Spring JIRA | 3 years ago | Ralph Schaer
    java.lang.IllegalStateException: Unable to find decoder for type <javax.websocket.PongMessage> used in <org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$5>

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Unable to find decoder for type <javax.websocket.PongMessage> used in <org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$5>

      at org.eclipse.jetty.websocket.jsr356.JsrSession.addMessageHandler()
    2. Jetty
      JsrSession.addMessageHandler
      1. org.eclipse.jetty.websocket.jsr356.JsrSession.addMessageHandler(JsrSession.java:113)[javax-websocket-client-impl-9.1.0.v20131115.jar:9.1.0.v20131115]
      1 frame
    3. Spring WebSocket
      StandardWebSocketHandlerAdapter.onOpen
      1. org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.onOpen(StandardWebSocketHandlerAdapter.java:93)[spring-websocket-4.0.0.RELEASE.jar:4.0.0.RELEASE]
      1 frame