Reputation: 700
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
Upvotes: 12
Views: 65612
Reputation: 552
I remember facing the same issue a long time back. While I don't remember what exactly sorted out the issue, I remember trying the following:
I was trying to pass the query parameters in the URL directly and I tried passing through POST method
I tried using a proxy with curl to see if I was possibly being blocked by the other server
I believe I also asked my host to look into it and they made some Apache setting changes
Upvotes: 4
Reputation: 654
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);
Upvotes: 0
Reputation: 6117
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));
Upvotes: 5