Failed connect to xxx.com:443; No route to host
thinkphp3.2.3curl 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;
}
} @小樱
快来看看 用telnet 测试一下443端口通不通,看你提供的信息是响应No route to host,可能是被受请求方的服务器防火墙拦截了
页:
[1]