AsyncTcpConnection 進行ws對外服務器進行申請鏈接時
這個鏈接我在mtqqx工具測試是可以鏈接的。
他有賬號密碼之類 不知道是否需要在請求鏈接時發(fā)送 該如何設置參數(shù)
$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,//客戶端向服務端發(fā)送心跳的時間間隔,默認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
linux workman