java.lang.IllegalStateException: The remote endpoint was in state [TEXT_PARTIAL_WRITING] which is an invalid state for called method

Stack Overflow | nilesh | 4 months ago
  1. 0

    Spring WebSocket : getting error while writing data to the socket

    Stack Overflow | 4 months ago | nilesh
    java.lang.IllegalStateException: The remote endpoint was in state [TEXT_PARTIAL_WRITING] which is an invalid state for called method
  2. 0

    I was able to reproduce the error message from Bug " SPR-14356". Here is the scenario for testing also I am not using STOMP framework 1. Created a scheduler which runs for every 5 seconds. configured the sockjs heartbeat at the same time and was getting this error : {noformat} 2016-08-05 19:28:04,963 TRACE [MessageBroker-1] o.s.w.s.s.t.s.WebSocketServerSockJsSession [AbstractSockJsSession.java:346] Preparing to write SockJsFrame content='h' 2016-08-05 19:28:04,964 TRACE [MessageBroker-1] o.s.w.s.s.t.s.WebSocketServerSockJsSession [WebSocketServerSockJsSession.java:219] Writing SockJsFrame content='h' 2016-08-05 19:28:04,964 TRACE [MessageBroker-1] o.s.w.s.a.NativeWebSocketSession [AbstractWebSocketSession.java:100] Sending TextMessage payload=[h], byteCount=1, last=true], StandardWebSocketSession[id=0, uri=/statchat-app-0.0.1-SNAPSHOT/onetoone/987/30pkeppn/websocket?email=statchat@hfhs.org&access_token=Bearer%20cwt=AAEBHAEFAAAAAAAFFQAAAHsAXEbHxgEhNpSCuUzpBQCBEPG03KmKqGVYoJGm-eyP8YKCAobPgyA44vbuH0LIQOXZWk_ou7d_oKHnFHrE_rxhUVcuhHL73oYIw6qBWsi90wgNEICZY2jjhKJSpjrDqcajWYI] 2016-08-05 19:28:04,965 TRACE [MessageBroker-4] o.s.w.s.s.t.s.WebSocketServerSockJsSession [AbstractSockJsSession.java:301] Cancelling heartbeat in session 30pkeppn 2016-08-05 19:28:04,966 TRACE [MessageBroker-4] o.s.w.s.s.t.s.WebSocketServerSockJsSession [AbstractSockJsSession.java:346] Preparing to write SockJsFrame content='a["{\"data\":\"ping from server 17\",\"type\":\"ping\"}"]' 2016-08-05 19:28:04,967 TRACE [MessageBroker-4] o.s.w.s.s.t.s.WebSocketServerSockJsSession [WebSocketServerSockJsSession.java:219] Writing SockJsFrame content='a["{\"data\":\"ping from server 17\",\"type\":\"ping\"}"]' 2016-08-05 19:28:04,967 TRACE [MessageBroker-4] o.s.w.s.a.NativeWebSocketSession [AbstractWebSocketSession.java:100] Sending TextMessage payload=[a["{\"data..], byteCount=57, last=true], StandardWebSocketSession[id=0, uri=/statchat-app-0.0.1-SNAPSHOT/onetoone/987/30pkeppn/websocket?email=statchat@hfhs.org&access_token=Bearer%20cwt=AAEBHAEFAAAAAAAFFQAAAHsAXEbHxgEhNpSCuUzpBQCBEPG03KmKqGVYoJGm-eyP8YKCAobPgyA44vbuH0LIQOXZWk_ou7d_oKHnFHrE_rxhUVcuhHL73oYIw6qBWsi90wgNEICZY2jjhKJSpjrDqcajWYI] 2016-08-05 19:28:04,970 TRACE [MessageBroker-1] o.s.w.s.s.t.s.WebSocketServerSockJsSession [AbstractSockJsSession.java:288] Scheduled heartbeat in session 30pkeppn 2016-08-05 19:28:05,032 DEBUG [MessageBroker-4] o.s.w.s.s.t.s.WebSocketServerSockJsSession [AbstractSockJsSession.java:387] Terminating connection after failure to send message to client java.lang.IllegalStateException: The remote endpoint was in state [TEXT_PARTIAL_WRITING] which is an invalid state for called method at org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.checkState(WsRemoteEndpointImplBase.java:1177) at org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.textPartialStart(WsRemoteEndpointImplBase.java:1135) at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendPartialString(WsRemoteEndpointImplBase.java:226) at org.apache.tomcat.websocket.WsRemoteEndpointBasic.sendText(WsRemoteEndpointBasic.java:49) at org.springframework.web.socket.adapter.standard.StandardWebSocketSession.sendTextMessage(StandardWebSocketSession.java:197) at org.springframework.web.socket.adapter.AbstractWebSocketSession.sendMessage(AbstractWebSocketSession.java:104) 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:349) 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:165) at org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator.tryFlushMessageBuffer(ConcurrentWebSocketSessionDecorator.java:131) at org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator.sendMessage(ConcurrentWebSocketSessionDecorator.java:104) at com.visionit.statchat.stomp.CustomStompSubProtocolHandler.handleMessageFromClient(CustomStompSubProtocolHandler.java:31) at org.springframework.web.socket.messaging.SubProtocolWebSocketHandler.handleMessage(SubProtocolWebSocketHandler.java:307) at org.springframework.web.socket.handler.WebSocketHandlerDecorator.handleMessage(WebSocketHandlerDecorator.java:75) at com.visionit.statchat.stomp.WebSocketSessionCapturingHandlerDecorator.handleMessage(WebSocketSessionCapturingHandlerDecorator.java:60) at com.visionit.statchat.stomp.WebSocketSessionCapturingHandlerDecorator.sendToAll(WebSocketSessionCapturingHandlerDecorator.java:154) at com.visionit.statchat.service.impl.RedisMessageListener.pingClients(RedisMessageListener.java:90) at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) 2016-08-05 19:28:05,034 DEBUG [MessageBroker-4] o.s.w.s.a.NativeWebSocketSession [AbstractWebSocketSession.java:137] Closing StandardWebSocketSession[id=0, uri=/statchat-app-0.0.1-SNAPSHOT/onetoone/987/30pkeppn/websocket?email=statchat@hfhs.org&access_token=Bearer%20cwt=AAEBHAEFAAAAAAAFFQAAAHsAXEbHxgEhNpSCuUzpBQCBEPG03KmKqGVYoJGm-eyP8YKCAobPgyA44vbuH0LIQOXZWk_ou7d_oKHnFHrE_rxhUVcuhHL73oYIw6qBWsi90wgNEICZY2jjhKJSpjrDqcajWYI] {noformat}

    Spring JIRA | 4 months ago | Nilesh Rao
    java.lang.IllegalStateException: The remote endpoint was in state [TEXT_PARTIAL_WRITING] which is an invalid state for called method
  3. 0

    WebSocket The remote endpoint was in state [TEXT_PARTIAL_WRITING]

    Stack Overflow | 2 years ago | mc j
    java.lang.IllegalStateException: The remote endpoint was in state [TEXT_PARTIAL_WRITING] which is an invalid state for called method
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    WebSocket The remote endpoint was in state [TEXT_PARTIAL_WRITING] | Solutions for enthusiast and professional programmers

    fatal-errors.com | 9 months ago
    java.lang.IllegalStateException: The remote endpoint was in state [TEXT_PARTIAL_WRITING] which is an invalid state for called method
  6. 0

    IllegalStateException [TEXT_PARTIAL_WRITING] when sending messages using WebSocketSession

    Stack Overflow | 2 years ago
    java.lang.IllegalStateException: The remote endpoint was in state [TEXT_PARTIAL_WRITING] which is an invalid state for called method

    4 unregistered visitors
    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. java.lang.IllegalStateException

      The remote endpoint was in state [TEXT_PARTIAL_WRITING] which is an invalid state for called method

      at org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.checkState()
    2. Tomcat WS
      WsRemoteEndpointBasic.sendText
      1. org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.checkState(WsRemoteEndpointImplBase.java:1177)
      2. org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.textPartialStart(WsRemoteEndpointImplBase.java:1135)
      3. org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendPartialString(WsRemoteEndpointImplBase.java:226)
      4. org.apache.tomcat.websocket.WsRemoteEndpointBasic.sendText(WsRemoteEndpointBasic.java:49)
      4 frames
    3. Spring WebSocket
      ConcurrentWebSocketSessionDecorator.sendMessage
      1. org.springframework.web.socket.adapter.standard.StandardWebSocketSession.sendTextMessage(StandardWebSocketSession.java:197)
      2. org.springframework.web.socket.adapter.AbstractWebSocketSession.sendMessage(AbstractWebSocketSession.java:105)
      3. org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.writeFrameInternal(WebSocketServerSockJsSession.java:222)
      4. org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:325)
      5. org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.sendMessageInternal(WebSocketServerSockJsSession.java:212)
      6. org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.sendMessage(AbstractSockJsSession.java:161)
      7. org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator.tryFlushMessageBuffer(ConcurrentWebSocketSessionDecorator.java:126)
      8. org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator.sendMessage(ConcurrentWebSocketSessionDecorator.java:99)
      8 frames
    4. com.visionit.statchat
      CustomStompSubProtocolHandler.handleMessageFromClient
      1. com.visionit.statchat.stomp.CustomStompSubProtocolHandler.handleMessageFromClient(CustomStompSubProtocolHandler.java:31)
      1 frame
    5. Spring WebSocket
      WebSocketHandlerDecorator.handleMessage
      1. org.springframework.web.socket.messaging.SubProtocolWebSocketHandler.handleMessage(SubProtocolWebSocketHandler.java:313)
      2. org.springframework.web.socket.handler.WebSocketHandlerDecorator.handleMessage(WebSocketHandlerDecorator.java:75)
      2 frames
    6. com.visionit.statchat
      RedisMessageListener.pingClients
      1. com.visionit.statchat.stomp.WebSocketSessionCapturingHandlerDecorator.sendToAll(WebSocketSessionCapturingHandlerDecorator.java:201)
      2. com.visionit.statchat.service.impl.RedisMessageListener.pingClients(RedisMessageListener.java:89)
      2 frames
    7. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:497)
      4 frames
    8. Spring Context
      DelegatingErrorHandlingRunnable.run
      1. org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
      2. org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
      2 frames
    9. Java RT
      Thread.run
      1. java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      2. java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
      3. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
      4. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
      5. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      6. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      7. java.lang.Thread.run(Thread.java:745)
      7 frames