php – 无法连接到Google Cloud Connection Server
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – 无法连接到Google Cloud Connection Server,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1180字,纯文字阅读大概需要2分钟。
内容图文
![php – 无法连接到Google Cloud Connection Server](/upload/InfoBanner/zyjiaocheng/817/23868af200cf4ffcb83a7c90d356e8fc.jpg)
我正在尝试在我的服务器和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
));
内容总结
以上是互联网集市为您收集整理的php – 无法连接到Google Cloud Connection Server全部内容,希望文章能够帮你解决php – 无法连接到Google Cloud Connection Server所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。