使用Client ID 认证,经常出现验证信息被删

问题描述

使用Client ID 认证,会出现验证信息莫名其妙被删的情况,导致客户端无法再连接上

环境信息

  • EMQ X 版本:4.2.2
  • 操作系统及版本:CentOS Linux release 7.7.1908 (Core)
  • 其他: 内核版本Linux 3.10.0-1062.18.1.el7.x86_64

配置文件及日志

2021-05-19 20:40:45.735 [debug] <<"1918BD00035F">>@39.144.11.202:23451 [MQTT] RECV PUBLISH(Q1, R0, D0, Topic=BGT1/1918BD00035F/PeriodReportBin, PacketId=13846, Payload=<<192,57,0,1,2,0,189,0,3,95,20,1,1,1,1,6,54,22,16,0,1,159,11,231,20,43,194,43,194,43,194,43,194,43,195,141,6,7,33,251,200,1,235,14,145,0,0,0,27,96,165,7,79,96,164,183,165,232,25>>)
2021-05-19 20:40:45.735 [info] <<"1918BD00035F">>@39.144.11.202:23451 PUBLISH to BGT1/1918BD00035F/PeriodReportBin: <<192,57,0,1,2,0,189,0,3,95,20,1,1,1,1,6,54,22,16,0,1,159,11,231,20,43,194,43,194,43,194,43,194,43,195,141,6,7,33,251,200,1,235,14,145,0,0,0,27,96,165,7,79,96,164,183,165,232,25>>
2021-05-19 20:40:45.736 [debug] <<"1918BD00035F">>@39.144.11.202:23451 [MQTT] SEND PUBACK(Q0, R0, D0, PacketId=13846, ReasonCode=0)
2021-05-19 20:40:45.736 [debug] <<"open212192.168.0.212">>@221.224.213.228:37044 [MQTT] SEND PUBLISH(Q1, R0, D0, Topic=BGT1/1918BD00035F/PeriodReportBin, PacketId=58986, Payload=<<192,57,0,1,2,0,189,0,3,95,20,1,1,1,1,6,54,22,16,0,1,159,11,231,20,43,194,43,194,43,194,43,194,43,195,141,6,7,33,251,200,1,235,14,145,0,0,0,27,96,165,7,79,96,164,183,165,232,25>>)
2021-05-19 20:40:45.736 [debug] <<"cloud_pre_172.16.166.79">>@47.114.177.143:50298 [MQTT] SEND PUBLISH(Q1, R0, D0, Topic=BGT1/1918BD00035F/PeriodReportBin, PacketId=23164, Payload=<<192,57,0,1,2,0,189,0,3,95,20,1,1,1,1,6,54,22,16,0,1,159,11,231,20,43,194,43,194,43,194,43,194,43,195,141,6,7,33,251,200,1,235,14,145,0,0,0,27,96,165,7,79,96,164,183,165,232,25>>)
2021-05-19 20:41:19.257 [debug] 39.144.2.100:20683 [MQTT] RECV CONNECT(Q0, R0, D0, ClientId=1918BD00035F, ProtoName=MQTT, ProtoVsn=4, CleanStart=true, KeepAlive=300, Username=1918BD00035F, Password=******)
2021-05-19 20:41:19.257 [warning] <<"1918BD00035F">>@39.144.2.100:20683 [Channel] Client 1918BD00035F (Username: '1918BD00035F') login failed for not_authorized
2021-05-19 20:41:19.257 [debug] <<"1918BD00035F">>@39.144.2.100:20683 [MQTT] SEND CONNACK(Q0, R0, D0, AckFlags=0, ReasonCode=5)
2021-05-19 20:41:19.257 [debug] <<"1918BD00035F">>@39.144.2.100:20683 [MQTT] Terminated due to {shutdown,not_authorized}

你使用的认证插件是?

emqx_auth_clientid

目前日志中看起来1918BD00035F设备publish消息后,没有离线的信息,但是收到了 RECV CONNECT 消息,debug一下设备的情况;并检查在业务期间有没有对EMQX其他的操作

业务期间没有对emqx做其他操作的,emqx会有什么情况下,会去主动删除emqx_auth_clientid里面添加的验证信息吗

EMQ X不会自己删除设备认证信息,确认下你的设备行为,没有看到离线消息的日志,但是publish消息后是该设备CONNECT的消息,有点不正常

好的,感谢

我想了解一下你是怎么解决的这个问题。我和你类似,我是docker-compose跑的emqx,然后客户端emqttx连接上去提示我账号密码未认证。但是奇怪的事我前5分钟连接是好的,去喝了口水回来就连接不上提示

(Username: 'admin') login failed for not_authorized

更多一些的日志如下:

2022-03-18T14:58:36.089688+00:00 [info] [Modules] Load emqx_mod_acl_internal module successfully.

2022-03-18T14:58:36.089813+00:00 [info] [Modules] Load emqx_mod_presence module successfully.

2022-03-18T14:58:36.089986+00:00 [info] [Modules] Load emqx_mod_topic_metrics module successfully.

2022-03-18T14:58:36.090121+00:00 [info] [Modules] Load emqx_mod_slow_subs module successfully.

2022-03-18T14:58:36.109093+00:00 [info] [Modules] Load emqx_mod_trace module successfully.

EMQ X Broker 4.4.1 is running now!

2022-03-18T14:59:24.330216+00:00 [debug] 172.16.0.60:27454 [MQTT/WS] RECV <<16>>

2022-03-18T14:59:24.330341+00:00 [debug] 172.16.0.60:27454 [MQTT/WS] RECV <<“1”>>

2022-03-18T14:59:24.330455+00:00 [debug] 172.16.0.60:27454 [MQTT/WS] RECV <<0,4>>

2022-03-18T14:59:24.330528+00:00 [debug] 172.16.0.60:27454 [MQTT/WS] RECV <<“MQTT”>>

2022-03-18T14:59:24.330684+00:00 [debug] 172.16.0.60:27454 [MQTT/WS] RECV <<4>>

2022-03-18T14:59:24.330800+00:00 [debug] 172.16.0.60:27454 [MQTT/WS] RECV <<“�”>>

2022-03-18T14:59:24.330910+00:00 [debug] 172.16.0.60:27454 [MQTT/WS] RECV <<0,60>>

2022-03-18T14:59:24.330999+00:00 [debug] 172.16.0.60:27454 [MQTT/WS] RECV <<0,20>>

2022-03-18T14:59:24.331095+00:00 [debug] 172.16.0.60:27454 [MQTT/WS] RECV <<“emq1-pro-ayunw-cn”>>

2022-03-18T14:59:24.331175+00:00 [debug] 172.16.0.60:27454 [MQTT/WS] RECV <<0,5>>

2022-03-18T14:59:24.331279+00:00 [debug] 172.16.0.60:27454 [MQTT/WS] RECV <<“admin”>>

2022-03-18T14:59:24.331341+00:00 [debug] 172.16.0.60:27454 [MQTT/WS] RECV <<0,8>>

2022-03-18T14:59:24.331404+00:00 [debug] 172.16.0.60:27454 [MQTT/WS] RECV <<“xxxxxxxx”>>

2022-03-18T14:59:24.331478+00:00 [debug] 172.16.0.60:27454 [MQTT/WS] RECV CONNECT(Q0, R0, D0, ClientId=emq1-pro-ayunw-cn, ProtoName=MQTT, ProtoVsn=4, CleanStart=true, KeepAlive=60, Username=admin, Password=******)

2022-03-18T14:59:24.331671+00:00 [warning] emq1-pro-ayunw-cn@172.16.0.60:27454 [Channel] Client emq1-pro-ayunw-cn (Username: ‘admin’) login failed for not_authorized

2022-03-18T14:59:24.331779+00:00 [debug] emq1-pro-ayunw-cn@172.16.0.60:27454 [MQTT/WS] SEND CONNACK(Q0, R0, D0, AckFlags=0, ReasonCode=5)

2022-03-18T14:59:24.331911+00:00 [debug] emq1-pro-ayunw-cn@172.16.0.60:27454 [MQTT/WS] Terminated due to {shutdown,not_authorized}

问题已经解决,需要手动编写load_plugins 加载插件,挂载到容器才会启动认证功能。