Swoole 连接 Websocket 发送信息报错
程序代码:
<?php $server = new Swoole\Websocket\Server("127.0.0.1", 9502); $server->on('open', function($server, $req) { echo "connection open: {$req->fd}\n"; }); $server->on('message', function($server, $frame) { echo "received message: {$frame->data}\n"; $server->push($frame->fd, json_encode(["hello", "world"])); }); $server->on('close', function($server, $fd) { echo "connection close: {$fd}\n"; }); $server->start();
打开浏览器运行 127.0.0.1:9502 报错
HTTP 400 Bad Request
——————————————————————————————————————————
Powered by Swoole
——————————————————————————————————————————
Powered by Swoole
终端返回:connection close: 1
[此贴子已经被作者于2020-8-30 17:50编辑过]