cURL:操作在0毫秒后超时

编程入门 行业动态 更新时间:2024-10-08 22:47:29
本文介绍了cURL:操作在0毫秒后超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

cURL给我错误:

Operation timed out after 0 milliseconds with 0 out of 0 bytes received

特别是,0毫秒部分是可疑的...

In particular, the "0 milliseconds" part is suspicious...

我的初始化代码:

$curl = curl_init($requestUrl); // private URL not published curl_setopt($curl, CURLOPT_FRESH_CONNECT, true); curl_setopt($curl, CURLINFO_HEADER_OUT, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/xml", "Accept: application/xml")); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 20); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_HTTP200ALIASES, range(400, 599)); curl_setopt($curl, CURLOPT_SSLVERSION, 3); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

超时似乎设置正确,可能有什么关系?

The timeout seems correctly set, what may be related it?

推荐答案

当尝试通过https连接时,我有同样的问题。问题是与ssl版本。 这对我很有用:

I had the same issue, when tried to connect via https. Problem was with ssl version. This worked well for me:

$ch=curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSLVERSION, 3);

更多推荐

cURL:操作在0毫秒后超时

本文发布于:2023-05-31 13:59:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/393009.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:操作   cURL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!