无法连接到 Google Cloud 连接服务器 [英] unable to connect to Google Cloud Connection Server

查看:68
本文介绍了无法连接到 Google Cloud 连接服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的服务器和 Google 云连接服务器 (CCS) 之间打开 XMPP 连接,但它不起作用.我正在使用 PHP 进行编程并使用 JAXL 库.这是我的代码:

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";
?>

然后我收到此错误:

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

我做错了什么?

推荐答案

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

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

这篇关于无法连接到 Google Cloud 连接服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆