org.springframework.messaging.converter.MessageConversionException: No suitable converter, payloadType=class java.lang.String, handlerType=class com.example.hello.MyStompSessionHandler

Stack Overflow | Chuck Liu | 4 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    how to use and customize MessageConversion(Spring websocket client)

    Stack Overflow | 4 months ago | Chuck Liu
    org.springframework.messaging.converter.MessageConversionException: No suitable converter, payloadType=class java.lang.String, handlerType=class com.example.hello.MyStompSessionHandler
  2. 0

    Websocket java client Spring + Stomp: Transport error: ConnectionLostException

    Stack Overflow | 8 months ago | lisdey89
    org.springframework.messaging.simp.stomp.ConnectionLostException: Connection closed
  3. 0

    Open client connections using: {code:java} RestTemplateXhrTransport xhrTransport = new RestTemplateXhrTransport(new RestTemplate()); transports.add(xhrTransport); sockJsClient = new SockJsClient(transports); stompClient = new WebSocketStompClient(sockJsClient); {code} are suddenly terminated (after running for hours) by the server saying: The remote endpoint was in state TEXT_PARTIAL_WRITING ... {code} [2016-01-29 03:37:57,126] org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.logWriteFrameFailure(AbstractSockJsSession.java:363) [DEBUG] [clientOutboundChannel-5] Terminating connection after failure to send message to client at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.writeFrameInternal(WebSocketServerSockJsSession.java:222) at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:325) at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.sendMessageInternal(WebSocketServerSockJsSession.java:212) at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.sendMessage(AbstractSockJsSession.java:161) [2016-01-29 03:37:57,135] org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator.handleTransportError(LoggingWebSocketHandlerDecorator.java:62) [DEBUG] [clientOutboundChannel-5] Transport error in WebSocketServerSockJsSe ssion[id=9f7bc8010fda4275bfd5426d76e95e0a] at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.disconnect(WebSocketServerSockJsSession.java:230) at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:331) at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.sendMessageInternal(WebSocketServerSockJsSession.java:212) at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.sendMessage(AbstractSockJsSession.java:161) [2016-01-29 03:37:57,136] org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator.afterConnectionClosed(LoggingWebSocketHandlerDecorator.java:70) [DEBUG] [clientOutboundChannel-5] WebSocketServerSockJsSession[id=9f7bc8010 fda4275bfd5426d76e95e0a] closed with CloseStatus[code=1011, reason=null] org.springframework.web.socket.sockjs.SockJsTransportFailureException: Failed to write SockJsFrame content='a["MESSAGE\ndestination:/vtsdb/global/manTrack\ncontent-type:application/json;ch...(truncated)'; nested exception is java.lang.Il legalStateException: The remote endpoint was in state [TEXT_PARTIAL_WRITING] which is an invalid state for called method at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:342) at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.sendMessageInternal(WebSocketServerSockJsSession.java:212) at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.sendMessage(AbstractSockJsSession.java:161) at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.writeFrameInternal(WebSocketServerSockJsSession.java:222) at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:325) {code} if I switch to: {code:java} StandardWebSocketClient wsClient = new StandardWebSocketClient(); transports.add(new WebSocketTransport(wsClient)); {code} the client connections becomes even more unstable receiving what appears to corrupt frames with a wrong payload length (wireshark). I have dumped the frames that causes the client to disconnct from wireshark and tried manually to decode it: {noformat} byte[] inputBuffer = DatatypeConverter.parseHexBinary("615b224d4553534147455c6e64657374696e6174696f6e3a2f76747364622f676c6f62616c2f5472616e7369745c6e636f6e74656e742d747970653a6170706c69636174696f6e2f6a736f6e3b636861727365743d5554462d385c6e737562736372697074696f6e3a325c6e6d6573736167652d69643a64303732363761666362333634653530626562373830393937613835653939662d313633333134375c6e636f6e74656e742d6c656e6774683a3135305c6e5c6e7b5c227374616c656169735c223a6e756c6c2c5c227374616c6574696d656169735c223a6e756c6c2c5c226576656e74747970655c223a5c227570646174655c222c5c227768656e6c6173747570646174655c223a5c22536174204a616e2032332031343a31393a30362055544320323031365c222c5c2269645c223a5c2235356632313835622d306461352d343339302d623961302d3533336532323432313833635c227d5c7530303030225d"); int readPos = 0; int b = inputBuffer[readPos++]; boolean fin = (b & 0x80) > 0; int rsv = (b & 0x70) >>> 4; byte opCode = (byte) (b & 0x0F); b = inputBuffer[readPos++]; long payloadLength = b & 0x7F; int headerLength = 0; if (payloadLength == 126) { headerLength += 2; } else if (payloadLength == 127) { headerLength += 8; } if (payloadLength == 126) { payloadLength = byteArrayToLong(inputBuffer, readPos, 2); readPos += 2; } else if (payloadLength == 127) { payloadLength = byteArrayToLong(inputBuffer, readPos, 8); readPos += 8; } out.println(format( "fin %s rsv %d opcode %d payloadLength %d isControl %s", fin, rsv, opCode, payloadLength, isControl(opCode))); {noformat} The stacktrace when a client receives a (corrupt?) frame is: {code:java} org.springframework.messaging.simp.stomp.ConnectionLostException: Connection closed at org.springframework.messaging.simp.stomp.DefaultStompSession.afterConnectionClosed(DefaultStompSession.java:459) at org.springframework.web.socket.messaging.WebSocketStompClient$WebSocketTcpConnectionHandlerAdapter.afterConnectionClosed(WebSocketStompClient.java:353) at org.springframework.web.socket.sockjs.client.AbstractClientSockJsSession.afterTransportClosed(AbstractClientSockJsSession.java:321) at org.springframework.web.socket.sockjs.client.WebSocketTransport$ClientSockJsWebSocketHandler.afterConnectionClosed(WebSocketTransport.java:172) at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.onClose(StandardWebSocketHandlerAdapter.java:143) at org.apache.tomcat.websocket.WsSession.fireEndpointOnClose(WsSession.java:527) at org.apache.tomcat.websocket.WsSession.onClose(WsSession.java:511) at org.apache.tomcat.websocket.WsFrameBase.processDataControl(WsFrameBase.java:342) at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:284) at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:130) at org.apache.tomcat.websocket.WsFrameClient.processSocketRead(WsFrameClient.java:73) at org.apache.tomcat.websocket.WsFrameClient.access$300(WsFrameClient.java:31) at org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.completed(WsFrameClient.java:125) at org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.completed(WsFrameClient.java:108) at sun.nio.ch.Invoker.invokeUnchecked(Unknown Source) at sun.nio.ch.Invoker$2.run(Unknown Source) at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) {code} If I dump only the printable text of the frame from wireshark it looks like this: {code} ["MESSAGE\ndestination:/vtsdb/global/Transit\ncontent-type:application/json;charset=UTF-8\nsubscription:2\nmessage-id:d07267afcb364e50beb780997a85e99f-1633147\ncontent-length:150\n\n{\"staleais\":null,\"staletimeais\":null,\"eventtype\":\"update\",\"whenlastupdate\":\"Sat Jan 23 14:19:06 UTC 2016\",\"id\":\"55f2185b-0da5-4390-b9a0-533e2242183c\"}\u0000"] {code} which looks like a sane message to me.

    Spring JIRA | 1 year ago | Carsten Madsen
    org.springframework.messaging.simp.stomp.ConnectionLostException: Connection closed
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    ConnectionLostException using Spring Boot with Tomcat Websocket

    Stack Overflow | 2 years ago | Langfo
    org.springframework.messaging.simp.stomp.ConnectionLostException: Connection closed
  6. 0

    Open client connections using: {code:java} RestTemplateXhrTransport xhrTransport = new RestTemplateXhrTransport(new RestTemplate()); transports.add(xhrTransport); sockJsClient = new SockJsClient(transports); stompClient = new WebSocketStompClient(sockJsClient); {code} are suddenly terminated (after running for hours) by the server saying: The remote endpoint was in state TEXT_PARTIAL_WRITING ... {code} [2016-01-29 03:37:57,126] org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.logWriteFrameFailure(AbstractSockJsSession.java:363) [DEBUG] [clientOutboundChannel-5] Terminating connection after failure to send message to client at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.writeFrameInternal(WebSocketServerSockJsSession.java:222) at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:325) at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.sendMessageInternal(WebSocketServerSockJsSession.java:212) at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.sendMessage(AbstractSockJsSession.java:161) [2016-01-29 03:37:57,135] org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator.handleTransportError(LoggingWebSocketHandlerDecorator.java:62) [DEBUG] [clientOutboundChannel-5] Transport error in WebSocketServerSockJsSe ssion[id=9f7bc8010fda4275bfd5426d76e95e0a] at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.disconnect(WebSocketServerSockJsSession.java:230) at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:331) at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.sendMessageInternal(WebSocketServerSockJsSession.java:212) at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.sendMessage(AbstractSockJsSession.java:161) [2016-01-29 03:37:57,136] org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator.afterConnectionClosed(LoggingWebSocketHandlerDecorator.java:70) [DEBUG] [clientOutboundChannel-5] WebSocketServerSockJsSession[id=9f7bc8010 fda4275bfd5426d76e95e0a] closed with CloseStatus[code=1011, reason=null] org.springframework.web.socket.sockjs.SockJsTransportFailureException: Failed to write SockJsFrame content='a["MESSAGE\ndestination:/vtsdb/global/manTrack\ncontent-type:application/json;ch...(truncated)'; nested exception is java.lang.Il legalStateException: The remote endpoint was in state [TEXT_PARTIAL_WRITING] which is an invalid state for called method at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:342) at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.sendMessageInternal(WebSocketServerSockJsSession.java:212) at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.sendMessage(AbstractSockJsSession.java:161) at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.writeFrameInternal(WebSocketServerSockJsSession.java:222) at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:325) {code} if I switch to: {code:java} StandardWebSocketClient wsClient = new StandardWebSocketClient(); transports.add(new WebSocketTransport(wsClient)); {code} the client connections becomes even more unstable receiving what appears to corrupt frames with a wrong payload length (wireshark). I have dumped the frames that causes the client to disconnct from wireshark and tried manually to decode it: {noformat} byte[] inputBuffer = DatatypeConverter.parseHexBinary("615b224d4553534147455c6e64657374696e6174696f6e3a2f76747364622f676c6f62616c2f5472616e7369745c6e636f6e74656e742d747970653a6170706c69636174696f6e2f6a736f6e3b636861727365743d5554462d385c6e737562736372697074696f6e3a325c6e6d6573736167652d69643a64303732363761666362333634653530626562373830393937613835653939662d313633333134375c6e636f6e74656e742d6c656e6774683a3135305c6e5c6e7b5c227374616c656169735c223a6e756c6c2c5c227374616c6574696d656169735c223a6e756c6c2c5c226576656e74747970655c223a5c227570646174655c222c5c227768656e6c6173747570646174655c223a5c22536174204a616e2032332031343a31393a30362055544320323031365c222c5c2269645c223a5c2235356632313835622d306461352d343339302d623961302d3533336532323432313833635c227d5c7530303030225d"); int readPos = 0; int b = inputBuffer[readPos++]; boolean fin = (b & 0x80) > 0; int rsv = (b & 0x70) >>> 4; byte opCode = (byte) (b & 0x0F); b = inputBuffer[readPos++]; long payloadLength = b & 0x7F; int headerLength = 0; if (payloadLength == 126) { headerLength += 2; } else if (payloadLength == 127) { headerLength += 8; } if (payloadLength == 126) { payloadLength = byteArrayToLong(inputBuffer, readPos, 2); readPos += 2; } else if (payloadLength == 127) { payloadLength = byteArrayToLong(inputBuffer, readPos, 8); readPos += 8; } out.println(format( "fin %s rsv %d opcode %d payloadLength %d isControl %s", fin, rsv, opCode, payloadLength, isControl(opCode))); {noformat} The stacktrace when a client receives a (corrupt?) frame is: {code:java} org.springframework.messaging.simp.stomp.ConnectionLostException: Connection closed at org.springframework.messaging.simp.stomp.DefaultStompSession.afterConnectionClosed(DefaultStompSession.java:459) at org.springframework.web.socket.messaging.WebSocketStompClient$WebSocketTcpConnectionHandlerAdapter.afterConnectionClosed(WebSocketStompClient.java:353) at org.springframework.web.socket.sockjs.client.AbstractClientSockJsSession.afterTransportClosed(AbstractClientSockJsSession.java:321) at org.springframework.web.socket.sockjs.client.WebSocketTransport$ClientSockJsWebSocketHandler.afterConnectionClosed(WebSocketTransport.java:172) at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.onClose(StandardWebSocketHandlerAdapter.java:143) at org.apache.tomcat.websocket.WsSession.fireEndpointOnClose(WsSession.java:527) at org.apache.tomcat.websocket.WsSession.onClose(WsSession.java:511) at org.apache.tomcat.websocket.WsFrameBase.processDataControl(WsFrameBase.java:342) at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:284) at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:130) at org.apache.tomcat.websocket.WsFrameClient.processSocketRead(WsFrameClient.java:73) at org.apache.tomcat.websocket.WsFrameClient.access$300(WsFrameClient.java:31) at org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.completed(WsFrameClient.java:125) at org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.completed(WsFrameClient.java:108) at sun.nio.ch.Invoker.invokeUnchecked(Unknown Source) at sun.nio.ch.Invoker$2.run(Unknown Source) at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) {code} If I dump only the printable text of the frame from wireshark it looks like this: {code} ["MESSAGE\ndestination:/vtsdb/global/Transit\ncontent-type:application/json;charset=UTF-8\nsubscription:2\nmessage-id:d07267afcb364e50beb780997a85e99f-1633147\ncontent-length:150\n\n{\"staleais\":null,\"staletimeais\":null,\"eventtype\":\"update\",\"whenlastupdate\":\"Sat Jan 23 14:19:06 UTC 2016\",\"id\":\"55f2185b-0da5-4390-b9a0-533e2242183c\"}\u0000"] {code} which looks like a sane message to me.

    Spring JIRA | 1 year ago | Carsten Madsen
    org.springframework.messaging.simp.stomp.ConnectionLostException: Connection closed

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.messaging.converter.MessageConversionException

      No suitable converter, payloadType=class java.lang.String, handlerType=class com.example.hello.MyStompSessionHandler

      at org.springframework.messaging.simp.stomp.DefaultStompSession.invokeHandler()
    2. Spring Messaging
      DefaultStompSession.handleMessage
      1. org.springframework.messaging.simp.stomp.DefaultStompSession.invokeHandler(DefaultStompSession.java:419)
      2. org.springframework.messaging.simp.stomp.DefaultStompSession.handleMessage(DefaultStompSession.java:373)
      2 frames
    3. Spring WebSocket
      WebSocketStompClient$WebSocketTcpConnectionHandlerAdapter.handleMessage
      1. org.springframework.web.socket.messaging.WebSocketStompClient$WebSocketTcpConnectionHandlerAdapter.handleMessage(WebSocketStompClient.java:342)
      1 frame
    4. org.springframework.web
      WebSocketTransport$ClientSockJsWebSocketHandler.handleTextMessage
      1. org.springframework.web.socket.sockjs.client.AbstractClientSockJsSession.handleMessageFrame(AbstractClientSockJsSession.java:267)
      2. org.springframework.web.socket.sockjs.client.AbstractClientSockJsSession.handleFrame(AbstractClientSockJsSession.java:200)
      3. org.springframework.web.socket.sockjs.client.WebSocketTransport$ClientSockJsWebSocketHandler.handleTextMessage(WebSocketTransport.java:162)
      3 frames
    5. Spring WebSocket
      StandardWebSocketHandlerAdapter$3.onMessage
      1. org.springframework.web.socket.handler.AbstractWebSocketHandler.handleMessage(AbstractWebSocketHandler.java:43)
      2. org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.handleTextMessage(StandardWebSocketHandlerAdapter.java:110)
      3. org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.access$000(StandardWebSocketHandlerAdapter.java:42)
      4. org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter.java:81)
      5. org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter.java:78)
      5 frames
    6. Tomcat WS
      WsFrameClient$WsFrameClientCompletionHandler.completed
      1. org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:399)
      2. org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:500)
      3. org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:295)
      4. org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:131)
      5. org.apache.tomcat.websocket.WsFrameClient.processSocketRead(WsFrameClient.java:73)
      6. org.apache.tomcat.websocket.WsFrameClient.access$300(WsFrameClient.java:31)
      7. org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.completed(WsFrameClient.java:131)
      8. org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.completed(WsFrameClient.java:114)
      8 frames
    7. Java RT
      Thread.run
      1. sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
      2. sun.nio.ch.Invoker$2.run(Invoker.java:218)
      3. sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
      4. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      5. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      6. java.lang.Thread.run(Thread.java:745)
      6 frames