gpt4 book ai didi

php - cURL 和 SSL,connect() 超时

转载 作者:搜寻专家 更新时间:2023-10-31 21:15:40 25 4
gpt4 key购买 nike

我正在使用 cURL 连接到 SSL 服务器以接收和发送 XML 文件,但我不断收到

"connect() time out!"

当我尝试连接到服务器时。

我是 cURL 的新手,所以我不知道是不是服务器配置、某些证书或其他什么有问题。

我正在尝试运行的代码(由 SSL 服务器的所有者提供给我):

function post($url, $post)
{
$ch = curl_init();
if($ch)
{
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT,60);
curl_setopt($ch, CURLOPT_VERBOSE,0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
echo '<pre>', curl_error($ch);
curl_close($ch);
if(!empty($result))
return $result;
}
}

cURL 版本信息:

[version_number] => 463362
[age] => 3
[features] => 1597
[ssl_version_number] => 0
[version] => 7.18.2
[host] => i486-pc-linux-gnu
[ssl_version] => OpenSSL/0.9.8g
[libz_version] => 1.2.3.3
[protocols] => Array
(
[0] => tftp
[1] => ftp
[2] => telnet
[3] => dict
[4] => ldap
[5] => ldaps
[6] => http
[7] => file
[8] => https
[9] => ftps
[10] => scp
[11] => sftp
)

最佳答案

该消息仅表示 TCP 连接过程在操作允许的时间内未完成。

如果您尝试连接到一个本应在给定端口上通过 TCP 可用的站点,那么您可能会怀疑有防火墙、代理、NAT、路由器或其他设备使它无法正常工作。

这实际上不是与 curl 相关的问题,您应该能够通过例如将 telnet 运行到同一主机 + 端口来验证这一点:“telnet [host] [port]”,因为这也应该会失败。

关于php - cURL 和 SSL,connect() 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9349350/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com