使用mqtt组件连接服务端(mqtt的wss协议)报错
$remote_server = new Client('websocket://s.sportnanoapi.com:443', [
'client_id'=>'MqttClient_'.self::msectime(),
'ssl' => true,
'username' => env('NAMI_USER'),
'password' => env('NAMI_SECRET'),
'connect_timeout' => 10,
'keepalive' => 20,
'clean_session' => true,
]);
Exception: You can't send(array) to client, you need to convert it to a string. in /var/www/59hongdan/vendor/workerman/workerman/Protocols/Websocket.php:236
Stack trace:
#0 /var/www/59hongdan/vendor/workerman/workerman/Connection/TcpConnection.php(344): Workerman\Protocols\Websocket::encode(Array, Object(Workerman\Connection\AsyncTcpConnection))
#1 /var/www/59hongdan/vendor/workerman/mqtt/src/Client.php(452): Workerman\Connection\TcpConnection->send(Array)
#2 /var/www/59hongdan/vendor/workerman/workerman/Connection/AsyncTcpConnection.php(345): Workerman\Mqtt\Client->onConnectionConnect(Object(Workerman\Connection\AsyncTcpConnection))
#3 /var/www/59hongdan/vendor/workerman/workerman/Events/Select.php(302): Workerman\Connection\AsyncTcpConnection->checkConnection(Resource id #200)
#4 /var/www/59hongdan/vendor/workerman/workerman/Worker.php(2408): Workerman\Events\Select->loop()
#5 /var/www/59hongdan/vendor/workerman/gateway-worker/src/BusinessWorker.php(197): Workerman\Worker->run()
#6 /var/www/59hongdan/vendor/workerman/workerman/Worker.php(1541): GatewayWorker\BusinessWorker->run()
#7 /var/www/59hongdan/vendor/workerman/workerman/Worker.php(1371): Workerman\Worker::forkOneWorkerForLinux(Object(GatewayWorker\BusinessWorker))
#8 /var/www/59hongdan/vendor/workerman/workerman/Worker.php(1345): Workerman\Worker::forkWorkersForLinux()
2个回答
年代过于久远,无法发表回答
workerman的mqtt客户端目前不支持wss协议。
能推荐下什么简单的替代方案吗?
能推荐下什么简单的替代方案吗?
哥们,你的问题解决了吗?用的什么替代方案呢?