Yurunsoft / Guzzle-Swoole

让基于 Guzzle 的项目完美无缝兼容 Swoole 协程,支持:Guzzle、Elasticsearch client——来自宇润 PHP 全家桶
MIT License
161 stars 21 forks source link

Connection timed out #27

Closed hjw1799 closed 2 years ago

hjw1799 commented 3 years ago

Connect failed: errorCode: 110, errorMessage: Connection timed out,位于xxx/vendor/yurunsoft/guzzle-swoole/src/SwooleHandler.php:126, 请问这个可以从哪方便去排查,偶现的

Yurunsoft commented 3 years ago

网络原因,超时,超时时间设置得大一些

hjw1799 commented 3 years ago

网络原因,超时,超时时间设置得大一些

new Client([ 'base_uri' => 'www.baidu.com', 'timeout' => 2.0, ]); 就guzzle这样加timeout就好吗

Yurunsoft commented 3 years ago

就用guzzle的写法,2秒也太短了,加大

hjw1799 commented 3 years ago

就用guzzle的写法,2秒也太短了,加大

好的,下午我尝试一下,然后给出效果反馈, 先多谢指点

hjw1799 commented 3 years ago

就用guzzle的写法,2秒也太短了,加大

好的,下午我尝试一下,然后给出效果反馈, 先多谢指点

就用guzzle的写法,2秒也太短了,加大

我注意到我项目guzzle是没设置超时时间的,也就是默认值0,但还是出现了这种情况

Yurunsoft commented 3 years ago

升级swoole或者尝试增加超时时间,timeout只可能是网络问题或者接口返回比较慢

hjw1799 commented 3 years ago

swoole

Swoole => enabled Author => Swoole Team team@swoole.com Version => 4.4.19 Built => Sep 1 2021 19:45:06 coroutine => enabled epoll => enabled eventfd => enabled signalfd => enabled cpu_affinity => enabled spinlock => enabled rwlock => enabled openssl => OpenSSL 1.0.1e-fips 11 Feb 2013 http2 => enabled pcre => enabled zlib => 1.2.3 mutex_timedlock => enabled pthread_barrier => enabled futex => enabled mysqlnd => 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

PHP 7.2.31 (cli)

这是我swoole的版本,很高了

Yurunsoft commented 3 years ago

太古老了,升级吧

hjw1799 commented 3 years ago

太古老了,升级吧

有什么版本推荐吗

Yurunsoft commented 3 years ago

老项目如果跑4.4下,可以试试4.4.25,如果新项目建议有多新用多新,目前最新4.8.1

hjw1799 commented 3 years ago

老项目如果跑4.4下,可以试试4.4.25,如果新项目建议有多新用多新,目前最新4.8.1

好的,我尝试一下

hjw1799 commented 3 years ago

老项目如果跑4.4下,可以试试4.4.25,如果新项目建议有多新用多新,目前最新4.8.1

还是没去升级swoole,感觉有点风险,感觉像是短时间建立了太多的的tcp请求,服务端拒绝了服务,errorCode: 110, errorMessage: Connection timed out,目前采用了重试机制,目测还好,不行的话再用令牌看看