首页
下载
文档
问答社区
视频
捐赠
源代码
AI 助理
赞助商
CRMEB
Apipost
腾讯云
微擎
禅道
51Talk
商业产品
Swoole AI 智能文档翻译器
Swoole-Compiler PHP 代码加密器
CRMEB 新零售社交电商系统
登录
注册
全部
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
发表新帖
SwooleError: cURL
### 问题描述 Uncaught Swoole\Error: cURL is executing, cannot be operated in vendor/symfony/http-client/Response/CurlResponse.php:90 ### Swoole版本,PHP版本,以及操作系统版本信息 PHP 7.4.16 Swoole => enabled Author => Swoole Team <team@swoole.com> Version => 4.6.6 Built => May 11 2021 15:41:19 coroutine => enabled with boost asm context epoll => enabled eventfd => enabled signalfd => enabled cpu_affinity => enabled spinlock => enabled rwlock => enabled openssl => OpenSSL 1.1.0l 10 Sep 2019 dtls => enabled curl-native => enabled pcre => enabled zlib => 1.2.8 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 => Off => Off swoole.unixsock_buffer_size => 8388608 => 8388608 ### 相关代码 ```php curl_setopt($ch, \CURLOPT_HEADERFUNCTION, static function ($ch, string $data) use (&$info, &$headers, $options, $multi, $id, &$location, $resolveRedirect, $logger): int { if (0 !== substr_compare($data, "\r\n", -2)) { return 0; } $len = 0; foreach (explode("\r\n", substr($data, 0, -2)) as $data) { $len += 2 + self::parseHeaderLine($ch, $data, $info, $headers, $options, $multi, $id, $location, $resolveRedirect, $logger); } return $len; }); ``` composer.json ```json { "require": { "ext-json": "*", "ext-mbstring": "*", "guzzlehttp/promises": "^1.4", "guzzlehttp/psr7": "^1.7", "php-http/async-client-implementation": "^1.0", "php-http/client-common": "^1.5|^2.0", "php-http/discovery": "^1.6.1", "php-http/httplug": "^1.1|^2.0", "php-http/message": "^1.5", "psr/http-factory": "^1.0", "symfony/http-client": "*", "nyholm/psr7": "^1.4" }, "require-dev": { "swoole/ide-helper": "^4.5" } } ``` 测试代码 <?php require __DIR__ . '/vendor/autoload.php'; use Symfony\Component\HttpClient\HttpClient as SymfonyHttpClient; use Symfony\Component\HttpClient\HttplugClient as SymfonyHttplugClient; use Http\Client\Common\PluginClient; use Http\Discovery\Psr17FactoryDiscovery; Swoole\Coroutine\run(function() { Swoole\Coroutine::create(function () { $httpClient = new SymfonyHttplugClient( SymfonyHttpClient::create(['max_duration' => 5]) ); $req = Psr17FactoryDiscovery::findRequestFactory() ->createRequest('POST', 'http://127.0.0.1') ->withHeader('Content-Type', 'application/json') ->withBody(Psr17FactoryDiscovery::findStreamFactory()->createStream('test')); $res = (new PluginClient($httpClient))->sendAsyncRequest($req)->wait(); var_dump($res); }); });
发布于3年前 · 4 次浏览 · 来自
提问
wickyhe
### 问题描述 Uncaught Swoole\Error: cURL is executing, cannot be operated in vendor/symfony/http-client/Response/CurlResponse.php:90 ### Swoole版本,PHP版本,以及操作系统版本信息 PHP 7.4.16 Swoole => enabled Author => Swoole Team <team@swoole.com> Version => 4.6.6 Built => May 11 2021 15:41:19 coroutine => enabled with boost asm context epoll => enabled eventfd => enabled signalfd => enabled cpu_affinity => enabled spinlock => enabled rwlock => enabled openssl => OpenSSL 1.1.0l 10 Sep 2019 dtls => enabled curl-native => enabled pcre => enabled zlib => 1.2.8 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 => Off => Off swoole.unixsock_buffer_size => 8388608 => 8388608 ### 相关代码 ```php curl_setopt($ch, \CURLOPT_HEADERFUNCTION, static function ($ch, string $data) use (&$info, &$headers, $options, $multi, $id, &$location, $resolveRedirect, $logger): int { if (0 !== substr_compare($data, "\r\n", -2)) { return 0; } $len = 0; foreach (explode("\r\n", substr($data, 0, -2)) as $data) { $len += 2 + self::parseHeaderLine($ch, $data, $info, $headers, $options, $multi, $id, $location, $resolveRedirect, $logger); } return $len; }); ``` composer.json ```json { "require": { "ext-json": "*", "ext-mbstring": "*", "guzzlehttp/promises": "^1.4", "guzzlehttp/psr7": "^1.7", "php-http/async-client-implementation": "^1.0", "php-http/client-common": "^1.5|^2.0", "php-http/discovery": "^1.6.1", "php-http/httplug": "^1.1|^2.0", "php-http/message": "^1.5", "psr/http-factory": "^1.0", "symfony/http-client": "*", "nyholm/psr7": "^1.4" }, "require-dev": { "swoole/ide-helper": "^4.5" } } ``` 测试代码 <?php require __DIR__ . '/vendor/autoload.php'; use Symfony\Component\HttpClient\HttpClient as SymfonyHttpClient; use Symfony\Component\HttpClient\HttplugClient as SymfonyHttplugClient; use Http\Client\Common\PluginClient; use Http\Discovery\Psr17FactoryDiscovery; Swoole\Coroutine\run(function() { Swoole\Coroutine::create(function () { $httpClient = new SymfonyHttplugClient( SymfonyHttpClient::create(['max_duration' => 5]) ); $req = Psr17FactoryDiscovery::findRequestFactory() ->createRequest('POST', 'http://127.0.0.1') ->withHeader('Content-Type', 'application/json') ->withBody(Psr17FactoryDiscovery::findStreamFactory()->createStream('test')); $res = (new PluginClient($httpClient))->sendAsyncRequest($req)->wait(); var_dump($res); }); });
赞
0
分享
收藏
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
评论
2021-05-12
鲁飞
前往 https://github.com/swoole/swoole-src/issues/4200 查看
赞
0
回复
微信公众号
热门内容
作者其它话题
- swoole 4.5.7 如何禁用 curl hook ?
暂无回复的问答
- CodeGalaxy K3s 轻量集群节点之间如何实现负载均衡
- 关于openssl CURL WARNING swSSL_connect: SSL_connect(fd=69) failed. Error: error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small[1|394]
- 多个模型如何进行事务异常回退?
- websocket开启wss报错
- 协程tcp服务器如何使用多进程?recv()方法接收信息,打印出来的pid一直是同一个。没用使用到多进程啊。