You should ping/pong rather that disconnect/reconnect
As during the disconnect/reconnect you could miss a message/event.
To keep the server from closing the connection, clients must send a
PINGcommand at least once every 5 minutes. If a client does not receive aPONGmessage within 10 seconds of issuing aPINGcommand, it should reconnect to the server. See details in Handling Connection Failures.
You need multiple timers.
One to handle sending ping and one to handle recieving a pong and doing stuff if a Pong isn’t receieved in time.
Thats why I have some things split out. So it’s less tangled and the seperate timer controller is held away from the main pubsub loop.