gpt4 book ai didi

java - 为什么activemq会自行打开套接字

转载 作者:太空宇宙 更新时间:2023-11-04 12:13:29 24 4
gpt4 key购买 nike

我遇到了这样的场景,其中我尝试使用 SSL 运行 activemq,并且看到 SSL 异常。

这是我的 activemq.xml 中的异常(exception)。

<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>

变量的值如下。

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

So, I fixed the JMS_X_SITE_CSV_URL to ssl://localhost:10031/ and the issue was resolved.

现在,这是我对此的问题(抱歉,这里的解释很长)。

Why was activemq opening sockets with itself?

在解决这个问题时,我在想,套接字是由生产者/消费者在尝试从队列中读取/写入数据时打开的,但是当我只运行 activemq 进程(没有其他 java 进程)来隔离它正在打开与自身的连接时,已经很晚了。

最佳答案

0.0.0.0 表示 activemq 将监听所有可用接口(interface),包括 127.0.0.1。欲了解更多详情,请参阅What is the difference between 0.0.0.0, 127.0.0.1 and localhost?

关于java - 为什么activemq会自行打开套接字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39656112/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com