首頁 >後端開發 >php教程 >客戶端WebSocket報錯! failed: Invalid frame header

客戶端WebSocket報錯! failed: Invalid frame header

WBOY
WBOY原創
2016-08-20 08:48:315924瀏覽

客戶端WebSocket報錯! failed: Invalid frame header

伺服器程式碼(用了swoole)

<code>$serv = new swoole_websocket_server("**********", 9502);

$serv->on('Open', function($server, $req) {
    echo "connection open: ".$req->fd;
});

$serv->on('Message', function($server, $frame) {
    echo "message: ".$frame->data;
    $server->push($frame->fd, json_encode(["hello", "world"]));
});

$serv->on('Close', function($server, $fd) {
    echo "connection close: ".$fd;
});

$serv->start();
</code>
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn