curl timeout problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tsg
Forum Contributor
Posts: 142
Joined: Sun Jan 12, 2003 9:22 pm
Location: SE, Alabama
Contact:

curl timeout problems

Post by tsg »

I have a script for a payment processor that works on my server, but not working on another. I am wondering if it is a windows/curl issue.

Here is the function:

Code: Select all

function TransmitHTTPRequest($postRequest){	
			$ch=curl_init($this->_sURL);
			if(!$ch)die(sprintf('Error1 [%d]: %s',curl_errno($ch),curl_error($ch)));
			
			curl_setopt($ch, CURLOPT_POST, 1); 
			curl_setopt($ch, CURLOPT_POSTFIELDS,$postRequest);
			curl_setopt($ch, CURLOPT_HEADER,0);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);	
			curl_setopt($ch, CURLOPT_SSLVERSION,3);
			
			$http_response = curl_exec($ch);
			
			if(!$http_response)die(sprintf('Error2 [%d]: %s',curl_errno($ch),curl_error($ch)));
			curl_close($ch);
			
			if($this->_debug)echo "<BR><BR><b>Data received from server:</b><BR><BR>$http_response";
			return $http_response;
		} //END TransmitHTTPRequest
Keep getting Error2 [28] which is: unable to resolve host , CURLE_OPERATION_TIMEOUTED

Like I said works on my server and other servers, but this one doesn't play nice.

FYI,
Windows NT WEBSERVER 5.2
PHP Version 5.2.0
cURL Information libcurl/7.14.0 OpenSSL/0.9.8d zlib/1.2.3

Any help with this error would be greatly appreciated.

Tim
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

Add the code below after the function deceleration and post here the output:

Code: Select all

echo $this->_sURL;
tsg
Forum Contributor
Posts: 142
Joined: Sun Jan 12, 2003 9:22 pm
Location: SE, Alabama
Contact:

Post by tsg »

That displays the merchant URL for the transaction.

The weird this is I get the timeout error immediately. The timeout is set to 120 .. but as soon as the button to process is clicked, it seems to automatically timeout and get that error.

Does this sound like it's not leaving the server?
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

From what I understand, you have problem in your PHP script (maybe a infinite loop...).
Post Reply