Mandar Chitale
Mandar Chitale

Reputation: 41

Error 28 timed out! PHP

I am trying to add information into the rest web service at a particular port number: 8999. On localhost, it is working fine but on the live server, it gives the following error:

cURL Error (28): connect() timed out!

Here is the code

$ch = curl_init('http://int.otono-me.com:8999/api/customers/new'); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);                                                                     
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 50); 
curl_setopt($ch, CURLOPT_PORT, 8999);                                                                     
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
    "Content-Type: application/json",                                                                                
    "X-Auth-Token: " . $_SESSION["Token"]
));                                                                                                                   

$result = curl_exec($ch);
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
if($curl_errno > 0) {
    echo "cURL Error ($curl_errno): $curl_error\n";
} else {
    echo "Successful\n";
}
curl_close($ch);

echo $result;

Any suggestion on what needs to be done?

Upvotes: 3

Views: 5290

Answers (3)

Legionar
Legionar

Reputation: 7607

Don't implement your PORT in your URL. Send separatelly URL and PORT:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://int.otono-me.com/api/customers/new");
curl_setopt($ch, CURLOPT_PORT, 8999);

Upvotes: 0

Daniel W.
Daniel W.

Reputation: 32350

Either you have a proxy on the live system, or a firewall in between.

Ask your local sysop for changes regarding firewall.

You are also missing a ':

$ch = curl_init('http://int.otono-me.com:8999/api/customers/new'); 
//       -------^

Upvotes: 1

Dmitriy Skogorev
Dmitriy Skogorev

Reputation: 189

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://int.otono-me.com:8999/api/customers/new");

also your link is not answering

Upvotes: 0

Related Questions