有大佬遇到过么 curl 进行 post 提交数据,突然出现 Operation timed out after 12001 milliseconds with 0 bytes received

2022-07-25 15:22:11 +08:00
 lcy630409
curl:
function juhecardHttpRequesta($url, $params = false, $ispost = 0,$header=false)
{
$httpInfo = [];
$ch = curl_init();

curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($ch, CURLOPT_TIMEOUT, 12);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if($header){
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
}
if ($ispost) {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_URL, $url);
} else {
if ($params) {
curl_setopt($ch, CURLOPT_URL, $url . '?' . $params);
} else {
curl_setopt($ch, CURLOPT_URL, $url);
}
}
$response = curl_exec($ch);
if ($response === FALSE) {
// echo "cURL Error: ".curl_error($ch);
return false;
}
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$httpInfo = array_merge($httpInfo, curl_getinfo($ch));
curl_close($ch);
return $response;
}


一直使用这个提交一个
juhecardHttpRequesta('http://1.1.1.1/orderapi/updateorderok',['order_id'=>$result['orderNo'],'order_status'=>$orderStatus],1);

一直使用正常,但是今天开始,突然出现问题,echo "cURL Error: ".curl_error($ch);的结果就是 Operation timed out after 12001 milliseconds with 0 bytes received ,但是如果你吧 http://1.1.1.1 修改成域名 ,域名也是解析到 1.1.1.1 上 他就好了
换回 ip 还是出现问题~~~~
1384 次点击
所在节点    PHP
2 条回复
weiqk
2022-07-26 09:05:22 +08:00
常规错误
lcy630409
2022-07-26 11:12:09 +08:00
@weiqk
感谢回复
最终解决办法:去掉了 CURLOPT_USERAGENT ,,,
怀疑是机房网络有代理过滤

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/868563

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX