mqtt 问题

zhou2021

在 $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

怎么解决呢? 谢谢您

3506 2 0
2个回答

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

  • 暂无评论
年代过于久远,无法发表回答
×
🔝