欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-04-29 11:14:20
...

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

服务器代码(用了swoole)

$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();