使用MQTT3.1.1外网连接报错,5.0就不会

我使用MQTTX设置MQTT3.1.1版本,使用映射到公网上的IP进行连接,会提示 Error: read ECONNRESET,如果使用MQTT5.0连接则可以直接连接上。

2023-11-29T09:19:47.375277+08:00 [debug] msg: emqx_connection_terminated, mfa: emqx_connection:terminate/2(668), peername: 10.10.100.253:58070, reason: {shutdown,tcp_closed}, tag: SOCKET
2023-11-29T09:19:47.375836+08:00 [info] msg: terminate, mfa: emqx_connection:terminate/2(673), peername: 10.10.100.253:58070, reason: {shutdown,tcp_closed}
2023-11-29T09:19:48.678284+08:00 [debug] msg: emqx_connection_terminated, mfa: emqx_connection:terminate/2(668), peername: 10.10.100.253:39668, reason: {shutdown,tcp_closed}, tag: SOCKET
2023-11-29T09:19:48.678710+08:00 [info] msg: terminate, mfa: emqx_connection:terminate/2(673), peername: 10.10.100.253:39668, reason: {shutdown,tcp_closed}
2023-11-29T09:19:49.245623+08:00 [debug] msg: emqx_connection_terminated, mfa: emqx_connection:terminate/2(668), peername: 10.10.100.253:39669, reason: {shutdown,tcp_closed}, tag: SOCKET
2023-11-29T09:19:49.245996+08:00 [info] msg: terminate, mfa: emqx_connection:terminate/2(673), peername: 10.10.100.253:39669, reason: {shutdown,tcp_closed}
2023-11-29T09:19:50.969828+08:00 [debug] msg: emqx_connection_terminated, mfa: emqx_connection:terminate/2(668), peername: 10.10.100.253:58071, reason: {shutdown,tcp_closed}, tag: SOCKET
2023-11-29T09:19:50.970220+08:00 [info] msg: terminate, mfa: emqx_connection:terminate/2(673), peername: 10.10.100.253:58071, reason: {shutdown,tcp_closed}
2023-11-29T09:19:54.575358+08:00 [debug] msg: emqx_connection_terminated, mfa: emqx_connection:terminate/2(668), peername: 10.10.100.253:58072, reason: {shutdown,tcp_closed}, tag: SOCKET
2023-11-29T09:19:54.575844+08:00 [info] msg: terminate, mfa: emqx_connection:terminate/2(673), peername: 10.10.100.253:58072, reason: {shutdown,tcp_closed}
2023-11-29T09:19:58.176899+08:00 [debug] msg: emqx_connection_terminated, mfa: emqx_connection:terminate/2(668), peername: 10.10.100.253:58073, reason: {shutdown,tcp_closed}, tag: SOCKET
2023-11-29T09:19:58.177322+08:00 [info] msg: terminate, mfa: emqx_connection:terminate/2(673), peername: 10.10.100.253:58073, reason: {shutdown,tcp_closed}
2023-11-29T09:20:01.783164+08:00 [debug] msg: emqx_connection_terminated, mfa: emqx_connection:terminate/2(668), peername: 10.10.100.253:58074, reason: {shutdown,tcp_closed}, tag: SOCKET
2023-11-29T09:20:01.783685+08:00 [info] msg: terminate, mfa: emqx_connection:terminate/2(673), peername: 10.10.100.253:58074, reason: {shutdown,tcp_closed}
2023-11-29T09:20:02.143271+08:00 [debug] msg: raw_bin_received, mfa: emqx_connection:when_bytes_in/3(778), peername: 10.10.100.253:17932, clientid: mqttx_6036cbca, bin: C000, size: 2, type: hex
2023-11-29T09:20:02.143823+08:00 [debug] msg: mqtt_packet_received, mfa: emqx_connection:handle_msg/2(575), peername: 10.10.100.253:17932, clientid: mqttx_6036cbca, packet: PINGREQ(Q0, R0, D0), tag: MQTT
2023-11-29T09:20:02.144215+08:00 [debug] msg: mqtt_packet_sent, mfa: emqx_connection:serialize_and_inc_stats_fun/1(877), peername: 10.10.100.253:17932, clientid: mqttx_6036cbca, packet: PINGRESP(Q0, R0, D0), tag: MQTT
2023-11-29T09:20:05.375615+08:00 [debug] msg: emqx_connection_terminated, mfa: emqx_connection:terminate/2(668), peername: 10.10.100.253:58075, reason: {shutdown,tcp_closed}, tag: SOCKET
2023-11-29T09:20:05.376115+08:00 [info] msg: terminate, mfa: emqx_connection:terminate/2(673), peername: 10.10.100.253:58075, reason: {shutdown,tcp_closed}
2023-11-29T09:20:08.976245+08:00 [debug] msg: emqx_connection_terminated, mfa: emqx_connection:terminate/2(668), peername: 10.10.100.253:58076, reason: {shutdown,tcp_closed}, tag: SOCKET
2023-11-29T09:20:08.976695+08:00 [info] msg: terminate, mfa: emqx_connection:terminate/2(673), peername: 10.10.100.253:58076, reason: {shutdown,tcp_closed}
2023-11-29T09:20:12.575597+08:00 [debug] msg: emqx_connection_terminated, mfa: emqx_connection:terminate/2(668), peername: 10.10.100.253:58077, reason: {shutdown,tcp_closed}, tag: SOCKET
2023-11-29T09:20:12.575943+08:00 [info] msg: terminate, mfa: emqx_connection:terminate/2(673), peername: 10.10.100.253:58077, reason: {shutdown,tcp_closed}
2023-11-29T09:20:16.174943+08:00 [debug] msg: emqx_connection_terminated, mfa: emqx_connection:terminate/2(668), peername: 10.10.100.253:58078, reason: {shutdown,tcp_closed}, tag: SOCKET
2023-11-29T09:20:16.175373+08:00 [info] msg: terminate, mfa: emqx_connection:terminate/2(673), peername: 10.10.100.253:58078, reason: {shutdown,tcp_closed}

tcp_closed 应该是远端主动关闭了本次 tcp 连接。你中间映射还加了啥负载均衡么?

我也遇到了这个问题,请问怎么解决?我的客户端是使用程序写了一个客户端。集群负载均衡之后,每10分钟断线重连一次https://askemq.com/t/topic/7324