因初次接触,所以选择 emqx 5.2.0 社区版进行体验。
目标是使用 Postgresql 作为数据库实现 emqx 密码认证。按照 5.2.0 文档进行配置,数据库可以正常连接。
除了数据库连接之外,所有配置包括数据表创建脚本以及初始数据,均按照官网文档创建。
使用,mqttx 进行测试,始终出现“Error: Connection refused: Not authorized”错误。windows 版和 Docker 都试过,均是如此。我也尝试更改加密算法、修改 sql 将 password_hash 映射成 password,依如此。
在 Docker 后台,会看到错误:
2023-09-19 22:25:21 2023-09-19T14:25:21.083065+00:00 [error] msg: postgresql connector do sql query failed, mfa: emqx_connector_pgsql:on_sql_query/5, line: 255, peername: 172.18.0.1:41984, clientid: mqttx_75da319e_1695133521000, connector: <<"emqx_authn_pgsql:1">>, reason: {error,error,<<"42501">>,insufficient_privilege,<<229,175,185,232,161,168,32,109,113,116,116,95,117,115,101,114,32,230,157,131,233,153,144,228,184,141,229,164,159>>,[{file,<<"aclchk.c">>},{line,<<"3652">>},{routine,<<"aclcheck_error">>},{severity,<<233,148,153,232,175,175>>}]}, sql: <<"emqx_authn_pgsql:1">>, type: prepared_query
2023-09-19 22:25:21 2023-09-19T14:25:21.083209+00:00 [error] msg: unrecoverable_error, mfa: emqx_resource_buffer_worker:handle_query_result_pure/3, line: 890, peername: 172.18.0.1:41984, clientid: mqttx_75da319e_1695133521000, id: <<"emqx_authn_pgsql:1">>, reason: {unrecoverable_error,{error,error,<<"42501">>,insufficient_privilege,<<229,175,185,232,161,168,32,109,113,116,116,95,117,115,101,114,32,230,157,131,233,153,144,228,184,141,229,164,159>>,[{file,<<"aclchk.c">>},{line,<<"3652">>},{routine,<<"aclcheck_error">>},{severity,<<233,148,153,232,175,175>>}]}}
2023-09-19 22:25:21 2023-09-19T14:25:21.083286+00:00 [error] msg: postgresql_query_failed, mfa: emqx_authn_pgsql:authenticate/2, line: 144, peername: 172.18.0.1:41984, clientid: mqttx_75da319e_1695133521000, params: [<<"emqx_u">>], provider: emqx_authn_pgsql, reason: {unrecoverable_error,{error,error,<<"42501">>,insufficient_privilege,<<229,175,185,232,161,168,32,109,113,116,116,95,117,115,101,114,32,230,157,131,233,153,144,228,184,141,229,164,159>>,[{file,<<"aclchk.c">>},{line,<<"3652">>},{routine,<<"aclcheck_error">>},{severity,<<233,148,153,232,175,175>>}]}}, resource: <<"emqx_authn_pgsql:1">>, tag: AUTHN
ACL 表也按照官网说明,增加了相应的表和初始数据。
同样的,改用 Mysql 数据库,按照官网说明配置,就可以很顺利的认证成功。Mysql 也不需要增加 ACL 表
请问,是我在 postgresql 中操作的不对,还是说社区版就不支持 Postgresql?