无法连接到谷歌云连接服务器


unable to connect to Google Cloud Connection Server

我试图打开我的服务器和谷歌云连接服务器(CCS)之间的XMPP连接,但它不起作用。我正在用PHP编程,并使用JAXL库。下面是我的代码:

<?php
include_once 'jaxl.php';
$client = new JAXL(array(
     'jid'=>'<my_sender_ID>@gcm.googleapis.com',
     'pass'=>'my_API_key',
     'auth_type'=>'PLAIN',
     'host' => 'gcm.googleapis.com',
     'port' => '5235',
     'force_tls' => true
)); 
$client->start();
echo "done";
?>

然后我得到这个错误:

unable to connect tcp://gcm.googleapis.com:5235 with error no: 110, error str: Connection timed out

我做错了什么?

您应该通过ssl连接gcm.googleapis.com,而不是http或tcp。

我修改了jaxl.php从:

public function get_socket_path() {
    return ($this->cfg['port'] == 5223 ? "ssl" : "tcp")."://".$this->cfg['host'].":".$this->cfg['port'];
}

:

public function get_socket_path() {
    return ($this->cfg['port'] == 5223 || $this->cfg['ssl'] == true ? "ssl" : "tcp")."://".$this->cfg['host'].":".$this->cfg['port'];
}

之后,你可以初始化客户端:

$client = new JAXL(array(
    'jid' => '<your-API-key>@gcm.googleapis.com',
    'pass' => '<your-API-key>',
    'host' => 'gcm.googleapis.com',
    'port' => 5235,
    'force_tls' => true,
    'auth_type' => 'PLAIN',
    'strict' => FALSE,
    'ssl' => TRUE
));

另外,在初始化客户端时,使用

'log_level' => JAXL_DEBUG

这将允许您看到所有正在发送或正在接收的内容。在我的情况下,我发现我的项目还没有被列入白名单——我忘记在https://services.google.com/fb/forms/gcm/

上注册了。
jaxl_socket_client:189 - 2013-10-04 08:11:58 - <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><temporary-auth-failure/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Project 1012343798740 not whitelisted.</text></failure>

也许您应该将host更改为http://gcm.googleapis.com。您的错误提示"无法连接tcp://gcm.googleapis.com:5235"。

GCM云连接服务器(CCS)是一个XMPP端点,运行在http://gcm.googleapis.com端口5235上。