使用MQTTX报错Error: read ECONNRESET

我把EMQX的开源版本部署到服务器上,但是MQTTX跨 VLAN 连接失败,TCP 通但数据包被拒(ECONNRESET) 同一 VLAN 的设备连接、认证均正常。不同 VLAN(10.244.252.0/24 )的设备 TCP 握手成功(Test-NetConnectionpingtracert 全通),但 MQTT CONNECT 包发送后立即收到 ECONNRESET 。EMQX 日志中没有任何来自跨 VLAN 设备的认证记录,看起来 MQTT 数据包从未到达应用层。

09:12:24.732[E][Dummy]Client_Keep_Error_Long:Error while authenticating. Extended authentication handler is not yet supportedExtended authentication handler is not yet supported
09:32:32.416[I][Dummy]Try connect to:151.146.86.149:1883
09:53:54.404[I][Dummy]Try connect to:151.146.86.149:1883
10:15:17.239[I][Dummy]Try connect to:151.146.86.149:1883
10:35:59.976[E][Dummy]Client_Keep_Error_Long:Error while authenticating. Extended authentication handler is not yet supportedExtended authentication handler is not yet supported
10:36:35.060[I][Dummy]Try connect to:151.146.86.149:1883 然后我使用客户端的时候,我的设备客户端无法访问服务器的EMQX1883端口,但是Tel-NetConnection都是可以ping通的

看起来是 CONNECT 包有没有到 EMQX 机器。

Test-NetConnection 只能证明 TCP 三次握手通了,不能证明跨 VLAN 的 MQTT 数据没有被中间设备重置。

在 EMQX 服务器上抓包,换成跨 VLAN 客户端 IP:

sudo tcpdump -i any -nn -s 0 -vv 'host <client_ip> and port 1883'
  1. 如果抓不到 MQTT CONNECT,问题在 EMQX 之前:VLAN 间 ACL、防火墙、NGFW/IPS、NAT 或安全组策略。重点看哪个设备发了 RST。这个要自个查一查。

  2. 如果能抓到 CONNECT,并且 RST 从 EMQX 服务器发出,再查 EMQX 侧日志和监听器配置:

emqx ctl listeners
sudo grep -E 'mqttx_16ef8335|151\.146\.86\.149|ECONNRESET|authentication|connack' /var/log/emqx/emqx.log