Skip to content

Commit 1b2768e

Browse files
committed
Seems like we're better off reconnecting ourselves, otherwise it leads to a 'Hermes WebSocket closed with code 4122, from host true, reason invalid challenge'
1 parent 66b3956 commit 1b2768e

3 files changed

Lines changed: 4 additions & 20 deletions

File tree

miner/src/main/java/fr/rakambda/channelpointsminer/miner/api/hermes/TwitchHermesWebSocketClient.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import java.util.UUID;
4040
import java.util.concurrent.ConcurrentLinkedQueue;
4141
import static org.java_websocket.framing.CloseFrame.GOING_AWAY;
42-
import static org.java_websocket.framing.CloseFrame.NORMAL;
4342

4443
@Log4j2
4544
public class TwitchHermesWebSocketClient extends WebSocketClient{
@@ -96,14 +95,9 @@ public void onMessage(String messageStr){
9695
subscribeRequests.remove(unsubscribeResponse.getUnsubscribeResponse().getSubscription().getId());
9796
}
9897
case NotificationResponse notificationResponse -> log.debug("Received Hermes notification of type {}", notificationResponse.getNotification().getClass().getSimpleName());
99-
case ReconnectResponse reconnectResponse -> {
100-
if(Objects.nonNull(reconnectResponse.getReconnect()) && Objects.nonNull(reconnectResponse.getReconnect().getUrl())){
101-
close(NORMAL);
102-
}
103-
else{
104-
log.warn("Received Hermes reconnect response without a reconnect URL");
105-
close(GOING_AWAY);
106-
}
98+
case ReconnectResponse ignored -> {
99+
log.warn("Received Hermes reconnect response");
100+
close(GOING_AWAY);
107101
}
108102
default -> {
109103
}

miner/src/main/java/fr/rakambda/channelpointsminer/miner/api/hermes/TwitchHermesWebSocketPool.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,6 @@ public void onWebSocketMessage(@NotNull ITwitchHermesWebSocketResponse response)
8686
if(response instanceof UnsubscribeResponse u){
8787
topics.remove(u.getUnsubscribeResponse().getSubscription().getId());
8888
}
89-
if(response instanceof ReconnectResponse r){
90-
if(Objects.nonNull(r.getReconnect()) && Objects.nonNull(r.getReconnect().getUrl())){
91-
try{
92-
createReconnectClient(r.getReconnect().getUrl()); // TODO do the subscription ids change ?
93-
}
94-
catch(Exception e){
95-
eventManager.onEvent(new ErrorEvent("Hermes API", "Failed to reconnect client with reconnect URL", e));
96-
}
97-
}
98-
}
9989
if(response instanceof NotificationResponse n){
10090
if(n.getNotification() instanceof PubSubNotificationType t){
10191
if(Objects.isNull(t.getPubsub())){

miner/src/test/java/fr/rakambda/channelpointsminer/miner/api/hermes/TwitchHermesWebSocketReconnectTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void onResponseWithReconnectUrl(WebsocketMockServer server) throws InterruptedEx
6868
.build())
6969
.build();
7070
verify(listener, timeout(MESSAGE_TIMEOUT)).onWebSocketMessage(expected);
71-
verify(listener).onWebSocketClosed(eq(tested), eq(NORMAL), anyString(), anyBoolean());
71+
verify(listener).onWebSocketClosed(eq(tested), eq(GOING_AWAY), anyString(), anyBoolean());
7272
}
7373

7474
@BeforeEach

0 commit comments

Comments
 (0)