白同学 发表于 2021/7/16 21:49

Failed connect to xxx.com:443; No route to host

thinkphp3.2.3

curl post 报错:Failed connect to xxx.com:443; No route to host

代码:
$this->postRequest($postUrl, http_build_query(['data'=>json_encode($params)]), [
            'CURLOPT_FOLLOWLOCATION' => true,
            'CURLOPT_SSL_VERIFYHOST' => false,
      ]);


    protected function postRequest($url, $params, $opt = []) {
      $curl = Curl::init();
      $curl->retry(3)->set($opt)->post($params)->url($url);
      if ($curl->error()) {
            throw new \Exception("curl error: ".$curl->message());
      } else {
            $info = $curl->info();
            if ($info['http_code'] != 200) {
                throw new \Exception("Unexpected HTTP code: \n".print_r($info, true));
            }
            return $curl;
      }
    }

白同学 发表于 2021/7/16 21:57

@小樱
快来看看

小樱 发表于 2021/7/17 00:36

用telnet 测试一下443端口通不通,看你提供的信息是响应No route to host,可能是被受请求方的服务器防火墙拦截了
页: [1]
查看完整版本: Failed connect to xxx.com:443; No route to host