I’ve integrated PubSub using the recommended flow (GitHub - twitchdev/pubsub-javascript-sample). Using that flow, I’m able to get notifications for subscribers & bits. However, there seem to be intermittent “misses” where subs/bits notifications are not received.
Couple things I’ve checked:
- The connection did not get disconnected. I have a log of all PING/PONG and all reconnect/disconnects. The PING/PONG is consistently occurring every minute and no disconnects/reconnects are observed.
- The token is valid for the entire time. I’ve logged every packet received on “listen” (immediately after converting to JSON). No packets were observed while the sub/bit notification was missed; indicating there wasn’t any “BADAUTH” issues observed. The following code shows how I log the listen packets:
ws = new WebSocket('wss://pubsub-edge.twitch.tv');
ws.onmessage = function(event) {
var top_level_message = JSON.parse(event.data);
console.log('RECV: ' + JSON.stringify(top_level_message) + '\n');
...
}
Any recommendations for how to debug further? Is this a known issue that PubSub can miss notifications? I understand folks are advised to use EventHooks but I believe that isn’t an option for me as I prefer the information/page to remain entirely client-side.
At this point, I’m considering going with a very non-ideal approach of querying the list of subscribers / bits leaderboard every ~10 seconds. This would mean lots of unnecessary bandwidth/processing to keep a track of all previous subs/bits and check for new ones. Open to any other ideas if anyone has them!