【发布时间】:2017-02-01 00:56:19
【问题描述】:
我遇到了这种情况,我试图使用 SSL 运行 activemq,但我看到了 SSL 异常。
这是我的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>
变量的值如下。
JMS_PORT=10029
JMS_STOMP_PORT=10030
JMS_SSL_PORT=10031
JMS_X_SITE_CSV_URL=tcp://localhost:10031/
现在,通过上述配置,我看到javax.net.ssl.SSLException 的错误如下:
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
错误消息起初看起来很神秘,但后来才有意义。当我实际尝试连接到 SSL 端口-10031 时,我使用tcp:// 配置了网络连接器。此问题导致套接字保留在 CLOSE_WAIT 中,从而为 ActiveMQ 本身使用了大量内存。
这是问题中悬空套接字的样子。
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
所以,我将
JMS_X_SITE_CSV_URL修复为ssl://localhost:10031/,问题就解决了。
现在,这是我的问题(抱歉,这里的解释太长了)。
为什么 activemq 自己打开套接字?
我在解决这个问题时在想,生产者/消费者在尝试从队列中读取/写入数据时打开了套接字,但是当我只运行 activemq 进程时已经很晚了(没有其他 java进程)以隔离它正在打开与自身的连接。
【问题讨论】:
标签: java networking activemq message-queue