我试图打开我的服务器和谷歌云连接服务器(CCS)之间的XMPP连接,但它doesn't工作。 I'm编程采用PHP和JAXL库。这是我的code:
I'm trying to open a XMPP connection between my server and the Google Cloud Connection Server (CCS), but it doesn´t work. I´m programming with PHP and using the JAXL library. Here is my code:
<?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";
?>
然后,我得到这个错误:
And then I get this error:
unable to connect tcp://gcm.googleapis.com:5235 with error no: 110, error str: Connection timed out
我是什么做错了吗?
what am I doing wrong?
您应该连接到gcm.googleapis.com通过SSL,而不是HTTP或TCP。
You should connect to gcm.googleapis.com by ssl, not http or tcp.
我通过修改jaxl.php解决了这个问题
I fixed this by modifying jaxl.php from:
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'];
}
之后,你可以初始化客户端:
After that you can initialize the client with:
$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
));