错误28超时! PHP

时间:2015-09-21 13:18:34

标签: php curl

我正在尝试将信息添加到特定端口号的其余Web服务:8999。在localhost上,它工作正常,但在实时服务器上,它会出现以下错误:

  

cURL错误(28):connect()超时!

这是代码

$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;

有关需要做什么的任何建议?

3 个答案:

答案 0 :(得分:1)

要么在实时系统上有代理, 或者介于两者之间的防火墙。

向您当地的sysop询问有关防火墙的更改。

您还缺少'

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

答案 1 :(得分:0)

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

您的链接也没有回复

答案 2 :(得分:0)

请勿在您的网址中实施您的PORT。单独发送URL和PORT:

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