dongyan3018 2012-02-19 12:58
浏览 189
已采纳

cURL和SSL,connect()超时

I'm using cURL to connect to a SSL server to recive and send XML-files but I keep getting

"connect() time out!"

when I try to connect to the server.

I'm kind of new to cURL so I don't know if it's something wrong with the servers configuration, some certificate, or what.

The code i'm trying to run (given to me by the owner of the SSL server):

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 information:

[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
    )
  • 写回答

1条回答 默认 最新

  • doutui839638 2012-02-19 22:43
    关注

    The message simply means that the TCP connect procedure hasn't completed without the time allowed for the operation.

    If you try to connect to a site that should be available over TCP on the given port then you can suspect that there's a firewall, proxy, NAT, router or other equipment in the way that makes it not work for you.

    This is not really a curl related problem and you should be able to verify this by for example running telnet to the same host + port: "telnet [host] [port]" as that should also fail.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥15 vba使用jmail发送邮件正文里面怎么加图片
  • ¥15 vb6.0如何向数据库中添加自动生成的字段数据。