simps / mqtt

🕹 MQTT Protocol Analysis and Coroutine Client for PHP. Support for 3.1, 3.1.1 and 5.0 versions of the MQTT protocol.
https://mqtt.simps.io
Apache License 2.0
358 stars 58 forks source link

[QUESTION] #90

Closed DancingDream closed 1 year ago

DancingDream commented 1 year ago

大佬,你好。按照腾讯云和现在的库编写的程序,能成功发布消息,但是订阅后接收到的$client->recv()为true,没有消息,想了解下问题出在哪

sy-records commented 1 year ago

应该是断线重连了,maxAttempts设为0,捕获connect异常,重新订阅

DancingDream commented 1 year ago

好的

DancingDream commented 1 year ago

哈喽,大佬,现在又有问题,订阅接收一次消息后,会断开重连,主题会清空。将会话清理设置false,并用qos1重新订阅,再一次接收消息,之后断开不会重新连接。如果将maxAttempts设为0,则会报出“网络未受保护”错误。

sy-records commented 1 year ago

心跳处理需要加上

DancingDream commented 1 year ago

大佬,心跳在config里面就已经设置为20,还需要在哪处理?

sy-records commented 1 year ago

配置是配置,配置了以后需要根据自己逻辑定时ping pong。可以看下示例