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

Spring JIRA | Lee Standen | 3 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    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}

    Spring JIRA | 3 years ago | Lee Standen
    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
  2. 0

    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}

    Spring JIRA | 3 years ago | Lee Standen
    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

    Root Cause Analysis

    1. 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()
    2. Spring WebSocket
      AbstractSockJsSession.sendMessage
      1. org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:343)[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE]
      2. org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSession.flushCache(StreamingSockJsSession.java:70)[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE]
      3. org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession.tryFlushCache(AbstractHttpSockJsSession.java:310)[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE]
      4. org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession.sendMessageInternal(AbstractHttpSockJsSession.java:297)[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE]
      5. org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.sendMessage(AbstractSockJsSession.java:247)[spring-websocket-4.0.3.RELEASE.jar:4.0.3.RELEASE]
      5 frames
    3. org.me.chat
      WebSocketAdapter.lambda$afterConnectionEstablished$0
      1. org.me.chat.adapter.WebSocketAdapter.reply(WebSocketAdapter.java:336)[classes/:na]
      2. org.me.chat.adapter.WebSocketAdapter.lambda$afterConnectionEstablished$0(WebSocketAdapter.java:85)[classes/:na]
      2 frames