Hello everyone.
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.
The curl timeout was less before (80 sec) as the gateway company said their script timeouts in 1 min. There was a 20 sec connection timeout on it as well.
This now is a try to see if there's extra time needed for any reason. Well, it does not seem to be the solution.
I've tried to use the curl connection timeout set as well (20sec), 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 sometimes I don't 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 parts:
error_reporting(0);
ignore_user_abort(1);
set_time_limit(270);
$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?