【问题标题】:unable to connect to Google Cloud Connection Server无法连接到 Google Cloud 连接服务器
【发布时间】:2013-06-15 22:00:02
【问题描述】:

我正在尝试在我的服务器和 Google 云连接服务器 (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

我做错了什么?

【问题讨论】:

  • 从纯网络的角度来看Connection timed out 通常意味着连接问题,所以我会检查 PING 和防火墙,并可能使用 NMAP 来查看端口 5235 是否可以访问。

标签: php android push-notification xmpp google-cloud-messaging


【解决方案1】:

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

'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>

【讨论】:

    【解决方案2】:

    您应该通过 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
    ));
    

    【讨论】:

    • 能否请您提供代码,因为我正在尝试这样做。我使用 java 制作了一个 CCSServer,但是想转移到 php。我已经尝试了一切,请帮助我。
    【解决方案3】:

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

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

    【讨论】:

      猜你喜欢
      • 2020-03-22
      • 2020-09-25
      • 1970-01-01
      • 1970-01-01
      • 2019-02-17
      • 2019-10-08
      • 2018-08-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多