EMQX5.7.0,client订阅发布时出现断开重连

2024-06-20T02:46:55.443990+00:00 [MQTT] drone@172.17.0.1:56034 msg: mqtt_packet_received, packet: PUBLISH(Q0, R0, D0, Topic=/uav/kbit/subscribe, PacketId=undefined, Payload={ “header”: { “messageType”: “uavOnlineList” } }), username: drone
2024-06-20T02:46:55.444131+00:00 [PUBLISH] drone@172.17.0.1:56034 msg: publish_to, topic: /uav/kbit/subscribe, username: drone, payload: { “header”: { “messageType”: “uavOnlineList” } }
2024-06-20T02:46:55.474976+00:00 [MQTT] drone@172.17.0.1:56034 msg: mqtt_packet_sent, packet: PUBLISH(Q0, R0, D0, Topic=/uav/kbit/publish, PacketId=undefined, Payload={“header”:{“compress”:0,“messageId”:“7”,“messageType”:“uavOnlineListReply”,“timestamp”:1718851615460,“version”:“1.0”},“payload”:{“code”:“000000”,“data”:,“errorMessage”:“处理成功”}}), username: drone
2024-06-20T02:46:56.779283+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_received, packet: CONNECT(Q0, R0, D0, ClientId=drone, ProtoName=MQTT, ProtoVsn=4, CleanStart=false, KeepAlive=60, Username=drone, Password=), username: drone
2024-06-20T02:46:56.779445+00:00 [AUTHN] drone@172.17.0.1:56346 msg: authenticator_result, authenticator: password_based:built_in_database, result: {ok,#{is_superuser => true}}, username: drone
2024-06-20T02:46:56.779533+00:00 [AUTHN] drone@172.17.0.1:56346 msg: authentication_result, reason: chain_result, result: {stop,{ok,#{is_superuser => true}}}, username: drone
2024-06-20T02:46:56.779717+00:00 [SUBSCRIBE] drone@172.17.0.1:56346 msg: subscribe, sub_id: drone, sub_opts: [nl: 0, qos: 0, rap: 0, rh: 0, sub_props: []], topic: /uav/+/publish, username: drone
2024-06-20T02:46:56.779883+00:00 [UNSUBSCRIBE] drone@172.17.0.1:56034 msg: unsubscribe, sub_opts: [nl: 0, qos: 0, rap: 0, rh: 0, sub_props: [], subid: drone], topic: /uav/+/publish, username: drone
2024-06-20T02:46:56.779939+00:00 [SOCKET] drone@172.17.0.1:56034 msg: emqx_connection_terminated, reason: {shutdown,takenover}, username: drone
2024-06-20T02:46:56.780384+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_sent, packet: CONNACK(Q0, R0, D0, AckFlags=1, ReasonCode=0), username: drone
2024-06-20T02:46:56.781825+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_received, packet: SUBSCRIBE(Q1, R0, D0, PacketId=9 TopicFilters=[/uav/+/publish(#{nl => 0,qos => 0,rap => 0,rh => 0})]), username: drone
2024-06-20T02:46:56.781976+00:00 [SUBSCRIBE] drone@172.17.0.1:56346 msg: subscribe, sub_id: drone, sub_opts: [nl: 0, qos: 0, rap: 0, rh: 0, sub_props: []], topic: /uav/+/publish, username: drone
2024-06-20T02:46:56.782033+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_sent, packet: SUBACK(Q0, R0, D0, PacketId=9, ReasonCodes=[0]), username: drone
2024-06-20T02:47:56.782459+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_received, packet: PINGREQ(Q0, R0, D0), username: drone
2024-06-20T02:47:56.782560+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_sent, packet: PINGRESP(Q0, R0, D0), username: drone
2024-06-20T02:48:56.782618+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_received, packet: PINGREQ(Q0, R0, D0), username: drone
2024-06-20T02:48:56.782701+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_sent, packet: PINGRESP(Q0, R0, D0), username: drone
2024-06-20T02:49:56.782845+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_received, packet: PINGREQ(Q0, R0, D0), username: drone
2024-06-20T02:49:56.782928+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_sent, packet: PINGRESP(Q0, R0, D0), username: drone
2024-06-20T02:50:56.783114+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_received, packet: PINGREQ(Q0, R0, D0), username: drone
2024-06-20T02:50:56.783203+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_sent, packet: PINGRESP(Q0, R0, D0), username: drone
2024-06-20T02:51:56.783311+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_received, packet: PINGREQ(Q0, R0, D0), username: drone
2024-06-20T02:51:56.783396+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_sent, packet: PINGRESP(Q0, R0, D0), username: drone
2024-06-20T02:52:56.784546+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_received, packet: PINGREQ(Q0, R0, D0), username: drone
2024-06-20T02:52:56.784629+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_sent, packet: PINGRESP(Q0, R0, D0), username: drone
2024-06-20T02:53:05.922052+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_received, packet: PUBLISH(Q0, R0, D0, Topic=/uav/kbit/subscribe, PacketId=undefined, Payload={ “header”: { “messageType”: “uavOnlineList” } }), username: drone
2024-06-20T02:53:05.922200+00:00 [PUBLISH] drone@172.17.0.1:56346 msg: publish_to, topic: /uav/kbit/subscribe, username: drone, payload: { “header”: { “messageType”: “uavOnlineList” } }
2024-06-20T02:53:05.952962+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_sent, packet: PUBLISH(Q0, R0, D0, Topic=/uav/kbit/publish, PacketId=undefined, Payload={“header”:{“compress”:0,“messageId”:“8”,“messageType”:“uavOnlineListReply”,“timestamp”:1718851985938,“version”:“1.0”},“payload”:{“code”:“000000”,“data”:[],“errorMessage”:“处理成功”}}), username: drone
2024-06-20T02:53:07.259514+00:00 [MQTT] drone@172.17.0.1:56914 msg: mqtt_packet_received, packet: CONNECT(Q0, R0, D0, ClientId=drone, ProtoName=MQTT, ProtoVsn=4, CleanStart=false, KeepAlive=60, Username=drone, Password=
), username: drone
2024-06-20T02:53:07.259698+00:00 [AUTHN] drone@172.17.0.1:56914 msg: authenticator_result, authenticator: password_based:built_in_database, result: {ok,#{is_superuser => true}}, username: drone
2024-06-20T02:53:07.259799+00:00 [AUTHN] drone@172.17.0.1:56914 msg: authentication_result, reason: chain_result, result: {stop,{ok,#{is_superuser => true}}}, username: drone
2024-06-20T02:53:07.259970+00:00 [SUBSCRIBE] drone@172.17.0.1:56914 msg: subscribe, sub_id: drone, sub_opts: [nl: 0, qos: 0, rap: 0, rh: 0, sub_props: ], topic: /uav/+/publish, username: drone
2024-06-20T02:53:07.260085+00:00 [UNSUBSCRIBE] drone@172.17.0.1:56346 msg: unsubscribe, sub_opts: [nl: 0, qos: 0, rap: 0, rh: 0, sub_props: , subid: drone], topic: /uav/+/publish, username: drone
2024-06-20T02:53:07.260136+00:00 [SOCKET] drone@172.17.0.1:56346 msg: emqx_connection_terminated, reason: {shutdown,takenover}, username: drone
2024-06-20T02:53:07.260578+00:00 [MQTT] drone@172.17.0.1:56914 msg: mqtt_packet_sent, packet: CONNACK(Q0, R0, D0, AckFlags=1, ReasonCode=0), username: drone
2024-06-20T02:53:07.261998+00:00 [MQTT] drone@172.17.0.1:56914 msg: mqtt_packet_received, packet: SUBSCRIBE(Q1, R0, D0, PacketId=10 TopicFilters=[/uav/+/publish(#{nl => 0,qos => 0,rap => 0,rh => 0})]), username: drone
2024-06-20T02:53:07.262131+00:00 [SUBSCRIBE] drone@172.17.0.1:56914 msg: subscribe, sub_id: drone, sub_opts: [nl: 0, qos: 0, rap: 0, rh: 0, sub_props: ], topic: /uav/+/publish, username: drone
2024-06-20T02:53:07.262181+00:00 [MQTT] drone@172.17.0.1:56914 msg: mqtt_packet_sent, packet: SUBACK(Q0, R0, D0, PacketId=10, ReasonCodes=[0]), username: drone
2024-06-20T02:54:07.262658+00:00 [MQTT] drone@172.17.0.1:56914 msg: mqtt_packet_received, packet: PINGREQ(Q0, R0, D0), username: drone
2024-06-20T02:54:07.262770+00:00 [MQTT] drone@172.17.0.1:56914 msg: mqtt_packet_sent, packet: PINGRESP(Q0, R0, D0), username: drone
2024-06-20T02:55:07.262875+00:00 [MQTT] drone@172.17.0.1:56914 msg: mqtt_packet_received, packet: PINGREQ(Q0, R0, D0), username: drone
2024-06-20T02:55:07.262951+00:00 [MQTT] drone@172.17.0.1:56914 msg: mqtt_packet_sent, packet: PINGRESP(Q0, R0, D0), username: drone

2024-06-20T02:46:56.779939+00:00 [SOCKET] drone@172.17.0.1:56034 msg: emqx_connection_terminated, reason: {shutdown,takenover}, username: drone

这里出现了断开连接

旧连接使用的端口是 56034

看起来是 clientid 冲突了,或者是客户端程序错误地发送了新的 CONNECT 报文。

2024-06-20T02:46:56.779283+00:00 [MQTT] drone@172.17.0.1:56346 msg: mqtt_packet_received, packet: CONNECT(Q0, R0, D0, ClientId=drone, ProtoName=MQTT, ProtoVsn=4, CleanStart=false, KeepAlive=60, Username=drone, Password=), username: drone
2024-06-20T02:53:07.259514+00:00 [MQTT] drone@172.17.0.1:56914 msg: mqtt_packet_received, packet: CONNECT(Q0, R0, D0, ClientId=drone, ProtoName=MQTT, ProtoVsn=4, CleanStart=false, KeepAlive=60, Username=drone, Password=), username: drone

这里,有新的连接使用 ClientId=drone,分别使用端口 56346 和 56914 发送了 CONNECT 报文。

1 个赞

查看了断开连接的回调,是消息解析有问题,出现异常,导致连接断开。已解决。

1 个赞