[Asterisk-java-users] Manager: no socket read timeout ?
Brought to you by:
srt
From: Gaetan M. <gm...@ea...> - 2007-01-13 00:46:07
|
Hi, First of all, thank you for this amazing library. I use the manager connection part with ast live. When I "stressed" the auto reconnection feature with an "unstable asterisk server" I remarked that only the socket connection timeout can be set, but not the socket read timeout. So if I stop/restart asterisk for example, it works as expected. The TCP socket is closed immediately and reopened. But if I unplug the power of the asterisk server, or perturb the network between my client and the asterisk server in a way that prevents the tcp layer from cleanly disposing the connection (reboot a statefull firewall, reconnect my vpn so my development machine gets another IP ...), then the client socket hangs "forever" (well with tcp keepalive it should be 2 hours right ?). I modified SocketConnectionFacadeImpl.java and added socket.setSoTimeout(timeout); to the constructor. That way the connection is dropped and restarted if it stales on read longer than the timeout. Of course I started a PingThread on the connection too, with an interval of half the socket timeout. Won't this have other (bad) side effects on the library ? Is there a nicer way to do this ? Gaetan |