Q:

Huge established number of socket in activemq

I am having issue in which there is huge number of established sockets with activemq.
According to ActiveMQ document, the socket will be closed due to inactivity. But in my application, after sometime, I have a huge socket connections due to inactivity. Here is my settings: 
Client configuration is having soTimeout 30s, connectionTimeout 10s
Broker Configuration is having maxInactivityDuration as 30s
In the log file, I am having the below exception, but I am unable to understand why socket is not closed as per activemq documentation.

[WARN ] [20/Nov/17 23:58:06.473] [Transport] - Transport Connection
  to: tcp://10.227.129.219:34896 failed:
  org.apache.activemq.transport.InactivityIOException: Channel was
  inactive (no connection attempt made) for too (>30000) long:
  tcp://10.227.129.219:34896

Active mq documentation is mentioned here

Using the default values; if no data has been written or read from the
  connection for 30 seconds, the InactivityMonitor kicks in. The
  InactivityMonitor throws an InactivityIOException and shuts down the
  transport associated with the connection

For your information, I am using activemq 5.13.3. Below is the snapshot of netstat command.
netstat -an | grep 9999
tcp        0      0 X.X.X.X:9999           Y.Y.Y.Y:38200        ESTABLISHED 
tcp        0      0 X.X.X.X:9999           Y.Y.Y.Y:44582        ESTABLISHED 
tcp        0      0 X.X.X.X:9999           Y.Y.Y.Y:41278        ESTABLISHED
... (few hundreds in total) 

A:

Based on the log file that you shared, TCP handshake was done, then activemq protocol (application level) is waiting for connection to be established. Due to any issue (e.g. network connection, etc), the connection cannot be established. I am guessing that your tcp keeplive configuration is enabled. Hence, TCP connections are not closed, and application (e.g. activemq) didn't close it either.

