Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
5.6.0, 5.8.0
-
Linux: Ubuntu 12.04.1 LTS (precise)
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.5) (6b27-1.12.5-1)
OpenJDK Client VM (build 20.0-b12, mixed mode, sharing)
Description
keepAlive not working for stomp URLs. Here is the activemq.xml:
<transportConnector name="stomp+ssl" uri="stomp+ssl://0.0.0.0:61613?trace=true&soLinger30000&keepAlive=true&soTimeout=44000"/>
Running "netstat -tupnco" as root shows java processes without the keepalive timer counting down. This confirms that tcp keepalive is not working.
However, running activemq under the following strace command seems to indicate tcp keepalive is being enabled with the setsockopt() system call:
strace -o /dev/stdout -f -e setsockopt bin/activemq-admin start | grep -i setsockopt
3029 setsockopt(14, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
3029 setsockopt(128, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
3040 setsockopt(130, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
3040 setsockopt(131, SOL_TCP, TCP_NODELAY, [1], 4) = 0
3040 setsockopt(131, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
3044 setsockopt(132, SOL_TCP, TCP_NODELAY, [1], 4) = 0
3029 setsockopt(133, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
3044 setsockopt(133, SOL_TCP, TCP_NODELAY, [1], 4) = 0
3044 setsockopt(133, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
3047 setsockopt(134, SOL_TCP, TCP_NODELAY, [1], 4) = 0
3044 setsockopt(135, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
3029 setsockopt(135, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
3029 setsockopt(136, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
3029 setsockopt(131, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
3057 setsockopt(134, SOL_SOCKET, SO_RCVBUF, [65536], 4) = 0
3057 setsockopt(134, SOL_SOCKET, SO_SNDBUF, [65536], 4) = 0
3056 setsockopt(133, SOL_SOCKET, SO_RCVBUF, [65536], 4) = 0
3056 setsockopt(133, SOL_SOCKET, SO_SNDBUF, [65536], 4) = 0
3029 setsockopt(140, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
3029 setsockopt(140, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
3046 setsockopt(145, SOL_TCP, TCP_NODELAY, [1], 4) = 0
3046 setsockopt(145, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
3078 setsockopt(146, SOL_TCP, TCP_NODELAY, [1], 4) = 0
But, again, netstat output does not show keepalives being enabled. netstat shows some java processes with keepalive, but then they quickly disappear. The remaining long lived listening and connected sockets do not have keepalive.
netstat -tupnco
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name Timer
tcp 0 0 10.5.48.17:61613 10.5.48.241:57464 ESTABLISHED 3287/java off (0.00/0/0)
tcp 0 0 10.5.48.17:22 192.168.2.10:1203 ESTABLISHED 1548/sshd: b [priv] keepalive (3768.50/0/0)
tcp 0 0 10.5.48.17:61613 169.254.6.55:35975 ESTABLISHED 3287/java off (0.00/0/0)
In addition, even if keepAlive was being set, this is not really a good solution as implemented because one cannot set the keepalive options at the socket level, only at the OS system-wide level. There's no way to set TCP_KEEPCNT, TCP_KEEPIDLE, and TCP_KEEPINTVL. When I set the keepalive options at the OS level, all applications are affected. I clearly don't want to use the same keepalive settings system wide. These three settings should be allowed to set keepalives only for activemq.
Temporary workaround: use http://libkeepalive.sourceforge.net/