emqx版本:5.3.1-alpha.1
现象:在Dashboard中设置了客户端认证,使用mysql,设置后认证是正常。但是如果重启emqx后,发现客户端认证失效,任何用户名密码都可以连接,在Dashboard中查看数据源状态连接正常,启用状态也是打开的,但是如果把设置删除重新创建一下又正常了,试了很多遍都是这样,找不到问题所在,请帮忙研究一下。(PS:同样使用mysql+ACL设置的客户端授权的配置,重启后是正常的。)
其中emqx.conf的内容如下:
NOTE:
This config file overrides data/configs/cluster.hocon,
and is merged with environment variables which start with ‘EMQX_’ prefix.
Config changes made from EMQX dashboard UI, management HTTP API, or CLI
are stored in data/configs/cluster.hocon.
To avoid confusion, please do not store the same configs in both files.
See Configuration Files | EMQX 5.0 Documentation for more details.
Configuration full example can be found in etc/examples
node {
name = “emqx@127.0.0.1”
cookie = “emqxsecretcookie”
data_dir = “/var/lib/emqx”
}
cluster {
name = emqxcl
discovery_strategy = manual
}
dashboard {
listeners.http {
bind = 18083
}
}
另一个文件cluster.hocon的内容如下:
authentication = [
{
backend = mysql
database = iotdb
mechanism = password_based
password = “1212”
password_hash_algorithm {name = sha256, salt_position = suffix}
pool_size = 8
query = “SELECT password_hash, salt FROM mqtt_user where username = ${username} LIMIT 1”
query_timeout = 5s
server = “127.0.0.1:3306”
ssl {enable = false, verify = verify_peer}
username = root
}
]
authorization {
cache {
enable = true
max_size = 32
ttl = 1m
}
deny_action = ignore
no_match = allow
sources = [
{
database = iotdb
password = “1212”
pool_size = 8
query = “SELECT action, permission, topic FROM mqtt_acl where username = ${username}”
server = “127.0.0.1:3306”
ssl {enable = false, verify = verify_peer}
type = mysql
username = root
},
{
enable = true
path = “/var/lib/emqx/authz/acl.conf”
type = file
}
]
}
flapping_detect {
ban_time = 5m
enable = true
max_count = 15
window_time = 1m
}