2

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&amp;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 to ssl://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.

divinedragon
  • 5,105
  • 13
  • 50
  • 97

2 Answers2

0

0.0.0.0 means that activemq will listen on all available interfaces, including 127.0.0.1. For further details see What is the difference between 0.0.0.0, 127.0.0.1 and localhost?

Community
  • 1
  • 1
gtonic
  • 2,295
  • 1
  • 24
  • 32
  • I get that point and it was they way I intended it to. My question pertains to as to why the activemq itself is connecting to the `10031` port. – divinedragon Sep 24 '16 at 05:16
0

ActiveMQ was trying to connect to its own broker because of the configuration block - networkConnector.

To provide massive scalability of a large messaging fabric you typically want to allow many brokers to be connected together into a network so that you can have as many clients as you wish all logically connected together - and running as many message brokers as you need based on your number of clients and network topology.

http://activemq.apache.org/networks-of-brokers.html

As, I have configured the JMS_X_SITE_CSV_URL to localhost, activemq is trying to connect to its own broker.

A little more details on this at - WARNING as java.io.EOFException when ActiveMQ starts

Community
  • 1
  • 1
divinedragon
  • 5,105
  • 13
  • 50
  • 97