Connecting to Twitch API with NodeJS and socket io

twitch.ping isn’t the right way to ping/pong

From my example

        pubsub.send(JSON.stringify({
            type: 'PING'
        }));

Which for you equates to

twitch.send(JSON.stringify({type: "PING"}));

This is also wrong

        twitch.on('pong', () => {
            console.log('Got PONG.');
            clearTimeout(noPongRestart);
        })

See line 78

Twitch sends as a message (not as a “pong”)