谷歌云消息传递不工作4.1.2设备在企业网络中消息、设备、工作、网络

2023-09-05 02:00:08 作者:莫相离

我已经实现了一个简单的GCM客户端和服务器。客户端使用目前GCM客户端API (不是的德precated助手库)。服务器(C#和放大器; .NET)的相应服务器指南(使用如下< A HREF =htt​​p://developer.android.com/google/gcm/http.html相对=nofollow> 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+手机收到很好,但是当连接到企业Wi-Fi网络在4.1.2手机都从来没有收到。如果我一个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.

我已经看到了一些迹象表明,GCM会失败时,公司网络有过度保护的防火墙(如here).但是,如果它只是一个防火墙的问题,肯定是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:

有谷歌播放服务4.3.25 在没有SIM卡,因此没有蜂窝数据,并在同一WiFi网络上 有正确的日期和放大器;时间 中注册的相同的Gmail测试账号 在运行我的客户端应用程序相同版本 已启用了自己的谷歌帐户的所有同步设置 have Google Play Services 4.3.25 have no SIM, hence no cellular data, and are on the same WiFi network have the correct date & time are registered with the same Gmail test account are running the same version of my client app have all sync settings for their Google account enabled

推荐答案

我终于想通了什么问题。该公司的防火墙阻止流量5228.(5229和5230的本机GCM端口上的也提到有关系GCM 但我们没有看到这些端口上的任何尝试的流量在所有。)这多少是在其他地方证明(只是谷歌的 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).

我找不到什么明确记载的任何地方,但我们已经从我们的服务器日志和运行的在手机连接跟踪,是较新版本的Andr​​oid回落到使用端口443(标准HTTPS端口),其中大多数防火墙通过允许通信在默认情况下。这是怎么运行较新的Andr​​oid版本,我们的设备都在工作,即使在防火墙后面。我不知道precisely什么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).