socketio / engine.io-client-java

Engine.IO Client Library for Java
http://socketio.github.io/engine.io-client-java
Other
359 stars 167 forks source link

RejectedExecutionException Occured in onMessage. #53

Closed mypplication closed 3 years ago

mypplication commented 8 years ago

Same issue here > https://github.com/socketio/socket.io-client-java/issues/295

This bug is the result of how you use the OkHttpClient object. In version 3 of OkHttp, do not recreate the instance OkHttpClient each use in your code:

There is no longer a global singleton connection pool. In OkHttp 2.x, all OkHttpClient instances shared a common connection pool by default. In OkHttp 3.x, each new OkHttpClient gets its own private connection pool. Applications should avoid creating many connection pools as doing so prevents connection reuse. Each connection pool holds its own set of connections alive so applications that have many pools also risk exhausting memory!

https://github.com/socketio/engine.io-client-java/blob/master/src/main/java/io/socket/engineio/client/transports/WebSocket.java

nkzawa commented 8 years ago

Hi, thanks for your report. Let me know how to reproduce if possible.

mypplication commented 8 years ago

Hello, sorry but for the moment, i can't reproduce.. if you look pkHttp3 websocket implementation, you can see ThreadPoolExecutor if created with a pool size limited to 1 https://github.com/square/okhttp/blob/master/okhttp-ws%2Fsrc%2Fmain%2Fjava%2Fokhttp3%2Fws%2FWebSocketCall.java#L162 I think is the source of this issue

dusanvita commented 8 years ago

Hi, I'm experiencing the same exception, but in onClose(), not onMessage() of RealWebSocket's reader implementation because ThreadPoolExecutor (replyExecutor) is not at all used in onMessage() but in on onPing() and onClose(). My only assumption is that ping response runner is already in the pool at the point of onClose request from the server so it throws an exception since it can only have one runner at the time.

This issue definitely is occurring while using engine.io/socket.io but I rather think it is in the OkHttp library itself and not here...

shobhitpuri commented 7 years ago

Just saw this thread after creating the issue https://github.com/socketio/engine.io-client-java/issues/81 . I think what @mypplication said contributes to Out of Memory exceptions as well as mentioned there. For reproducing it, try connecting calling doOpen() and closing connection multiple times.

darrachequesne commented 3 years ago

Closed due to inactivity, please reopen if needed.