You need to know WHY you are being disconnected. This message is generic to many reasons so doesnt explain much.
If you are getting disconnected from DoS, then you should work via a proxy to hide your IP.
If you are getting flooded, then implement some flood protection so you wont lag and disconnect.
If the server is laggy, then it will disconnect you, with this message, as it thinks you pinged out cause you missed sending the 'Pong' in time.
If its your ISP disconnecting you due to inactivity, then a simple timer should keep it active: /timer 0 60 ping irc.server.com (or indeed a pong, or anything that will send a command to the server), the time of 1 min means you wont exceed your sendQ limit and get killed for flooding as you are limited to the amount of characters you can send per line, so no matter what you use in the timer, you wont get killed, unless of course you set it to send 1000 tsunami type flood messages, which is a bit stupid lol
There may be other reasons as to why your getting disconnected, but this are the main reasons.