首页 >后端开发 >php教程 >客户端WebSocket报错!failed: Invalid frame header

客户端WebSocket报错!failed: Invalid frame header

WBOY
WBOY原创
2016-08-20 08:48:315938浏览

客户端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