标题:Swoole 连接 Websocket 发送信息报错
只看楼主
a75692074
Rank: 1
等 级:新手上路
威 望:1
帖 子:48
专家分:0
注 册:2018-7-20
结帖率:100%
 问题点数:0 回复次数:2 
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
markgo
Rank: 2
等 级:论坛游民
帖 子:4
专家分:20
注 册:2021-2-6
得分:0 
Websocket 协议  不是   http协议。
2021-02-06 15:20
LHY163311
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2020-12-3
得分:0 
fFILE *srcFile = fopen(binaryPath, "r");
        if (srcFile == NULL)
        {
            int errNum = 0;
            errNum = errno;
            printf("open fail errno = %d reason = %s \n", errNum, strerror(errNum));
            fprintf(stderr, "Error: Could not open binary %s\n", binaryPath);
            exit(1);
        }
2021-03-09 16:46



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




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

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