Google Cloud Messaging 无法在公司网络上的 4.1.2 设备上运行 [英] Google Cloud Messaging not working on 4.1.2 devices on a corporate network

查看:23
本文介绍了Google Cloud Messaging 无法在公司网络上的 4.1.2 设备上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了一个简单的 GCM 客户端和服务器.客户端使用 当前 GCM 客户端 API(不是 已弃用的帮助程序库).服务器 (C# & .NET) 遵循相应的服务器指南(使用 HTTP).我的服务器在我公司域内的一台机器上运行,因此我将客户端设备连接到公司网络内的 Wi-Fi 接入点,但可以访问互联网.

I've implemented a simple GCM client and server. The client uses the current GCM client APIs (not the deprecated helper library). The server (C# & .NET) follows the corresponding server guidelines (using HTTP). My server runs on a machine within my company domain, so I'm connecting the client devices to a Wi-Fi access point inside the corporate network but with access to the Internet.

简而言之,我的问题是在 4.3+ 手机上可以正常接收通知,但在 4.1.2 手机上连接到公司 Wi-Fi 网络时永远不会收到通知.如果我将 4.1.2 设备连接到我们的公共访客 Wi-Fi 网络,GCM 消息会按预期收到,但应用无法连接到公司服务器.

My problem in a nutshell is that notifications are received fine on 4.3+ handsets, but are never received on 4.1.2 handsets when connected to the corporate Wi-Fi network. If I connect a 4.1.2 device to our public guest Wi-Fi network the GCM messages are received as expected, but then the app can't connect to the corporate server.

我已经看到一些迹象表明,当企业网络具有过度保护防火墙(例如 此处).但如果只是防火墙问题,4.3+的设备肯定也收不到消息吧?

I've seen some indications that GCM can fail when corporate networks have overly protective firewalls (e.g. here). But if it was just a firewall issue, surely the 4.3+ devices wouldn't receive any messages either?

我的测试手机如下:

  • 华硕 Nexus 7 (4.4.2)
  • 三星 Galaxy S4 (4.4.2)
  • HTC One (4.3)
  • 三星 Galaxy S3 (4.1.2)
  • 摩托罗拉 Razr HD (4.1.2)

服务器已收到来自所有五个设备的有效注册 ID.在一个 15 秒的计时器上,它发送一条消息到所有五个注册 IDS.响应始终显示已发送 5 条消息,没有错误,也没有更改注册 ID.但是,它总是在上面列出的前三台设备上收到,而在后两台(运行 4.1.2)上从不.当我调试它们时,根本没有调用广播接收器.

The server has received valid registration IDs from all five devices. On a 15-second timer it sends out a single message addressed to all five registration IDS. The response always shows that 5 messages were sent with no errors and no changed registration IDs. However, it is always received on the first three devices listed above, and never on the last two (running 4.1.2). When I debug them, the broadcast receiver isn't getting invoked at all.

我还验证了所有五个设备:

I've also verified that all five devices:

  • 拥有 Google Play 服务 4.3.25
  • 没有 SIM 卡,因此没有蜂窝数据,并且在同一个 WiFi 网络上
  • 有正确的日期&时间
  • 使用相同的 Gmail 测试帐户注册
  • 正在运行相同版本的客户端应用
  • 为其 Google 帐户启用所有同步设置

推荐答案

我终于弄清楚问题出在哪里了.公司防火墙阻止了本地 GCM 端口 5228 上的流量.(5229 和 5230 是 也提到与 GCM 相关,但我们根本没有在这些端口上看到任何尝试的流量.)这在其他地方有很好的记录(只有 Google GCM 端口 5228).

I've finally figured out what the problem is. The corporate firewall is blocking traffic on the native GCM port of 5228. (5229 and 5230 are also mentioned with relation to GCM but we're not seeing any attempted traffic on those ports at all.) This much is well documented elsewhere (just Google GCM port 5228).

我在任何地方都找不到明确记录的内容,但我们已经从我们的服务器日志和运行 Connection Tracker 在手机上,是较新版本的 Android 回退到使用端口 443(标准 HTTPS 端口),大多数防火墙默认允许流量通过.这就是我们运行较新 Android 版本的设备即使在防火墙之后也能正常工作的方式.我不知道具体是哪个 Android 版本引入了这个端口 443 回退,但它介于 4.1.2(不工作)和 4.3(工作)之间.

What I can't find clearly documented anywhere, but we've figured out from our server logs and from running Connection Tracker on the handsets, is that newer versions of Android fall back to using port 443 (the standard HTTPS port) which most firewalls allow traffic through by default. This is how our devices running newer Android versions are working even behind the firewall. I don't know precisely what Android version introduced this port 443 fallback, but it's somewhere between 4.1.2 (not working) and 4.3 (working).

这篇关于Google Cloud Messaging 无法在公司网络上的 4.1.2 设备上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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