MQTT配置:
设备心跳设置是180s:
日志追踪:
2023-09-21T18:18:48.808328+08:00 [MQTT] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@221.178.126.151:37532 msg: mqtt_packet_received, packet: CONNECT(Q0, R0, D0, ClientId=bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001, ProtoName=MQTT, ProtoVsn=4, CleanStart=true, KeepAlive=180, Username=bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001, Password=******)
2023-09-21T18:18:48.808486+08:00 [AUTHN] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@221.178.126.151:37532 msg: user_not_found, provider: emqx_authn_mnesia
2023-09-21T18:18:48.808507+08:00 [AUTHN] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@221.178.126.151:37532 msg: authenticator_result, authenticator: password_based:built_in_database, result: ignore
2023-09-21T18:18:48.808571+08:00 [QUERY] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@221.178.126.151:37532 msg: mysql_connector_received, connector: emqx_authn_mysql:11684, sql: emqx_authn_mysql, state: [batch_inserts: , batch_params_tokens: , params_tokens: [emqx_authn_mysql: ], pool_name: emqx_authn_mysql:11684, prepare_statement: [emqx_authn_mysql: SELECT mqttPassword as password FROM iot_device where mqttAccount = ? and clientId = ? and disabled = false LIMIT 1]]
2023-09-21T18:18:48.816527+08:00 [AUTHN] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@221.178.126.151:37532 msg: authenticator_result, authenticator: password_based:mysql, result: {ok,#{is_superuser => false}}
2023-09-21T18:18:48.816671+08:00 [AUTHN] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@221.178.126.151:37532 msg: authentication_result, reason: chain_result, result: {stop,{ok,#{is_superuser => false}}}
2023-09-21T18:18:48.817266+08:00 [RULE] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@221.178.126.151:37532 msg: republish_message, flags: [retain: false], pub_props: [User-Property: ], topic: events/bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001/connection/status, payload: {
“username”:“bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001”,
“node":"emqx@127.0.0.1”,
“event”:“client.connected”,
“clientid”:“bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001”,
“timestamp”:“1695291528817”
}
2023-09-21T18:18:48.817344+08:00 [PUBLISH] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@221.178.126.151:37532 msg: publish_to, topic: events/bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001/connection/status, payload: {
“username”:“bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001”,
“node":"emqx@127.0.0.1”,
“event”:“client.connected”,
“clientid”:“bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001”,
“timestamp”:“1695291528817”
}
2023-09-21T18:18:48.817463+08:00 [BRIDGE] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@221.178.126.151:37532 msg: bridge_action, bridge_id: webhook:iot_update_status
2023-09-21T18:18:48.817628+08:00 [MQTT] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@221.178.126.151:37532 msg: mqtt_packet_sent, packet: CONNACK(Q0, R0, D0, AckFlags=0, ReasonCode=0)
2023-09-21T18:18:49.022799+08:00 [MQTT] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@221.178.126.151:37532 msg: mqtt_packet_received, packet: SUBSCRIBE(Q1, R0, D0, PacketId=1 TopicFilters=[xw/WB_00001/bd08c9f0582811ee97b4bdc6a35a6b09/message/update(#{nl => 0,
qos => 1,
rap => 0,
rh => 0})])
2023-09-21T18:18:49.023114+08:00 [SUBSCRIBE] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@221.178.126.151:37532 msg: subscribe, sub_id: bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001, sub_opts: [nl: 0, qos: 1, rap: 0, rh: 0, sub_props: ], topic: xw/WB_00001/bd08c9f0582811ee97b4bdc6a35a6b09/message/update
2023-09-21T18:18:49.023463+08:00 [BRIDGE] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@221.178.126.151:37532 msg: bridge_action, bridge_id: webhook:iot_device_topic
2023-09-21T18:20:07.802003+08:00 [PUBLISH] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@117.132.196.84:48351 msg: publish_to, topic: xw/WB_00001/bd08c9f0582811ee97b4bdc6a35a6b09/message/update, payload: {“PreheatState”: “1”, “WaringState”: “0”, “ICCID”: “898604921920C0658015”, “channel”: 0, “FXW01Data”: “NM1_ID_00731;32.8;42.7;40950004;409500040;40950004;409500040;8181999;409500040;13643333;409500040;2038000;34033330;1194705;18518180;331333;4608040;601343;2227270;207872;1225560;159256;1094160;82252;764130;98647;899020;57814;664170;50952;639350;10.1;10;”}
2023-09-21T18:20:07.802200+08:00 [BRIDGE] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@117.132.196.84:48351 msg: bridge_action, bridge_id: webhook:iot_device_topic
2023-09-21T18:20:07.802681+08:00 [MQTT] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@117.132.196.84:48351 msg: mqtt_packet_sent, packet: PUBLISH(Q0, R0, D0, Topic=xw/WB_00001/bd08c9f0582811ee97b4bdc6a35a6b09/message/update, PacketId=undefined, Payload={“PreheatState”: “1”, “WaringState”: “0”, “ICCID”: “898604921920C0658015”, “channel”: 0, “FXW01Data”: “NM1_ID_00731;32.8;42.7;40950004;409500040;40950004;409500040;8181999;409500040;13643333;409500040;2038000;34033330;1194705;18518180;331333;4608040;601343;2227270;207872;1225560;159256;1094160;82252;764130;98647;899020;57814;664170;50952;639350;10.1;10;”})
2023-09-21T18:25:22.411803+08:00 [SOCKET] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@117.132.196.84:48351 msg: socket_force_closed, reason: keepalive_timeout
2023-09-21T18:25:22.412237+08:00 [RULE] bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001@117.132.196.84:48351 msg: republish_message, flags: [retain: false], pub_props: [User-Property: ], topic: events/bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001/connection/status, payload: {
“username”:“bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001”,
“node":"emqx@127.0.0.1”,
“event”:“client.disconnected”,
“clientid”:“bd08c9f0582811ee97b4bdc6a35a6b09&WB_00001”,
“timestamp”:“1695291922412”
}
从日志上看,最后一条数据是18:20:07上报的,这时拔了电源,18:25:22才提示离线了。比正常保活时间多了2分多钟,如果我的倍数按默认1.5倍的话,从拔电后大概10分钟才离线。这是什么原因呢