这里写问题描述
帮忙看下这个mqtt的配置,哪里需要优化下呢。现在的问题是可以连接上,也可以成功接收到订阅的话题消息,但是接收到几次以后就接收不到了。mqtt.fx客户端测试又可以一致接收到,所以还是代码上的问题。
$worker = new Worker();
$worker->onWorkerStart = function(){
$mqtt = new \Workerman\Mqtt\Client('mqtt://xx.xx.xx.x:1883', [
'reconnect_period' => 30,
'username' => 'xxx',
'password' => 'yyy',
'clean_session' => false
]);
$mqtt->onConnect = function($mqtt) {
$mqtt->subscribe('mqtt/face/321842/Rec');
};
$mqtt->onMessage = function($topic, $content){
echo date('Y-m-d H:i:s') . "Received message on topic [" .$topic ."]\n";
};
$mqtt->onClose = function () {
echo 'rec::onClose';
};
$mqtt->connect();
};
Worker::runAll();
reconnect_period 这个直接删掉按照默认呢
我试试
要守护进程运行吧