windows下开启event扩展使用workerman 作为wss客户端报错

dennlian
2018-06-20 10:04:22 pid:1 Worker process terminated with ERROR: E_ERROR "Uncaught Exception: Expected either valid PHP stream or valid PHP socket resource in F:\E\workspace\201805\hb_cuohe\vendor\workerman\workerman\Events\Event.php:93
Stack trace:
#0 F:\E\workspace\201805\hb_cuohe\vendor\workerman\workerman\Events\Event.php(93): Event->__construct(Object(EventBase), Resource id #48, 18, Array, Resource id #48)
#1 F:\E\workspace\201805\hb_cuohe\vendor\workerman\workerman\Connection\AsyncTcpConnection.php(314): Workerman\Events\Event->add(Resource id #48, 1, Array)
#2 : Workerman\Connection\AsyncTcpConnection->checkConnection(Resource id #48, 4, Resource id #48)
#3 F:\E\workspace\201805\hb_cuohe\vendor\workerman\workerman\Events\Event.php(185): EventBase->loop()
#4 F:\E\workspace\201805\hb_cuohe\vendor\workerman\workerman\Worker.php(2231): Workerman\Events\Event->loop()
#5 F:\E\workspace\201805\hb_cuohe\vendor\workerman\workerman\Worker.php(1221): Workerman\Worker->run()
#6 F:\E\workspace\201805\hb_cuohe\vendor\workerman\workerman\Worker.php(1164): Workerman\Work in F:\E\workspace\201805\hb_cuohe\vendor\workerman\workerman\Events\Event.php on line 93"
4221 3 0
3个回答

walkor 打赏

var_dump 下Resource id #48这个变量,看下是什么类型的资源。

  • dennlian 2018-06-20

    刚开始是正常的,然后不知怎的变成了
    resource(48) of type (stream)
    resource(48) of type (Unknown)

dennlian

刚开始是正常的,然后不知怎的变成了
resource(48) of type (stream)
resource(48) of type (Unknown)
请问是什么造成的呢?

$worker = new Worker();

use \Workerman\Lib\Timer;

$worker->onWorkerStart = function ($worker) {
    // ssl需要访问443端口

    $cons = new AsyncTcpConnection('ws://s2.ripple.com:443');

    // 设置以ssl加密方式访问,使之成为wss
    $cons->transport = 'ssl';

    $connect = false;

    $send_list = false;

    $cons->onConnect = function (AsyncTcpConnection $con)  {
        $connect = true;
        ;
    };

    $cons->onMessage = function (AsyncTcpConnection $con, $data) use ( &$send_list) {

        //DI()->logger->debug(json_encode($data).'3333');
    };

    $cons->onError = function (AsyncTcpConnection $con) use (&$connect, &$send_list) {
        $connect = $send_list = false;
        $con->connect();
    };

    $cons->connect();
};

Worker::runAll();
  • 暂无评论
walkor 打赏

把event扩展去掉试下,有可能是event扩展在windows下的bug。

  • 暂无评论
年代过于久远,无法发表回答
×
🔝