cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

php curl_exec stopped

From: Asaf Cohen <asafco4_at_gmail.com>
Date: Mon, 27 May 2013 12:21:01 +0300

Hi,
I'm kinda new to curl in php and I have the following problem:

Once a form in my website is submitted, I start sending post requests to
another web service in a loop.
I need to send large number of requests, up to 300 one after another (not
simultaneously).
All requests are sent to HTTPS address.

everything is working great until certain request just kills the page
loading.
It usually happens after 80-90 requests though it can be sometimes also
after 20-30.
I debugged it and it dies in curl_exec()
(had a debug message before it but the one after didn't show)

Code doesn't have an error as the first requests are doing just fine.

I tried to have sleep after each request, or big sleep after 10 requests
but it didn't help.
I also counted the time until the fall/crash, it's not constant.

I tried to set max_input_time & max_execution_time to 600 (10 minutes),
again, no luck.

Tried also to turn on curl verbose flag and got the output to a file,
didn't see any error message or reason why it stopped.

Any ideas???
Please be very specific as I'm new to this (if you tell me to check error
log, tell me how & where)

My code is written in php, the server is running php 5.3, apache on linux,
hosting provider is godaddy shared hosting plan.
curl version is 17.9.7.

code:
======
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_URL, "https://myurl");
curl_setopt($ch, CURLOPT_POSTFIELDS, "post_field1=value1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, false);

$server_output = curl_exec ($ch); // <------ IT DIES HERE INSIDE
curl_close ($ch);
return $server_output;

Thanks in advance,

AC

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2013-05-27