org.springframework.web.socket.sockjs.SockJsTransportFailureException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • I've got an application which sends a stack of data to the client after they connect via websockets (basically initializing the state of the application). I'm getting a WritePendingException intermittently and I can't seem to find anywhere to catch and recover from it. Here's the stacktrace. {code}00:26:28.705 [qtp1378084334-31] ERROR o.s.w.s.h.ExceptionWebSocketHandlerDecorator - Closing due to exception for SockJS session id=819zm43n org.springframework.web.socket.sockjs.SockJsTransportFailureException: Failed to write SockJsFrame content='a["{\"messages\":[{\"message\":\"testo\",\"fromAccount\":{\"name\":\"Innominata\...(truncated)'; nested exception is java.io.IOException: java.nio.channels.WritePendingException at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:343) ~[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSession.flushCache(StreamingSockJsSession.java:70) ~[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession.tryFlushCache(AbstractHttpSockJsSession.java:310) ~[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession.sendMessageInternal(AbstractHttpSockJsSession.java:297) ~[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.sendMessage(AbstractSockJsSession.java:247) ~[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.me.chat.adapter.WebSocketAdapter.reply(WebSocketAdapter.java:336) ~[classes/:na] at org.me.chat.adapter.WebSocketAdapter.lambda$afterConnectionEstablished$0(WebSocketAdapter.java:85) ~[classes/:na] at org.me.chat.adapter.WebSocketAdapter$$Lambda$9/1679234307.accept(Unknown Source) ~[na:na] at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[na:1.8.0] at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1359) ~[na:1.8.0] at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512) ~[na:1.8.0] at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290) ~[na:1.8.0] at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731) ~[na:1.8.0] at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[na:1.8.0] at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:902) ~[na:1.8.0] at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1689) ~[na:1.8.0] at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1644) ~[na:1.8.0] at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[na:1.8.0] Caused by: java.io.IOException: java.nio.channels.WritePendingException at org.eclipse.jetty.util.BlockingCallback.block(BlockingCallback.java:101) ~[na:na] at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:125) ~[na:na] at org.eclipse.jetty.server.HttpOutput.flush(HttpOutput.java:221) ~[na:na] at org.eclipse.jetty.server.Response.flushBuffer(Response.java:1217) ~[na:na] at javax.servlet.ServletResponseWrapper.flushBuffer(ServletResponseWrapper.java:215) ~[servlet-api-3.1.jar:3.1.0] at javax.servlet.ServletResponseWrapper.flushBuffer(ServletResponseWrapper.java:215) ~[servlet-api-3.1.jar:3.1.0] at org.springframework.security.web.context.SaveContextOnUpdateOrErrorResponseWrapper.flushBuffer(SaveContextOnUpdateOrErrorResponseWrapper.java:135) ~[spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.http.server.ServletServerHttpResponse.flush(ServletServerHttpResponse.java:90) ~[spring-web-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSession.writeFrameInternal(StreamingSockJsSession.java:99) ~[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:332) ~[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] ... 17 common frames omitted Caused by: java.nio.channels.WritePendingException: null at org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:331) ~[na:na] at org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:125) ~[na:na] at org.eclipse.jetty.server.HttpConnection$ContentCallback.process(HttpConnection.java:680) ~[na:na] at org.eclipse.jetty.util.IteratingCallback.processIterations(IteratingCallback.java:166) ~[na:na] at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:126) ~[na:na] at org.eclipse.jetty.server.HttpConnection.send(HttpConnection.java:303) ~[na:na] at org.eclipse.jetty.server.HttpChannel.sendResponse(HttpChannel.java:720) ~[na:na] at org.eclipse.jetty.server.HttpChannel.write(HttpChannel.java:751) ~[na:na] at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:130) ~[na:na] at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:124) ~[na:na] ... 25 common frames omitted{code}
    via by Lee Standen,
  • I've got an application which sends a stack of data to the client after they connect via websockets (basically initializing the state of the application). I'm getting a WritePendingException intermittently and I can't seem to find anywhere to catch and recover from it. Here's the stacktrace. {code}00:26:28.705 [qtp1378084334-31] ERROR o.s.w.s.h.ExceptionWebSocketHandlerDecorator - Closing due to exception for SockJS session id=819zm43n org.springframework.web.socket.sockjs.SockJsTransportFailureException: Failed to write SockJsFrame content='a["{\"messages\":[{\"message\":\"testo\",\"fromAccount\":{\"name\":\"Innominata\...(truncated)'; nested exception is java.io.IOException: java.nio.channels.WritePendingException at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:343) ~[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSession.flushCache(StreamingSockJsSession.java:70) ~[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession.tryFlushCache(AbstractHttpSockJsSession.java:310) ~[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession.sendMessageInternal(AbstractHttpSockJsSession.java:297) ~[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.sendMessage(AbstractSockJsSession.java:247) ~[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.me.chat.adapter.WebSocketAdapter.reply(WebSocketAdapter.java:336) ~[classes/:na] at org.me.chat.adapter.WebSocketAdapter.lambda$afterConnectionEstablished$0(WebSocketAdapter.java:85) ~[classes/:na] at org.me.chat.adapter.WebSocketAdapter$$Lambda$9/1679234307.accept(Unknown Source) ~[na:na] at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[na:1.8.0] at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1359) ~[na:1.8.0] at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512) ~[na:1.8.0] at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290) ~[na:1.8.0] at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731) ~[na:1.8.0] at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[na:1.8.0] at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:902) ~[na:1.8.0] at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1689) ~[na:1.8.0] at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1644) ~[na:1.8.0] at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[na:1.8.0] Caused by: java.io.IOException: java.nio.channels.WritePendingException at org.eclipse.jetty.util.BlockingCallback.block(BlockingCallback.java:101) ~[na:na] at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:125) ~[na:na] at org.eclipse.jetty.server.HttpOutput.flush(HttpOutput.java:221) ~[na:na] at org.eclipse.jetty.server.Response.flushBuffer(Response.java:1217) ~[na:na] at javax.servlet.ServletResponseWrapper.flushBuffer(ServletResponseWrapper.java:215) ~[servlet-api-3.1.jar:3.1.0] at javax.servlet.ServletResponseWrapper.flushBuffer(ServletResponseWrapper.java:215) ~[servlet-api-3.1.jar:3.1.0] at org.springframework.security.web.context.SaveContextOnUpdateOrErrorResponseWrapper.flushBuffer(SaveContextOnUpdateOrErrorResponseWrapper.java:135) ~[spring-security-web-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.http.server.ServletServerHttpResponse.flush(ServletServerHttpResponse.java:90) ~[spring-web-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSession.writeFrameInternal(StreamingSockJsSession.java:99) ~[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:332) ~[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] ... 17 common frames omitted Caused by: java.nio.channels.WritePendingException: null at org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:331) ~[na:na] at org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:125) ~[na:na] at org.eclipse.jetty.server.HttpConnection$ContentCallback.process(HttpConnection.java:680) ~[na:na] at org.eclipse.jetty.util.IteratingCallback.processIterations(IteratingCallback.java:166) ~[na:na] at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:126) ~[na:na] at org.eclipse.jetty.server.HttpConnection.send(HttpConnection.java:303) ~[na:na] at org.eclipse.jetty.server.HttpChannel.sendResponse(HttpChannel.java:720) ~[na:na] at org.eclipse.jetty.server.HttpChannel.write(HttpChannel.java:751) ~[na:na] at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:130) ~[na:na] at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:124) ~[na:na] ... 25 common frames omitted{code}
    via by Lee Standen,
  • 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.
    via by Carsten Madsen,
  • 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.
    via by Carsten Madsen,
    • org.springframework.web.socket.sockjs.SockJsTransportFailureException: Failed to write SockJsFrame content='a["{\"messages\":[{\"message\":\"testo\",\"fromAccount\":{\"name\":\"Innominata\...(truncated)'; nested exception is java.io.IOException: java.nio.channels.WritePendingException at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:343)[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSession.flushCache(StreamingSockJsSession.java:70)[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession.tryFlushCache(AbstractHttpSockJsSession.java:310)[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession.sendMessageInternal(AbstractHttpSockJsSession.java:297)[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.sendMessage(AbstractSockJsSession.java:247)[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.me.chat.adapter.WebSocketAdapter.reply(WebSocketAdapter.java:336)[classes/:na] at org.me.chat.adapter.WebSocketAdapter.lambda$afterConnectionEstablished$0(WebSocketAdapter.java:85)[classes/:na]
    No Bugmate found.