mqtt的publish写回调就报错

vipbressanon

问题描述

关于mqtt的publish的问题,文档说publish方法是有回调的,我想用回调来监控是否有推送异常的情况,但是我写上回调,就会报错,我是不是哪里写的不对?

程序代码

$mqtt->publish(
$topic,
json_encode($res['data']),
['qos' => 1],
function(\Exception $e){
var_dump($e->getMessage());
}
);

报错信息

TypeError: Argument 1 passed to {closure}() must be an instance of Exception, nu
ll given in D:\workspace\newcloud_report\Listens\Udp\Udp1.php:68

截图报错信息里报错文件相关代码

截图

操作系统及workerman/webman等框架组件具体版本

"workerman/workerman": "^4.0",
"workerman/mqtt": "^1.2",
"predis/predis": "^2.0",
"guanguans/notify": "^1.24",
"workerman/mysql": "^1.0"

894 1 2
1个回答

walkor 打赏
function(\Exception $e){
    var_dump($e->getMessage());
}

改成

function(\Exception $e = null){
    var_dump($e->getMessage());
}
年代过于久远,无法发表回答
×
🔝