mqtt过一段时间消息发送失败

环境

  • EMQX 版本:5.x
  • 操作系统版本:Linux

错误日志

2025-04-09T14:14:18.289706+08:00
[error]
msg: match_rule_error,
mfa: emqx_authz_redis:do_authorize/4(114),
peername: 10.10.10.131:53018,
clientid: kangwenyao-1744178691628,
reason: {invalid_topic_rule,<<“2”>>,notamap},
rule_encoded: <<“2”>>,
stacktrace: [
{emqx_authz_redis,parse_rule,1,[{file,“emqx_authz_redis.erl”},{line,149}]},
{emqx_authz_redis,compile_rule,2,[{file,“emqx_authz_redis.erl”},{line,125}]},
{emqx_authz_redis,do_authorize,4,[{file,“emqx_authz_redis.erl”},{line,101}]},
{emqx_authz,do_authorize,4,[{file,“emqx_authz.erl”},{line,521}]},
{emqx_authz,authorize_non_superuser,5,[{file,“emqx_authz.erl”},{line,471}]},
{emqx_hooks,safe_execute,2,[{file,“emqx_hooks.erl”},{line,204}]},
{emqx_hooks,do_run_fold,3,[{file,“emqx_hooks.erl”},{line,184}]},
{emqx_access_control,do_authorize,3,[{file,“emqx_access_control.erl”},{line,176}]},
{emqx_access_control,check_authorization_cache,3,[{file,“emqx_access_control.erl”},{line,137}]},
{emqx_access_control,authorize,3,[{file,“emqx_access_control.erl”},{line,105}]},
{emqx_channel,check_pub_authz,2,[{file,“emqx_channel.erl”},{line,1840}]},
{emqx_utils,pipeline,3,[{file,“emqx_utils.erl”},{line,172}]},
{emqx_channel,process_publish,2,[{file,“emqx_channel.erl”},{line,619}]},
{emqx_ws_connection,with_channel,3,[{file,“emqx_ws_connection.erl”},{line,754}]},
{cowboy_websocket,handler_call,6,[{file,“cowboy_websocket.erl”},{line,487}]},
{proc_lib,wake_up,3,[{file,“proc_lib.erl”},{line,250}]}
],
topic_filter_raw: <<“thing/product/7CTDL9K00A0051/drc/down”>>

你的 redis 里面查出来的authz 格式错了。


应该是这样的,结果查出来只有一个 2

这个是开始好使,用一段时间就不好使了;并不是那种直接从开始就授权失败,你确定是你说的这个原因吗?

日志很明确的说,你现在就是遇到了这个问题。

这个也是格式吧?

我知道你说的是这个道理;但是我刚开始好使,过一段时间时候才不好使的;
如果没有别的原因,只能调整授权规则来验证了。