WebSocket not correctly closed in case of exceptions from okhttp3 web socket
surlemur opened this issue · 0 comments
A load test yielded the following exception (see also #54) from time to time:
2016-04-26 13:12:18,080 [EventThread] ERROR EventThread:81 - Task threw exception
java.lang.IllegalStateException: must call close()
at okhttp3.internal.ws.RealWebSocket.sendMessage(RealWebSocket.java:108) ~[na:na]
at io.socket.engineio.client.transports.WebSocket$3.call(WebSocket.java:173) ~[na:na]
at io.socket.engineio.parser.Parser.encodePacket(Parser.java:63) ~[na:na]
at io.socket.engineio.parser.Parser.encodePacket(Parser.java:42) ~[na:na]
at io.socket.engineio.client.transports.WebSocket.write(WebSocket.java:168) ~[na:na]
at io.socket.engineio.client.Transport$3.run(Transport.java:101) ~[na:na]
at io.socket.thread.EventThread.exec(EventThread.java:54) ~[na:na]
at io.socket.engineio.client.Transport.send(Transport.java:96) ~[na:na]
at io.socket.engineio.client.Socket.flush(Socket.java:605) ~[na:na]
at io.socket.engineio.client.Socket.onDrain(Socket.java:596) ~[na:na]
at io.socket.engineio.client.Socket.access$1100(Socket.java:30) ~[na:na]
at io.socket.engineio.client.Socket$6.call(Socket.java:298) ~[na:na]
at io.socket.emitter.Emitter.emit(Emitter.java:117) ~[na:na]
at io.socket.engineio.client.transports.WebSocket$2$1.run(WebSocket.java:160) ~[na:na]
at io.socket.thread.EventThread$2.run(EventThread.java:79) ~[na:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_06]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_06]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_06]
The reason is probably that IOExceptions thrown from okhttp3's RealWebSocket.sendMessage do not lead to the engine.io WebSocket being properly closed.
By the way: consider logging in WebSocket L.178 as 'warning' at least, and add the original IOException.