In my spring boot app that I'm running in Intellij I have one @Scheduled task, and two WebSocket streams open to two different servers using OkHttp connections from two different instances of OkHttpClients. I don't think the Connection pool setting in the OkHttpClient.Builder is of relevance here since there are two instances of OkHttpClient. Both the websocket streams receive some events initially and then one of them never receives any event anymore. I have also verified by printing the hashcode of the worker threads that they are different. [![image][1]][1]
Sadly I notice the same problem on the command line mvn run also, so it doesn't seem to be an Intellij specific issue.
How can I make the events received on both socket streams continously? Will it help if I reused the same OkHttpClient to create both the connections?
Update: Not wanting to waste time waiting to solve this I went to the extreme step of separating into 2 separate applications each with a websocket listener. Yet I face the same issue, one of them stops receiving any callback after a few seconds of starting. Can't blame it on the remote server, because if I ran any one of them individually, it never stops receiving the callback stream. I need them to be up and running simultaneously and communicate with one another.
fwiw, I'm using [this][2] client library to subscribe to one WebSocket stream, and [this][3] for another. The first endpoint is wss://stream.binance.com:9443/ws/btcusdt@aggTrade and the second is wss://fstream.binance.com. The latter subscription is established by posting a JSON {"method":"SUBSCRIBE","id":1663348051361,"params":"btcusdt@aggTrade"} to it.
I have chatted with the customer support of the server endpoints, they are unable to help me, they just said that if I'm able to subscribe to the socket stream individually just fine, they don't see any reason why one of them should stop working when I bring them up both at the same time. [1]: https://i.stack.imgur.com/T5oia.png [2]: https://github.com/binance-exchange/binance-java-api/blob/master/src/main/java/com/binance/api/client/impl/BinanceApiWebSocketClientImpl.java#L47 [3]: https://github.com/Binance-docs/Binance_Futures_Java/blob/master/src/main/java/com/binance/client/impl/WebSocketStreamClientImpl.java#L63