Closed
Description
PHP&Swoole 版本
PHP 8.2.28 (cli) (built: Mar 11 2025 17:58:12) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.28, Copyright (c) Zend Technologies
with Zend OPcache v8.2.28, Copyright (c), by Zend Technologies
swoole
Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 6.0.2
Built => May 27 2025 09:11:27
coroutine => enabled with boost asm context
kqueue => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.1.1v 1 Aug 2023
dtls => enabled
http2 => enabled
json => enabled
curl-native => enabled
curl-version => 8.13.0
zlib => 1.2.12
brotli => E16781312/D16781312
zstd => 1.5.7
mysqlnd => enabled
Directive => Local Value => Master Value
swoole.enable_library => On => On
swoole.enable_fiber_mock => Off => Off
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 262144 => 262144
代码
// test.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Swoole\Coroutine;
use function Swoole\Coroutine\run;
run(function () {
Coroutine::create(function(){
$client = new \GuzzleHttp\Client();
$response = $client->get('https://httpbin.org/stream/20', [
'stream' => true,
]);
$body = $response->getBody();
while (!$body->eof()) {
echo $body->read(1024);
}
});
});
运行
php test.php
错误
PHP Fatal error: Uncaught GuzzleHttp\Exception\ConnectException: Connection refused for URI https://httpbin.org/stream/20 in /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php:341
Stack trace:
#0 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php(254): GuzzleHttp\Handler\StreamHandler->GuzzleHttp\Handler\{closure}()
#1 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php(335): GuzzleHttp\Handler\StreamHandler->createResource(Object(Closure))
#2 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php(70): GuzzleHttp\Handler\StreamHandler->createStream(Object(GuzzleHttp\Psr7\Request), Array)
#3 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(48): GuzzleHttp\Handler\StreamHandler->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#4 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php(35): GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#5 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Middleware.php(31): GuzzleHttp\PrepareBodyMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#6 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(71): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#7 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\RedirectMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#8 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/HandlerStack.php(75): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#9 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Client.php(333): GuzzleHttp\HandlerStack->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#10 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Client.php(169): GuzzleHttp\Client->transfer(Object(GuzzleHttp\Psr7\Request), Array)
#11 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Client.php(189): GuzzleHttp\Client->requestAsync('GET', Object(GuzzleHttp\Psr7\Uri), Array)
#12 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/ClientTrait.php(44): GuzzleHttp\Client->request('GET', 'https://httpbin...', Array)
#13 /Users/hdj/github/huangdijia/odin-demo/test.php(11): GuzzleHttp\Client->get('https://httpbin...', Array)
#14 [internal function]: {closure}()
#15 {main}
Next GuzzleHttp\Exception\ConnectException: Connection refused for URI https://httpbin.org/stream/20 in /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php:84
Stack trace:
#0 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(48): GuzzleHttp\Handler\StreamHandler->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#1 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php(35): GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#2 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Middleware.php(31): GuzzleHttp\PrepareBodyMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#3 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(71): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#4 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\RedirectMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#5 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/HandlerStack.php(75): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#6 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Client.php(333): GuzzleHttp\HandlerStack->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#7 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Client.php(169): GuzzleHttp\Client->transfer(Object(GuzzleHttp\Psr7\Request), Array)
#8 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Client.php(189): GuzzleHttp\Client->requestAsync('GET', Object(GuzzleHttp\Psr7\Uri), Array)
#9 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/ClientTrait.php(44): GuzzleHttp\Client->request('GET', 'https://httpbin...', Array)
#10 /Users/hdj/github/huangdijia/odin-demo/test.php(11): GuzzleHttp\Client->get('https://httpbin...', Array)
#11 [internal function]: {closure}()
#12 {main}
thrown in /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 84
Fatal error: Uncaught GuzzleHttp\Exception\ConnectException: Connection refused for URI https://httpbin.org/stream/20 in /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php:341
Stack trace:
#0 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php(254): GuzzleHttp\Handler\StreamHandler->GuzzleHttp\Handler\{closure}()
#1 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php(335): GuzzleHttp\Handler\StreamHandler->createResource(Object(Closure))
#2 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php(70): GuzzleHttp\Handler\StreamHandler->createStream(Object(GuzzleHttp\Psr7\Request), Array)
#3 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(48): GuzzleHttp\Handler\StreamHandler->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#4 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php(35): GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#5 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Middleware.php(31): GuzzleHttp\PrepareBodyMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#6 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(71): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#7 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\RedirectMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#8 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/HandlerStack.php(75): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#9 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Client.php(333): GuzzleHttp\HandlerStack->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#10 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Client.php(169): GuzzleHttp\Client->transfer(Object(GuzzleHttp\Psr7\Request), Array)
#11 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Client.php(189): GuzzleHttp\Client->requestAsync('GET', Object(GuzzleHttp\Psr7\Uri), Array)
#12 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/ClientTrait.php(44): GuzzleHttp\Client->request('GET', 'https://httpbin...', Array)
#13 /Users/hdj/github/huangdijia/odin-demo/test.php(11): GuzzleHttp\Client->get('https://httpbin...', Array)
#14 [internal function]: {closure}()
#15 {main}
Next GuzzleHttp\Exception\ConnectException: Connection refused for URI https://httpbin.org/stream/20 in /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php:84
Stack trace:
#0 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(48): GuzzleHttp\Handler\StreamHandler->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#1 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php(35): GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#2 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Middleware.php(31): GuzzleHttp\PrepareBodyMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#3 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(71): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#4 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\RedirectMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#5 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/HandlerStack.php(75): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#6 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Client.php(333): GuzzleHttp\HandlerStack->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#7 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Client.php(169): GuzzleHttp\Client->transfer(Object(GuzzleHttp\Psr7\Request), Array)
#8 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Client.php(189): GuzzleHttp\Client->requestAsync('GET', Object(GuzzleHttp\Psr7\Uri), Array)
#9 /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/ClientTrait.php(44): GuzzleHttp\Client->request('GET', 'https://httpbin...', Array)
#10 /Users/hdj/github/huangdijia/odin-demo/test.php(11): GuzzleHttp\Client->get('https://httpbin...', Array)
#11 [internal function]: {closure}()
#12 {main}
thrown in /Users/hdj/github/huangdijia/odin-demo/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 84