RFC 0016 - EventSub WebSockets

May be out of scope for this but any plans for supporting reconnecting to a session again and buffering events for a bit in case of connection deaths?

Lots of websocket based event APIs I’ve seen and worked with (like from payment processors or also Discord) will have some form of buffering of events for a connection if it randomly dies and allow some small amount of time (like 5 mins) to reconnect a session and will then replay all missed events.

Like for example returning a reconnect token in the initial welcome message and then if the connection dies letting you reconnect to something like wss://eventsub.wss.twitch.tv/reconnect?token={token}&last_message={last_message_id_you_still_got} and replaying all events that happened in the meantime before then going on normally with new ones.

Without that functionality keeping a consistent state of data and not missing anything will usually require extra API requests and make logic way more difficult for devs.

As an example say you wanna listen to all new follows or subs to a channel for a notification tool and the users internet connection dies for 30 secs then after creating a new EventSub websocket and new follow topic subscription for it you basically have to make a Helix Channel Follows API request and check those recent follows from the API against your last received one from the dead websocket to make sure you didn’t miss any and handle any you did miss.

Then multiply that effort for every possible topic you wanna listen to, many which don’t even really have appropriate APIs to easily get recent data making that even more of a pain.

This is of course already kind of a thing with existing server based EventSub but there you already have retry support on Twitch’s side making short term server problems not an issue and also in general with servers just being more stable making that way less problematic. But with this being way more frontend focused and often used on user machines and user internet connections random disconnects and connection deaths should be way more common.

I understand that this could be massive extra effort implementation wise but just pointing out that support for reconnecting sessions in some way makes usage so much easier for devs.

Also way better experience for end users too because if you look at tons of streamer targeted software out there using Twitch websocket PubSub currently most devs simply don’t even bother doing the API thing to stay consistent after disconnects and will just miss anything that happened during them meaning tons of those tools are just kinda slightly broken.

4 Likes