How to keep connection with Asterisk AMI active?

Hi, as I know when we create a TCP connection with AMI through 5038, it will be closed by Asterisk after a few hours. Is that true?
Do we need to keep sending Ping action to Asterisk to keep this connection active? What is the interval?
And sending Ping is enough? I have tried to send ping every 60 seconds, but Asterisk still close the connection with me.
I am using Java socket.
Could any one give me some help? Thank you very much!

I’m not aware of any such timeout. Certainly I’ve just run a test in which AMI was essentially idle for over 14 hours.

I would look for a firwall timing out its knowledge of a connection.

i leave my asterisk-java servers connected to my machines indefinitely. they often go many hours without any messages (middle of the night). no disconnects here.