telnet to mysql, which timeout is used?
I suggest not using telnet to connect to database servers.

Recommend using ServerAliveInterval (man 8 ssh_config) to keep your connection alive rather than a mysql mechanism.