Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

给emqx5.7版本生成一个特定镜像,配置其emqx.conf和acl.conf,支持1883和8883,8884端口,8884端口有认证,并且拒绝publish action和set指令 #14214

Open
zhouruiruiruiyan opened this issue Nov 13, 2024 · 3 comments
Labels

Comments

@zhouruiruiruiyan
Copy link

zhouruiruiruiyan commented Nov 13, 2024

What happened?

环境

  1. 有一个Dockerfile文件
    image
  2. docker-compose文件
    image
  3. conf下,acl.conf文件
    image
  4. conf下,emqx.conf文件
node {
  name = "emqx@127.0.0.1"
  cookie = "emqxsecretcookie"
  data_dir = "data"
}

cluster {
  name = emqxcl
  discovery_strategy = manual
}

dashboard {
    listeners.http {
        bind = 18083
    }
}

authentication = [
 {
  method="post"
	headers= {content-type="application/json"}
	mechanism="password_based"
	backend="http"
	url= "http://mqtt-auth:18087/api/v1/auth",
	enable=true
	body={"username": "${username}","password": "${password}"}
 }
]

zones.devicezone.mqtt.max_packet_size=10485760

mqtt {
 client_attrs_init = [ 
         { expression = "iif(str_eq(zone,'devicezone'),'action','none')" set_as_attr = action}, 
         { expression = "iif(str_eq(zone,'devicezone'),'set','none')" set_as_attr = set},
         { expression = "iif(str_eq(zone,'devicezone'),'req','none')" set_as_attr = req} ]
 }

listeners.tcp.default{ 
  enable_authn = false 
}

listeners.ssl.default{ 
  enable_authn = false 
  zone = devicezone
}

listeners.ssl.auth{ 
  bind = "0.0.0.0:8884" 
  enabled = true 
  proxy_protocol = false 
  enable_authn = true 
  max_connections = infinity 
}

问题

以上是环境,这部分会部署,但是现在我们现场遇到了一种问题,而且是偶现的,当在部署系统的时候,有一个客户端去连接1883端口,并且订阅主题(因为这个客户端是管设备在线状态的,出现了设备全部离线的情况)

问题总结

客户端连接成功,订阅主题(因之前未去处理监听后qos的值,不晓得是不是真正的订阅成功)

分析记录和日志贴图如下:

  1. 在客户端连接的那个容器内,查询1883端口,是有连接的
    image
  2. 但是在mqtt容器里,查看当前订阅是不存在的
    image
  3. 查看mqtt的日志,发现以下问题
    image
    查找issue,发现有人发出这个: https://askemq.com/t/topic/9241
  4. 而且这种问题是偶现的,不晓得在这种情况下,去监听主题的时候,qos的返回值是多少。是128么?

What did you expect to happen?

是否能在这种情况下,不出现这种偶现的情况

How can we reproduce it (as minimally and precisely as possible)?

No response

Anything else we need to know?

No response

EMQX version

$ ./bin/emqx_ctl broker
# paste output here

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

Log files

@savonarola
Copy link
Contributor

savonarola commented Nov 13, 2024

Hello!

The described situation is not a bug — it happens when EMQX is started, but the authorization system has not yet been fully initialized. During this initialization period, EMQX returns 0x87 code for actions (RC_NOT_AUTHORIZED).

@zhouruiruiruiyan
Copy link
Author

Hello!

The described situation is not a bug — it happens when EMQX is started, but the authorization system has not yet been fully initialized. During this initialization period, EMQX returns 0x87 code for actions (RC_NOT_AUTHORIZED).

那以上问题,只能在我连接时候的根据client.subscribe 的错误码回复去处理了?

@zhouruiruiruiyan
Copy link
Author

Hello!
The described situation is not a bug — it happens when EMQX is started, but the authorization system has not yet been fully initialized. During this initialization period, EMQX returns 0x87 code for actions (RC_NOT_AUTHORIZED).

那以上问题,只能在我连接时候的根据client.subscribe 的错误码回复去处理了?

或者有没有办法缩短从启动端口到emqx正常启动的时间差?
企业微信截图_1732510828758

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants