Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CURLE_RECV_ERROR 56 when trying to open a url with proxy

Tags:

php

curl

libcurl

I have been trying to send curl requests with a proxy. When I send such requests with a POST method, it works fine, but it doesn't work with GET method and I get:

CURLE_RECV_ERROR (56) - Failure when receiving data from the peer.

Any possible reason why that occurs?

The below code returns this error whereas when I execute it with another url using POST METHOD it works fine.

$handle = curl_init($url);
curl_setopt($handle, CURLOPT_POST          , 0);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_HEADER        , 1);
curl_setopt($handle, CURLOPT_MAXREDIRS     , 5);
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($handle, CURLOPT_USERAGENT     , 'Mozilla/5.0 (Windows; U; Windows NT   5.1; en-GB; rv:1.9.1.4) Gecko/20091016 Firefox/3.5.4');
// curl_setopt($handle, CURLOPT_POSTFIELDS    , "gender=M");
curl_setopt($handle,CURLOPT_PROXY          , $proxyUrl);
curl_setopt($handle,CURLOPT_PROXYUSERPWD   , $urlProxyUserPwd);

echo curl_exec($handle);
like image 989
user1085195 Avatar asked Dec 09 '11 10:12

user1085195


1 Answers

If you get the error message Unable to retrieve feed: cURL error 56: Recv failure: Connection reset by peer while processing feeds, this is due to the network connection being closed while your script is trying to retrieve a response from a remote server.

Can you increase the timeout on the server side(if server is urs)?

like image 185
Eswar Rajesh Pinapala Avatar answered Oct 05 '22 09:10

Eswar Rajesh Pinapala