RakambdaOrg/ChannelPointsMiner

Error with WS chat

Rakambda opened this issue · 2 comments

Description

When connection to WS is lost, seems like it fails to reconnect

Version / commit

9ee19cd

Relevant log output

2022-07-31T05:03:02,478 INFO {websocket_id=79a183d8-87ce-4b07-87a7-6e7c835e996a} - IRC WebSocket closed with code 1006, from host true, reason
2022-07-31T05:03:02,504 ERROR {websocket_id=79a183d8-87ce-4b07-87a7-6e7c835e996a} - Failed to create new websocket
2022-07-31T05:03:02,505 ERROR {} - Error from IRC WebSocket
java.lang.RuntimeException: java.lang.InterruptedException
        at fr.raksrinana.channelpointsminer.miner.api.chat.ws.TwitchChatWebSocketPool.createNewClient(TwitchChatWebSocketPool.java:89) ~[classes/:?]
        at java.util.Optional.orElseGet(Optional.java:364) ~[?:?]
        at fr.raksrinana.channelpointsminer.miner.api.chat.ws.TwitchChatWebSocketPool.getAvailableClient(TwitchChatWebSocketPool.java:74) ~[classes/:?]
        at fr.raksrinana.channelpointsminer.miner.api.chat.ws.TwitchChatWebSocketPool.join(TwitchChatWebSocketPool.java:53) ~[classes/:?]
        at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
        at fr.raksrinana.channelpointsminer.miner.api.chat.ws.TwitchChatWebSocketPool.onWebSocketClosed(TwitchChatWebSocketPool.java:41) ~[classes/:?]
        at fr.raksrinana.channelpointsminer.miner.api.chat.ws.TwitchChatWebSocketClient.lambda$onClose$0(TwitchChatWebSocketClient.java:70) ~[classes/:?]
        at java.util.concurrent.ConcurrentLinkedQueue.forEachFrom(ConcurrentLinkedQueue.java:1037) ~[?:?]
        at java.util.concurrent.ConcurrentLinkedQueue.forEach(ConcurrentLinkedQueue.java:1054) ~[?:?]
        at fr.raksrinana.channelpointsminer.miner.api.chat.ws.TwitchChatWebSocketClient.onClose(TwitchChatWebSocketClient.java:70) ~[classes/:?]
        at org.java_websocket.client.WebSocketClient.onWebsocketClose(WebSocketClient.java:663) ~[Java-WebSocket-1.5.3.jar:?]
        at org.java_websocket.WebSocketImpl.closeConnection(WebSocketImpl.java:561) ~[Java-WebSocket-1.5.3.jar:?]
        at org.java_websocket.WebSocketImpl.closeConnection(WebSocketImpl.java:574) ~[Java-WebSocket-1.5.3.jar:?]
        at org.java_websocket.WebSocketImpl.eot(WebSocketImpl.java:626) ~[Java-WebSocket-1.5.3.jar:?]
        at org.java_websocket.client.WebSocketClient.handleIOException(WebSocketClient.java:984) ~[Java-WebSocket-1.5.3.jar:?]
        at org.java_websocket.client.WebSocketClient.access$000(WebSocketClient.java:75) ~[Java-WebSocket-1.5.3.jar:?]
        at org.java_websocket.client.WebSocketClient$WebsocketWriteThread.run(WebSocketClient.java:801) ~[Java-WebSocket-1.5.3.jar:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.InterruptedException
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1048) ~[?:?]
        at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:230) ~[?:?]
        at org.java_websocket.client.WebSocketClient.connectBlocking(WebSocketClient.java:387) ~[Java-WebSocket-1.5.3.jar:?]
        at fr.raksrinana.channelpointsminer.miner.api.chat.ws.TwitchChatWebSocketPool.createNewClient(TwitchChatWebSocketPool.java:83) ~[classes/:?]
        ... 17 more

Sometimes server seems to drop the connection, while we reconnect server is not available and channels are not joined again as the re-created client didn't join any.

This issue probably also happens for pub-sub ws.

Didn't monitor fully if the above fixes works (if channels are joined again correctly). But at least the error didn't appear again.