TimeoutException while sending data via WebSocket

1.6k views Asked by At

I'm encountering java.util.concurrent.TimeoutException while sending data via WebSocket (Tomcat8 JSR-356). Refer the trace given below

java.io.IOException: java.util.concurrent.TimeoutException
    at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendPartialString(WsRemoteEndpointImplBase.java:258)
    at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendString(WsRemoteEndpointImplBase.java:193)
    at org.apache.tomcat.websocket.WsRemoteEndpointBasic.sendText(WsRemoteEndpointBasic.java:37)

I want to know if there are any circumstances under which we get this exception, apart from network latency related issues

Note : I'm facing this exception randomly. Tomcat version is 8.0.20

1

There are 1 answers

0
Andre Brito On

I had the same issue and it was caused by sending data in chunks (Chunked transfer encoding or chunk streaming)

In my case was HTTP Post and the fix was sending content-length in headers.

But it may be the case that the receiver is not prepared to read data in chunks and thus times out waiting for EOF of data.