AsyncTcpConnection链接ws报错 返回404

黄先生

问题描述

AsyncTcpConnection 进行ws对外服务器进行申请链接时

这个链接我在mtqqx工具测试是可以链接的。
他有账号密码之类 不知道是否需要在请求链接时发送 该如何设置参数

程序代码

$worker = new Worker();

$worker->onWorkerStart = function($worker){
   $appKey = 'HAKDALDSA';
   $appSecret = '';
   $clientId = 'MqttClient_2010651651654198';
   $username = $appKey;
   $password = '#nnlcwl@wsjdasdj.232316';
   $connectTimeout = 30;
   $keepalive = 630;
   $cleanSession = true;//中断清除会话
   $options = array(
       'keepalive' => $keepalive,//客户端向服务端发送心跳的时间间隔,默认50秒,设置成0代表不启用心跳
       'client_id' => $clientId,//客户端id,如果没设置默认是 "workerman-mqtt-client-".mt_rand()
       'clean_session' => $cleanSession,
       'connect_timeout' => $connectTimeout,
       'username' => $username,
       'password' => $password,
       'path'=>'/mqtt',
       'qos'=>0
   );

    $urls = http_build_query($options);
    $con = new AsyncTcpConnection('ws://***********:8083',$options);
    $con->onConnect = function(AsyncTcpConnection $con) {
        //var_dump($con);
      // $topics = 'system/NNLCWL/dtu/command/push';
     //   $con->send($topics);
    };

    $con->onError = function($con, $code, $msg){
    echo "error: $msg\n";

    };

    $con->onMessage = function(AsyncTcpConnection $con, $data) {

       echo $data;
    };
    $con->connect();
};

Worker::runAll(); 

报错信息

Sec-WebSocket-Accept not found. Header:
HTTP/1.1 404 Not Found
content-length: 0
date: Mon, 20 Feb 2023 10:07:04 GMT
server: Cowboy

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

截图

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

linux workman

870 0 0
0个回答

年代过于久远,无法发表回答
×
🔝