Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventSub Websocket failing to reconnect #286

Closed
Teekeks opened this issue Jan 18, 2024 · 3 comments · Fixed by #310
Closed

EventSub Websocket failing to reconnect #286

Teekeks opened this issue Jan 18, 2024 · 3 comments · Fixed by #310
Labels
bug Something isn't working EventSub
Milestone

Comments

@Teekeks
Copy link
Owner

Teekeks commented Jan 18, 2024

For some people, EventSub Websocket seems to fail to reconnect from time to time.

Log:

2024-01-18 21:22:35,147 - got session keep alive
2024-01-18 21:22:45,146 - got session keep alive
2024-01-18 21:22:54,675 - got request from websocket to reconnect
2024-01-18 21:22:54,675 - reconnecting using wss://cell-c.eventsub.wss.twitch.tv/ws?challenge=123dd623-5b4c-4af7-9372-5b6ed985c123&id=123oQokjpezENRQC9qSpqX-bPKBIGY2Vsb123...
2024-01-18 21:22:54,675 - websocket is closing
2024-01-18 21:22:54,828 - Websocket closing: 4007 - Invalid reconnect
@Teekeks Teekeks added bug Something isn't working EventSub labels Jan 18, 2024
@Teekeks Teekeks added this to the v4.3.0 milestone Feb 3, 2024
@phifuh
Copy link

phifuh commented Mar 26, 2024

@Teekeks Do you think this will fix #291

@Latent-Logic
Copy link
Contributor

Do you think this will fix #291

No, because that issue is talking about a network glitch on the client side, whereas this issue is coming from an problem with how the library is handling a session_reconnect message from Twitch.

@Latent-Logic
Copy link
Contributor

ws_test.txt
I've created a test file to reproduce this issue. With this file I saw the issue in the logs here:

2024-05-28 10:31:20,607 DEBUG   twitchAPI.eventsub.websocket    got session keep alive
2024-05-28 10:31:30,606 DEBUG   twitchAPI.eventsub.websocket    got session keep alive
2024-05-28 10:31:36,593 DEBUG   twitchAPI.eventsub.websocket    got request from websocket to reconnect
2024-05-28 10:31:36,594 DEBUG   twitchAPI.eventsub.websocket    reconnecting using wss://cell-a.eventsub.wss.twitch.tv/ws?challenge=f522781c-154f-4988-8098-a278919d332c&id=AgoQgTr-_hg5ST6DQGlKRLFU6BIGY2VsbC1h...
2024-05-28 10:31:36,632 DEBUG   twitchAPI.eventsub.websocket    websocket is closing
2024-05-28 10:31:36,740 INFO    twitchAPI.eventsub.websocket    Websocket closing: 4007 - Invalid reconnect

2024-05-28 10:58:44,100 DEBUG   twitchAPI.eventsub.websocket    stopping websocket EventSub...

Using the same repro file to test my fix that I'll open a PR for shortly

Latent-Logic added a commit to Latent-Logic/pyTwitchAPI that referenced this issue May 28, 2024
https://dev.twitch.tv/docs/eventsub/handling-websocket-events/#reconnect-message
When a session_reconnect message is received, the client should create
a new connection to the reconnect url while leaving the existing
connection open to receive messages until the new connection gets
the welcome message. This way no events should be missed during the
handoff.

In my testing this fixes Teekeks#286 where the connection gets broken
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working EventSub
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants