我尝试在我的服务器和 Google Cloud 连接服务器 (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'];
}
to:
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
));
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)