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

MQTT session #7

Open
Jack-laoniu opened this issue Jul 25, 2022 · 0 comments
Open

MQTT session #7

Jack-laoniu opened this issue Jul 25, 2022 · 0 comments

Comments

@Jack-laoniu
Copy link
Owner

Jack-laoniu commented Jul 25, 2022

对于网络不稳定的物联网,MQTT如何减少连接断开之间,资源的消耗

  • 5.0版本使用clean start 与 Session Expiry Interval 分别为 是否开始新的连接,断连后保持连接时间, Session Expiry Interval 可以在断开连接后重新设置
  • 通过这两个变量,客户端在每次 连接服务端时,指定是否需要建立新的连接,客户端在连接服务端时,通过服务端返回的ack报文中的 Session Present 得知上次连接是否保留,如果保留就不用建立新的连接,从而节省资源,不同客户端可以根据自己不同的业务甚至过期时间来控制资源的消耗
  • 对于上层业务来说 ,一个设备是否在在线的判断标准就是是否开启新的连接,因为开启新的订阅是需要传对应的topic,而是用旧的连接则不用,综上我们可以使用Session Present 是否改变,是否存在来判断设备是否在线的依据
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant