mqtt 问题

0

在 $worker = new Worker(); 里面创建两个


$mqtt = new Workerman\Mqtt\Client()
$mqtt_to = new Workerman\Mqtt\Client()


导致错误
Warning: Cannot declare class \Workerman\Protocols\Mqtt, because the name is already in use in E:\iot_gateway\vendor\workerman\mqtt\src\Client.php
on line 185


怎么解决呢? 谢谢您

已邀请:

zhou2021

赞同来自:

$mqtt = new Workerman\Mqtt\Client('*********', $options);
$mqtt->onConnect = function() use ($mqtt, $file_name) {
$mqtt->subscribe('/001/+/+');
};

$mqtt_to = new Workerman\Mqtt\Client('**********', $options_to);
$mqtt_to->onConnect = function() use ($mqtt_to, $file_name) {
//$mqtt_to->subscribe('/001/+/+');
};

walkor

赞同来自:

已经修复。更新workerman/mqtt 到1.1或者后续更高版本


composer require workerman/mqtt ^1.1

要回复问题请先登录注册