I got this scenario wherein I was trying to run the activemq with SSL and I was seeing SSL exception.
Here is the except from my activemq.xml
.
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:${JMS_PORT}" />
<transportConnector name="stomp" uri="stomp://0.0.0.0:${JMS_STOMP_PORT}"/>
<transportConnector name="ssl" uri="ssl://0.0.0.0:${JMS_SSL_PORT}"/>
</transportConnectors>
<sslContext>
<sslContext
keyStore="file:${JMS_KEY_STORE}"
keyStorePassword="${JMS_KEY_STORE_PASSWORD}"
trustStore="file:${JMS_TRUST_STORE}"
trustStorePassword="${JMS_TRUST_STORE_PASSWORD}"
/>
</sslContext>
<networkConnectors>
<networkConnector
name="host1 and host2"
uri="static://(${JMS_X_SITE_CSV_URL})?wireFormat=ssl&wireFormat.maxInactivityDuration=30000"
dynamicOnly="true"
suppressDuplicateQueueSubscriptions = "true"
networkTTL="1"
/>
</networkConnectors>
And the values for the variables is as below.
JMS_PORT=10029
JMS_STOMP_PORT=10030
JMS_SSL_PORT=10031
JMS_X_SITE_CSV_URL=tcp://localhost:10031/
Now, with the above configuration I was seeing errors for javax.net.ssl.SSLException
as below:
2016-09-20 14:47:48,619 | ERROR | Could not accept connection from tcp://localhost:54869: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? | org.apache.activemq.broker.TransportConnector | ActiveMQ BrokerService[divinedragonbox] Task-3
2016-09-20 14:47:49,628 | ERROR | Could not accept connection from tcp://localhost:54871: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? | org.apache.activemq.broker.TransportConnector | ActiveMQ BrokerService[divinedragonbox] Task-9
2016-09-20 14:47:51,639 | ERROR | Could not accept connection from tcp://localhost:54893: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? | org.apache.activemq.broker.TransportConnector | ActiveMQ BrokerService[divinedragonbox] Task-12
2016-09-20 14:47:55,645 | ERROR | Could not accept connection from tcp://localhost:54902: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? | org.apache.activemq.broker.TransportConnector | ActiveMQ BrokerService[divinedragonbox] Task-20
2016-09-20 14:48:03,653 | ERROR | Could not accept connection from tcp://localhost:54906: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? | org.apache.activemq.broker.TransportConnector | ActiveMQ BrokerService[divinedragonbox] Task-31
2016-09-20 14:48:19,661 | ERROR | Could not accept connection from tcp://localhost:54915: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? | org.apache.activemq.broker.TransportConnector | ActiveMQ BrokerService[divinedragonbox] Task-50
The error message looked cryptic at first, but made sense later on. I configured the network connector with tcp://
when I was actually trying to connect to the SSL port-10031
. This issue was causing the sockets to remain in CLOSE_WAIT
and thereby using a huge memory for ActiveMQ itself.
Here is how the dangling sockets looked like with the issue.
tcp6 0 0 127.0.0.1:54869 127.0.0.1:10031 CLOSE_WAIT 4807/java
tcp6 0 0 127.0.0.1:54871 127.0.0.1:10031 CLOSE_WAIT 4807/java
tcp6 1 0 127.0.0.1:54893 127.0.0.1:10031 CLOSE_WAIT 4807/java
tcp6 0 0 127.0.0.1:54902 127.0.0.1:10031 CLOSE_WAIT 4807/java
tcp6 1 0 127.0.0.1:54915 127.0.0.1:10031 CLOSE_WAIT 4807/java
tcp6 1 0 127.0.0.1:54922 127.0.0.1:10031 CLOSE_WAIT 4807/java
So, I fixed the
JMS_X_SITE_CSV_URL
tossl://localhost:10031/
and the issue was resolved.
Now, here is my question on this(Sorry about the long explanation to come here).
Why was activemq opening sockets with itself?
I was thinking while working out on this issue, that the sockets are opened by the producers/consumers while trying to read/write data off the queues, but it was very late when I was only running activemq process(no other java process) to isolate that it was opening connections with itself.