Seems correct.
Personally if Twitch doesn’t PING withing a given time frame I’ll send my own.
But your original problem seesm to suggest something isn’t write with the ping/pong/disconnect logic
Or you can’t handle extended periods of “no messages sent to a channel” for you to read nicely