Apache ActiveMQ Artemis 2.30.0协议握手错误致Broker变慢及控制台无法访问
Apache ActiveMQ Artemis 2.30.0 协议握手错误与Broker性能问题处理
问题现象
使用Apache ActiveMQ Artemis 2.30.0时,突发协议握手错误,导致Broker运行缓慢;数分钟后,即便输入正确的用户名和密码,也无法登录Web控制台。
日志信息
2023-10-05 11:11:44,640 INFO [io.hawt.web.auth.LoginServlet] Logging in user: admin 2023-10-05 11:14:35,463 WARN [org.apache.activemq.artemis.core.client] AMQ212037: Connection failure to null has been detected: An existing connection was forcibly closed by the remote host [code=GENERIC_EXCEPTION] 2023-10-05 11:14:35,463 WARN [org.apache.activemq.artemis.core.client] AMQ212037: Connection failure to null has been detected: An existing connection was forcibly closed by the remote host [code=GENERIC_EXCEPTION] 2023-10-05 11:14:35,463 WARN [org.apache.activemq.artemis.core.client] AMQ212037: Connection failure to null has been detected: An existing connection was forcibly closed by the remote host [code=GENERIC_EXCEPTION] 2023-10-05 11:14:39,055 WARN [org.apache.activemq.artemis.core.client] AMQ212037: Connection failure to null has been detected: An existing connection was forcibly closed by the remote host [code=GENERIC_EXCEPTION] 2023-10-05 11:14:43,476 WARN [org.apache.activemq.artemis.core.client] AMQ212037: Connection failure to null has been detected: An existing connection was forcibly closed by the remote host [code=GENERIC_EXCEPTION] 2023-10-05 11:14:43,476 WARN [org.apache.activemq.artemis.core.client] AMQ212037: Connection failure to null has been detected: An existing Connection was forcibly closed by the remote host [code=GENERIC_EXCEPTION] 2023-10-05 11:14:43,492 WARN [org.apache.activemq.artemis.core.client] AMQ212037: Connection failure to null has been detected: An existing connection was forcibly closed by the remote host [code=GENERIC_EXCEPTION] 2023-10-05 11:14:43,508 ERROR[org.apache.activemq.artemis.core.server] AMQ224126: Failure during protocol handshake on connection to /172.16.7.55:1883 from /172.16.8.100:62990 java.io.IOException: An existing connection was forcibly closed by the remote host
Broker配置(connectors与acceptors片段)
<connectors> <connector name="amq1">tcp://ppr-t24-qve-01:61616</connector> <connector name="amq2">tcp://ppr-t24-qve-02:61616</connector> </connectors> <acceptors> <acceptor name="artemis">tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true</acceptor> <acceptor name="amqp">tcp://0.0.0.0:5672?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=AMQP,CORE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpMinLargeMessageSize=102400;amqpDuplicateDetection=true</acceptor> <acceptor name="stomp">tcp://0.0.0.0:61613?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP,CORE;useEpoll=true</acceptor> <acceptor name="hornetq">tcp://0.0.0.0:5445?anycastPrefix=jms.queue.;multicastPrefix=jms.topic.;protocols=HORNETQ,STOMP;useEpoll=true</acceptor> <acceptor name="mqtt">tcp://0.0.0.0:1883?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=MQTT,CORE;useEpoll=true</acceptor> </acceptors>
问题分析
核心触发点是来自/172.16.8.100的MQTT客户端连接握手失败,大量重复的连接失败警告会持续占用Broker的线程和资源,导致Broker性能急剧下降,最终耗尽Web控制台(Hawtio)的服务资源,引发登录失败。
解决步骤
- 排查异常客户端:检查IP为
/172.16.8.100的MQTT客户端,确认其MQTT版本(Artemis 2.30.0兼容3.1、3.1.1、5.0)、连接参数(客户端ID、认证信息)是否正确,或进程是否异常。 - 优化MQTT acceptor配置:添加连接超时参数,避免Broker长时间等待无效握手请求,修改后的MQTT acceptor配置如下:
<acceptor name="mqtt">tcp://0.0.0.0:1883?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=MQTT,CORE;useEpoll=true;connectionTimeout=30000</acceptor>
- 临时阻断异常连接:若无法快速修复客户端,可通过防火墙规则临时阻断
/172.16.8.100的连接请求,减少Broker资源消耗,优先恢复Web控制台访问。 - 检查系统资源:查看Broker所在服务器的CPU、内存、文件描述符使用情况,若资源耗尽,调整JVM堆内存参数(
etc/artemis.profile)或系统文件描述符限制。 - 恢复Web控制台:若Hawtio线程池耗尽,可重启Broker临时恢复服务,后续调整
etc/jolokia-access.xml中的线程池配置优化性能。
内容的提问来源于stack exchange,提问作者Ahamed
相关产品推荐
相关产品推荐

