Page 1 of 1

cURL and script shutdown

Posted: Wed May 24, 2006 4:13 am
by ysu
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello everyone.
I'm new here, and already looking for help 

I have a strange and elusive problem. We have an online payment system, which is working fine most of the time...but not always.
I'm using cURL and sometimes (around 20% of the cases) the script does not continue after reaching the curl_exec().

I'm positive it stops there as there's a logging set to log just before and after the exec, as you can see below, and it does not reach the 'after' part in these cases.

The script I'm running has now 270s timeout set just before calling the connection, the curl has 240.
It was less before (1 min) as the gateway guys said their script timeouts in 1 min, it's just a try if they gave me the wrong info by mistake.
Well, it does not seem to be the solution.

I've tried to use the curl connection timeout set as well, no difference.

The biggest problem is that on the other side (the gateway) the transaction is registered and finished ok in these cases.
So the data goes out all right, but I never receive an answer, and the curl timeout does not seem to work either...

All info I think may be relevant:
PHP Version 4.3.11
CURL Information 	libcurl/7.12.0 OpenSSL/0.9.7a zlib/1.1.4
Apache Version 	Apache/1.3.34 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.11 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.7a

The relevant code part:

Code: Select all

$ch = curl_init( $this->myGatewayURL );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $xmlRequest );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt( $ch, CURLOPT_TIMEOUT, 240 );

$startat = date("Y-m-d H:i:s");
$this->writeLog("\nCurlExec start at $startat...");
$xmlResponse = curl_exec( $ch );
$finishedat = date("Y-m-d H:i:s");
$lastlong = strtotime($finishedat) - strtotime($startat);
$this->writeLog("\nCurlexec finished ok at $finishedat (lasted $lastlong)");
My question: do you have any idea what should I try and look for or ask for/from the hosting or the gateway company to solve this mistery?
Any of you had similar probems with curl?
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:1. Select the correct board for your query. Take some time to read the guidelines in the sticky topic.
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Thanks for the help and sorry for the wrong location.