EMQX版本4.3.2 经常出现设备连接不上,一直返回valid client id,怎么都连接不上,但是能订阅到设备上线的topic,mqtt在线列表查询不到,这个是被EMQX缓存起来了吗?
点击连接,能同时订阅到两条上线信息
那就是说明没登录成功。你打开 emqx 的 debug 日志看看。
可能也会有一些错误日志。
这个是开启debug的日志:2024-04-02T09:55:53.339698+08:00 [debug] 172.22.0.119:56198 [MQTT] RECV CONNECT(Q0, R0, D0, ClientId=238N50042564_AB2098AFD043A88C24D625F5278D3968, ProtoName=MQTT, ProtoVsn=4, CleanStart=true, KeepAlive=60, Username=test0402, Password=)
2024-04-02T09:55:53.350075+08:00 [debug] grusprotest01_88F7CEF117BED311A73FA60DFE33C53E@172.23.0.175:23717 [MQTT] SEND PUBLISH(Q0, R0, D0, Topic=$SYS/brokers/emqx3@172.21.65.159/clients/238N50042564_AB2098AFD043A88C24D625F5278D3968/connected, PacketId=undefined, Payload=<<“{"username":"test0402","ts":1712022953348,"sockport":1883,"proto_ver":4,"proto_name":"MQTT","keepalive":60,"ipaddress":"172.22.0.119","expiry_interval":0,"connected_at":1712022953348,"connack":0,"clientid":"238N50042564_AB2098AFD043A88C24D625F5278D3968","clean_start":true}”>>)
2024-04-02T09:55:53.350172+08:00 [debug] push_grus_prod158217114194519584019@172.22.0.118:41352 [MQTT] SEND PUBLISH(Q0, R0, D0, Topic=$SYS/brokers/emqx3@172.21.65.159/clients/238N50042564_AB2098AFD043A88C24D625F5278D3968/connected, PacketId=undefined, Payload=<<“{"username":"test0402","ts":1712022953348,"sockport":1883,"proto_ver":4,"proto_name":"MQTT","keepalive":60,"ipaddress":"172.22.0.119","expiry_interval":0,"connected_at":1712022953348,"connack":0,"clientid":"238N50042564_AB2098AFD043A88C24D625F5278D3968","clean_start":true}”>>)
2024-04-02T09:55:53.350555+08:00 [debug] 238N50042564_AB2098AFD043A88C24D625F5278D3968@172.22.0.119:56198 [MQTT] SEND CONNACK(Q0, R0, D0, AckFlags=0, ReasonCode=2)
2024-04-02T09:55:53.350690+08:00 [info] 238N50042564_AB2098AFD043A88C24D625F5278D3968@172.22.0.119:56198 file: emqx_connection.erl, line: 519, mfa: {emqx_connection,terminate,2}, msg: terminate, pid: <0.19216.1981>, reason: {shutdown,client_identifier_not_valid}
2024-04-02T09:55:53.507709+08:00 [debug] push_grus_prod158417114196008274539@172.22.0.118:24650 [MQTT] SEND PUBLISH(Q0, R0, D0, Topic=$SYS/brokers/emqx1@172.21.65.154/clients/238N50042564_AB2098AFD043A88C24D625F5278D3968/connected, PacketId=undefined, Payload=<<“{"username":"test0402","ts":1712022953504,"sockport":1883,"proto_ver":3,"proto_name":"MQIsdp","keepalive":60,"ipaddress":"172.22.0.118","expiry_interval":0,"connected_at":1712022953504,"connack":0,"clientid":"238N50042564_AB2098AFD043A88C24D625F5278D3968","clean_start":true}”>>)
2024-04-02T09:55:53.507771+08:00 [debug] event=cast_received driver=tcp socket=“#Port<0.139673>” peer=“172.21.65.154:20284” module=emqx_broker function=dispatch args=“[<<”$SYS/brokers/+/clients/238N50042564_AB2098AFD043A88C24D625F5278D3968/#“>>,{delivery,<45336.2636.777>,{message,<<0,6,21,19,103,253,174,174,119,118,9,3,…>>,1,emqx_mod_presence,#{sys => true},#{},<<”$SYS/brokers/emqx1@172.21.65"…>>,<<“{"username":"test0402","”…>>,1712022953504}}]"
2024-04-02T09:55:53.507980+08:00 [debug] grusprotest01_88F7CEF117BED311A73FA60DFE33C53E@172.23.0.175:23717 [MQTT] SEND PUBLISH(Q0, R0, D0, Topic=$SYS/brokers/emqx1@172.21.65.154/clients/238N50042564_AB2098AFD043A88C24D625F5278D3968/connected, PacketId=undefined, Payload=<<“{"username":"test0402","ts":1712022953504,"sockport":1883,"proto_ver":3,"proto_name":"MQIsdp","keepalive":60,"ipaddress":"172.22.0.118","expiry_interval":0,"connected_at":1712022953504,"connack":0,"clientid":"238N50042564_AB2098AFD043A88C24D625F5278D3968","clean_start":true}”>>)
2024-04-02T09:55:54.395872+08:00 [debug] 172.22.0.119:56268 [MQTT] RECV CONNECT(Q0, R0, D0, ClientId=238N50042564_AB2098AFD043A88C24D625F5278D3968, ProtoName=MQTT, ProtoVsn=4, CleanStart=true, KeepAlive=60, Username=test0402, Password=)
2024-04-02T09:55:54.407793+08:00 [debug] grusprotest01_88F7CEF117BED311A73FA60DFE33C53E@172.23.0.175:23717 [MQTT] SEND PUBLISH(Q0, R0, D0, Topic=$SYS/brokers/emqx3@172.21.65.159/clients/238N50042564_AB2098AFD043A88C24D625F5278D3968/connected, PacketId=undefined, Payload=<<“{"username":"test0402","ts":1712022954404,"sockport":1883,"proto_ver":4,"proto_name":"MQTT","keepalive":60,"ipaddress":"172.22.0.119","expiry_interval":0,"connected_at":1712022954404,"connack":0,"clientid":"238N50042564_AB2098AFD043A88C24D625F5278D3968","clean_start":true}”>>)
2024-04-02T09:55:54.410358+08:00 [debug] 238N50042564_AB2098AFD043A88C24D625F5278D3968@172.22.0.119:56268 [MQTT] SEND CONNACK(Q0, R0, D0, AckFlags=0, ReasonCode=2)
2024-04-02T09:55:54.410520+08:00 [info] 238N50042564_AB2098AFD043A88C24D625F5278D3968@172.22.0.119:56268 file: emqx_connection.erl, line: 519, mfa: {emqx_connection,terminate,2}, msg: terminate, pid: <0.29964.1915>, reason: {shutdown,client_identifier_not_valid}
2024-04-02T09:55:54.559106+08:00 [debug] 172.22.0.119:40797 [MQTT] RECV CONNECT(Q0, R0, D0, ClientId=238N50042564_AB2098AFD043A88C24D625F5278D3968, ProtoName=MQIsdp, ProtoVsn=3, CleanStart=true, KeepAlive=60, Username=test0402, Password=******)
2024-04-02T09:55:54.570457+08:00 [debug] push_grus_prod146317114185816538554@172.22.0.119:21838 [MQTT] SEND PUBLISH(Q0, R0, D0, Topic=$SYS/brokers/emqx3@172.21.65.159/clients/238N50042564_AB2098AFD043A88C24D625F5278D3968/connected, PacketId=undefined, Payload=<<“{"username":"test0402","ts":1712022954566,"sockport":1883,"proto_ver":3,"proto_name":"MQIsdp","keepalive":60,"ipaddress":"172.22.0.119","expiry_interval":0,"connected_at":1712022954566,"connack":0,"clientid":"238N50042564_AB2098AFD043A88C24D625F5278D3968","clean_start":true}”>>)
2024-04-02T09:55:54.570502+08:00 [debug] grusprotest01_88F7CEF117BED311A73FA60DFE33C53E@172.23.0.175:23717 [MQTT] SEND PUBLISH(Q0, R0, D0, Topic=$SYS/brokers/emqx3@172.21.65.159/clients/238N50042564_AB2098AFD043A88C24D625F5278D3968/connected, PacketId=undefined, Payload=<<“{"username":"test0402","ts":1712022954566,"sockport":1883,"proto_ver":3,"proto_name":"MQIsdp","keepalive":60,"ipaddress":"172.22.0.119","expiry_interval":0,"connected_at":1712022954566,"connack":0,"clientid":"238N50042564_AB2098AFD043A88C24D625F5278D3968","clean_start":true}”>>)
2024-04-02T09:55:54.571003+08:00 [debug] 238N50042564_AB2098AFD043A88C24D625F5278D3968@172.22.0.119:40797 [MQTT] SEND CONNACK(Q0, R0, D0, AckFlags=0, ReasonCode=2)
2024-04-02T09:55:54.571146+08:00 [info] 238N50042564_AB2098AFD043A88C24D625F5278D3968@172.22.0.119:40797 file: emqx_connection.erl, line: 519, mfa: {emqx_connection,terminate,2}, msg: terminate, pid: <0.19246.1981>, reason: {shutdown,client_identifier_not_valid}
2024-04-02T09:55:55.324815+08:00 [debug] event=cast_received driver=tcp socket=“#Port<0.27709>” peer=“172.21.65.156:6150” module=emqx_broker function=dispatch args=“[<<”$SYS/brokers/+/clients238N50042564_AB2098AFD043A88C24D625F5278D3968/#“>>,{delivery,<45337.1757.868>,{message,<<0,6,21,19,104,25,90,193,104,226,100,3,…>>,1,emqx_mod_presence,#{sys => true},#{},<<”$SYS/brokers/emqx2@172.21.65"…>>,<<“{"username":"test0402","”…>>,1712022955317}}]"
2024-04-02T09:55:55.325095+08:00 [debug] grusprotest01_88F7CEF117BED311A73FA60DFE33C53E@172.23.0.175:23717 [MQTT] SEND PUBLISH(Q0, R0, D0, Topic=$SYS/brokers/emqx2@172.21.65.156/clients/238N50042564_AB2098AFD043A88C24D625F5278D3968/connected, PacketId=undefined, Payload=<<“{"username":"test0402","ts":1712022955317,"sockport":1883,"proto_ver":4,"proto_name":"MQTT","keepalive":60,"ipaddress":"172.22.0.119","expiry_interval":0,"connected_at":1712022955317,"connack":0,"clientid":"238N50042564_AB2098AFD043A88C24D625F5278D3968","clean_start":true}”>>)
2024-04-02T09:55:55.519763+08:00 [debug] event=cast_received driver=tcp socket=“#Port<0.27709>” peer=“172.21.65.156:6150” module=emqx_broker function=dispatch args=“[<<”$SYS/brokers/+/clients238N50042564_AB2098AFD043A88C24D625F5278D3968/#“>>,{delivery,<45337.20574.1011>,{message,<<0,6,21,19,104,28,91,55,104,226,243,3,…>>,1,emqx_mod_presence,#{sys => true},#{},<<”$SYS/brokers/emqx2@172.21.65"…>>,<<“{"username":"test0402","”…>>,1712022955514}}]"
2024-04-02T09:55:55.520023+08:00 [debug] grusprotest01_88F7CEF117BED311A73FA60DFE33C53E@172.23.0.175:23717 [MQTT] SEND PUBLISH(Q0, R0, D0, Topic=$SYS/brokers/emqx2@172.21.65.156/clients/238N50042564_AB2098AFD043A88C24D625F5278D3968/connected, PacketId=undefined, Payload=<<“{"username":"test0402","ts":1712022955514,"sockport":1883,"proto_ver":3,"proto_name":"MQIsdp","keepalive":60,"ipaddress":"172.22.0.119","expiry_interval":0,"connected_at":1712022955514,"connack":0,"clientid":"238N50042564_AB2098AFD043A88C24D625F5278D3968","clean_start":true}”>>)
2024-04-02T09:55:41.444044+08:00 [debug] push_grus_prod16081711419218540634@172.23.0.175:31223 [MQTT] SEND PUBLISH(Q0, R0, D0, Topic=$SYS/brokers/emqx1@172.21.65.154/clients/238N50042564_AB2098AFD043A88C24D625F5278D3968/connected, PacketId=undefined, Payload=<<“{"username":"test0402","ts":1712022941439,"sockport":1883,"proto_ver":4,"proto_name":"MQTT","keepalive":60,"ipaddress":"172.22.0.118","expiry_interval":0,"connected_at":1712022941439,"connack":0,"clientid":"238N50042564_AB2098AFD043A88C24D625F5278D3968","clean_start":true}”>>)
2024-04-02T09:55:41.444248+08:00 [debug] event=cast_received driver=tcp socket=“#Port<0.139673>” peer=“172.21.65.154:20284” module=emqx_broker function=dispatch args=“[<<”$SYS/brokers/+/clients/238N50042564_AB2098AFD043A88C24D625F5278D3968/#“>>,{delivery,<45336.10940.585>,{message,<<0,6,21,19,103,69,148,201,119,118,73,2,…>>,1,emqx_mod_presence,#{sys => true},#{},<<”$SYS/brokers/emqx1@172.21.65"…>>,<<“{"username":"test0402","”…>>,1712022941439}}]" ===========看日志就说是client_identifier_not_valid
总感觉是个已知问题,同一个客户端多次重连时,clientid 被锁定导致无法登陆。你用 4.4.19(开源最新版本)或者 emqx 5.6.0 试试看吧?
没办法解锁吗?因为是在生产环境竟然避免emqx服务器重启
好像是因为服务器挂了,然后重启之后,有些终端连接就一直报无效客户机码
4.3 版本已经停止维护了,最好升级到 4.4.19 去。