phpsocket.io 的一个$request变量中找不到$res的问题

0

详细描述:


.现在是运行一个phpsocket.io的demo
启动没问题,是当客户端第一次访问的时候开始报错。
抛出错误的代码路径是vendor/workerman/phpsocket.io/src/Engine/Transports/Polling.php 的14行


部分错误栈:


PHP Notice:  Undefined property: PHPSocketIO\Engine\Protocols\Http\Request::$res in ~/work/im/ioim.sscf.com/vendor/workerman/phpsocket.io/src/Engine/Transports/Polling.php on line 14

Notice: Undefined property: PHPSocketIO\Engine\Protocols\Http\Request::$res in ~/work/im/ioim.sscf.com/vendor/workerman/phpsocket.io/src/Engine/Transports/Polling.php on line 14
exception 'Exception' with message 'empty this->res' in ~/work/im/ioim.sscf.com/vendor/workerman/phpsocket.io/src/Engine/Transports/PollingXHR.php:45
Stack trace:
#0 ~/work/im/ioim.sscf.com/vendor/workerman/phpsocket.io/src/Engine/Transports/Polling.php(181): PHPSocketIO\Engine\Transports\PollingXHR->doWrite('\x00\x01\x00\x00\xFF0{"sid":"1...')
#1 ~/work/im/ioim.sscf.com/vendor/workerman/phpsocket.io/src/Engine/Transports/Polling.php(176): PHPSocketIO\Engine\Transports\Polling->write('\x00\x01\x00\x00\xFF0{"sid":"1...')
#2 ~/work/im/ioim.sscf.com/vendor/workerman/phpsocket.io/src/Engine/Socket.php(312): PHPSocketIO\Engine\Transports\Polling->send(Array)
#3 : PHPSocketIO\Engine\Socket->flush()

尝试:
因为在看代码的时候发现前面的其实是由一个res的,_于是尝试把对应的res赋值给request_;但此时却发现客户端出现另外一个错误。failed: Error during WebSocket handshake: Unexpected response code: 200


修改位置:
vendor/workerman/phpsocket.io/src/Engine/Engine.php 的255行
添加的代码是:
$req->res = $res;

已邀请:

walkor

赞同来自: chentf

直接
var socket = io('http://127.0.0.1:8083');
试下

walkor

赞同来自:

是什么socket.io客户端?js?

chentf - 90后IT男

赞同来自:

如果在使用var socket = io('http://127.0.0.1:8083'); 后端代码是没什么问题的。。。也不再存在出现变量不存在的问题了。。

要回复问题请先登录注册