Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error 28 timed out! PHP

Tags:

php

curl

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?

like image 345
Mandar Chitale Avatar asked Mar 19 '26 12:03

Mandar Chitale


1 Answers

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'); 
//       -------^
like image 81
Daniel W. Avatar answered Mar 22 '26 01:03

Daniel W.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!