4

I had a basic Curl script which basically executed a script on remote server. I was working fine from around 6 months.

Yesterday it stopped working, and was giving back following error.

Curl error: Failure when receiving data from the peer

Would like to know if anyone knows on which condition the curl would returned such error?

1 Answer 1

10

When dealing with problem with curl, run it again with:

curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR,  fopen('php://output', 'w'));

Usually the exact error message is in there somewhere.

Fixed: CURLOPT_STDERR indeed needs a stream resource as @Lübnah states in the comments, and @Roman tried to edit in (although earlier reviewers denied the edit, I've now included it in the answer).

Sign up to request clarification or add additional context in comments.

3 Comments

I am already doing your suggestion, and it gives me the error which I mentioned above. Error code : 56. And error printed out in file is : Failure when receiving data from the peer. Thanks for your suggestion though.
Sounds like a TCP problem. What happens if you increase the timeout> And are you sending more headers the just a GET / POST? (i.e. host etc.)? If not, what happens if you add them, and vice-versa?
I had to change the 2nd line to curl_setopt($ch, CURLOPT_STDERR, fopen('php://output', 'w')); before this worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.