Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608
具体错误信息是 [2023-03-08 11:29:07 $22941.0] WARNING check_worker_exit_status: worker#0[pid=22991] abnormal exit, status=255, signal=0 PHP Fatal error: Uncaught Swlib\Http\Exception\ConnectException: HTTP 110 Unknown: Websocket upgrade failed by [Connection timed out]. in /home/wwwroot/huobiWebsocketPhp/vendor/swlib/saber/src/WebSocket.php:67 Stack trace:
0 /home/wwwroot/huobiWebsocketPhp/vendor/swlib/saber/src/Saber.php(314): Swlib\Saber\WebSocket->__construct()
1 /home/wwwroot/huobiWebsocketPhp/vendor/swlib/saber/src/Saber.php(140): Swlib\Saber->upgrade()
2 /home/wwwroot/huobiWebsocketPhp/vendor/swlib/saber/src/SaberGM.php(101): Swlib\Saber::websocket()
3 /home/wwwroot/huobiWebsocketPhp/src/Websocket.php(238): Swlib\SaberGM::websocket()
4 /home/wwwroot/huobiWebsocketPhp/src/Websocket.php(82): Zwl\HuobiWebsocketPhp\Websocket->connectWs()
5 {main}
thrown in /home/wwwroot/huobiWebsocketPhp/vendor/swlib/saber/src/WebSocket.php on line 67
我的swoole版本 swoole
Swoole => enabled Author => Swoole Team team@swoole.com Version => 4.6.7 Built => Oct 17 2021 18:11:07 coroutine => enabled with boost asm context epoll => enabled eventfd => enabled signalfd => enabled cpu_affinity => enabled spinlock => enabled rwlock => enabled openssl => OpenSSL 1.0.2u 20 Dec 2019 pcre => enabled zlib => 1.2.7 mutex_timedlock => enabled pthread_barrier => enabled futex => enabled async_redis => enabled
Directive => Local Value => Master Value swoole.enable_coroutine => On => On swoole.enable_library => On => On swoole.enable_preemptive_scheduler => Off => Off swoole.display_errors => On => On swoole.use_shortname => On => On swoole.unixsock_buffer_size => 8388608 => 8388608
我的复现代码,我启动了一个ws服务端,然后再onworkerstart的事件里新建了一个协程去连接第三方的wss接口拿数据。 public function construct() { $this->WebServer = new \Swoole\WebSocket\Server($this->ip, $this->port); $this->WebServer->set(array( 'worker_num' => $this->workerNum, // 一般设置为服务器CPU数的1-4倍 'daemonize' => 1, // 是否为守护进程 1,0 'heartbeat_idle_time' => 90, // 客户端心跳时间1 'heartbeat_check_interval' => 45, // 每60秒遍历一次 'log_file' => DIR__.'/swoole.log', // 日志文件信息1 'reload_async' => true, // 设置异步重启开关 'max_wait_time' => 5 // 设置 Worker 进程收到停止服务通知后最大等待时间 ));
public function onWorkerStart(\Swoole\WebSocket\Server $server, int $workerId) {