如果curl getinfo为HTTP CODE不返回代码? [英] if curl getinfo for HTTP CODE is not returning a code?
问题描述
我正在对web服务进行正常的curl调用,并通过
I am doing a normal curl call to a webservice and I grab the return HTTP code through
$code = curl_getinfo ($ch, CURLINFO_HTTP_CODE);
它返回$ code为200 - 这是好的。
但是记录curl调用现在从一个星期,那里几乎没有调用到同一个webservice没有返回任何东西!所以基本上我得到$代码为空白。
It does return me $code as 200 - which is good. But logging the curl calls now from a week, there where few calls to the same webservice which didn't return anything! so basically I am getting $code as blank.
有人可以告诉我什么应该在这些情况下出现错误,如果可以调试它更多!
Can someone tell me what should be going wrong under those scenarios, and if can debug it more!?
感谢,
Tanmay
Thanks, Tanmay
------------- ----------更新-------------------------
-----------------------Update-------------------------
感谢大家的信息。是的,我也在想,一样,它没有达到服务器。我将更新我的代码,以获得curl_error&&
Thanks everyone for the info. Yes I was also thinking the same, its not reaching the server. I will update my code with to get curl_error && curl_errno and will update you guys soon.
再次感谢。
--------- ------------- Update 2 ----------------------------------- ----------------------
我没有更新我的代码,返回我的错误没有7 - 无法连接到主机。
我没有记录所有的curl调用,所以基本上约90-98%的curl调用执行良好。但只有1-2%的curl调用不能找到主机!任何人都可以告诉我什么可能是原因?
---------------------- Update 2--------------------------------------------------------- I did update my code to return me the error no 7 - couldn't connect to host. I did logged all the curl calls, so basically around 90-98% of curl calls are executing good. But only 1-2% of curl calls are not able to find the host! Can anyone tell me what could be the reason? and How I can prevent it?
推荐答案
再次感谢
Tanmay
如果cURL HTTP代码没有返回任何东西(也就是0),这意味着cURL操作由于某种原因失败。捕获您的日志中的 curl_error
将是有益的,以及它可能会给你更多的洞察在这些情况下发生(如果他们再次发生)。
If the cURL HTTP code returned nothing (aka '0'), that means the cURL operation failed for some reason. It would be beneficial to capture the curl_error
in your logs as well as it might give you more insight to was happened in those cases (if they happen again).
这篇关于如果curl getinfo为HTTP CODE不返回代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!