可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
basically, this error only occurs in CURL
curl: (56) Recv failure: Connection reset by peer
But when I visit it directly the link directly on my browser, it works!
What are your recommendations on fixing this one or the cause of this error?
Note: the server is coded in ASP and it only occurs on one API Call
回答1:
I remember facing this issue a long time back. While I don't remember what exactly sorted the issue, but I remember trying the following:
1) I was trying to pass the query parameters in the url directly and I tried passing through POST method
2) I tried using a proxy with curl to see if I was possibly being blocked by the other server
3) I believe I also asked my host to look into it and they made some Apache setting changes
回答2:
I resolved this issue by removing whitespace characters from the URL. In my situation, it was the proxy server that was erroring out, not the web server.
In PHP:
curl_setopt($ch, CURLOPT_URL, trim($url));
回答3:
I had similar problem with this code:
$url = "http://xxx.xxx.xxx.xxx"; $ch = curl_init(); curl_setopt($ch, CURLOPT_PORT, 44455); //Set the port to connect to //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 44455); curl_setopt($ch, CURLOPT_URL, $url); echo $xml = curl_exec($ch); if(curl_errno($ch)) { echo 'error:' . curl_error($ch); } curl_close($ch);
Got it solved by disabling this:
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 44455);