Skip to content

在Swoole协程中报错 #24

@RenLoong

Description

@RenLoong

如果是直接配置了Swoole:

<?php

use Workerman\Events\Swoole;

return [
    'Consumer'  => [
        'handler'     => Webman\RedisQueue\Process\Consumer::class,
        'count'       => 8, // 可以设置多进程同时消费
        'eventLoop' => Swoole::class,
        'constructor' => [
            // 消费者类目录
            'consumer_dir' => base_path('plugin/shortplay/queue')
        ]
    ]
];

那么在启动时报错:

TypeError: swoole_socket_set_option(): Argument #1 ($socket) must be of type Swoole\Coroutine\Socket, Socket given in @swoole-src/library/ext/sockets.php:157
Stack trace:
#0 [internal function]: swoole_socket_set_option()
#1 /home/www/wwwroot/xx/vendor/workerman/workerman/src/Connection/AsyncTcpConnection.php(388): socket_set_option()
#2 /home/www/wwwroot/xx/vendor/workerman/workerman/src/Events/Swoole.php(288): Workerman\Connection\AsyncTcpConnection->checkConnection()
#3 [internal function]: Workerman\Events\Swoole->Workerman\Events\{closure}()
#4 {main}

如果未配置Swoole:

<?php

return [
    'Consumer'  => [
        'handler'     => Webman\RedisQueue\Process\Consumer::class,
        'count'       => 8, // 可以设置多进程同时消费
        'constructor' => [
            // 消费者类目录
            'consumer_dir' => base_path('plugin/shortplay/queue')
        ]
    ]
];

那么在投递时报错:

TypeError: swoole_socket_set_option(): Argument #1 ($socket) must be of type Swoole\Coroutine\Socket, Socket given in @swoole-src/library/ext/sockets.php:157
Stack trace:
#0 [internal function]: swoole_socket_set_option()
#1 /home/www/wwwroot/xx/vendor/workerman/workerman/src/Connection/AsyncTcpConnection.php(388): socket_set_option()
#2 /home/www/wwwroot/xx/vendor/workerman/workerman/src/Events/Swoole.php(288): Workerman\Connection\AsyncTcpConnection->checkConnection()
#3 [internal function]: Workerman\Events\Swoole->Workerman\Events\{closure}()
#4 {main}

webman服务使用Swoole才报错

event-loop proto user worker listen count state
swoole tcp root webman http://0.0.0.0:36300 1 [OK]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions