Closed millken closed 6 years ago
我这边测试了,'verify' => false
没有问题
当verify为false时,不会验证证书,怎么会无效呢
嗯,我也测试了下,发现正常使用没用
<?php
require dirname(__DIR__).'/vendor/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
go(function () {
$handler = new GuzzleSwooleHandler();
$stack = HandlerStack::create($handler);
$client = new Client(['handler' => $stack]);
$response = $client->request('GET', 'https://ecs-buy.aliyun.com/api/ecsPrice/describePrice.jsonp', [
'query' => [
'callback' => 'angular.callbacks._6',
'_timestamp' => time(),
'data' => '{"orderType":"instance-buy","regionId":"cn-hangzhou-dg-a01","commodity":{"zoneId":"random","instanceType":"ecs.xn4.small","ioOptimized":true,"networkType":"vpc","internetChargeType":"PayByBandwidth","internetMaxBandwidthOut":1,"imageType":"public","systemDisk":{"category":"cloud_efficiency","size":"40"},"dataDisks":null,"priceUnit":"Month","periodType":"Monthly","period":1,"amount":1,"maxAmount":1,"autoRenew":false}}',
],
'headers' => [
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36',
'Referer' => 'https://ecs-buy.aliyun.com/simple/',
'Accept-Encoding' => 'deflate, br',
'Accept-Language' => 'zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7',
],
'verify' => false,
]);
var_dump($response->getStatusCode(), $response->getBody()->__toString(), $response->getHeaders());
});
但是我是创建了自定义进程,然后在swoole_timer里跑的,这样返回-2 的状态码。 具体我再调试下,谢谢!
https://wiki.swoole.com/wiki/page/726.html
在约定的时间内服务器未返回响应,请求超时,statusCode将设置为-2
应该是超时了,你调试下看看先
刚测试发现,加了'timeout' => 1.0,
就返回正常了,不加的话就会有问题。
了解了,晚点加个默认timeout
最新版中已经修复这个问题,guzzle
里timeout
默认为0是不限制超时时间,现在已经支持了
swoole 4.0.3,php 7.2.8
默认是没有问题的