mahaiyin
  • 4
  • 新人请关照

有用户连接时报错,怎么解决啊

$server = new Swoole\WebSocket\Server('0.0.0.0', 8899);
$server->on('open', function ($server, $req) {
});
$server->on('message', function ($server, $frame) {
    $server->push($frame->fd, $frame->data);
});
$server->on('WorkerStart', function ($server, $worker_id) {
    while (true) {
        foreach ($server->connections as $fd) {
            $server->push($fd, '111111111111');
        }
    }
});
$server->on('close', function ($s, $fd) {
});
$server->start();
Warning: SwooleWebSocketServer::push(): the connected client of connection[1] is not a websocket client or closed in /obj/server.php on line 12
PHP Warning: SwooleWebSocketServer::push(): the connected client of connection[1] is not a websocket client or closed in /obj/server.php on line 12
阅读 301
评论 2019-11-15 提问
    4 个回答
    Sgenmi
    • 1
    • 新人请关照

    可能是没有心跳,断开了。

    评论 赞赏 2019-12-24