标题:Swoole 连接 Websocket 发送信息报错
取消只看楼主
a75692074
Rank: 1
等 级:新手上路
威 望:1
帖 子:48
专家分:0
注 册:2018-7-20
结帖率:100%
 问题点数:0 回复次数:0 
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

终端返回:connection close: 1

[此贴子已经被作者于2020-8-30 17:50编辑过]

搜索更多相关主题的帖子: connection close 连接 server 报错 
2020-08-30 17:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-503005-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.603428 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved