V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
lcy630409
V2EX  ›  PHP

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

  •  
  •   lcy630409 · 2022-07-25 15:22:11 +08:00 · 1347 次点击
    这是一个创建于 612 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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 还是出现问题~~~~
    2 条回复    2022-07-26 11:12:09 +08:00
    weiqk
        1
    weiqk  
       2022-07-26 09:05:22 +08:00 via Android   ❤️ 1
    常规错误
    lcy630409
        2
    lcy630409  
    OP
       2022-07-26 11:12:09 +08:00
    @weiqk
    感谢回复
    最终解决办法:去掉了 CURLOPT_USERAGENT ,,,
    怀疑是机房网络有代理过滤
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1638 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 16:49 · PVG 00:49 · LAX 09:49 · JFK 12:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.