Behavior of GCM over Wi-Fi

2,287 views
Skip to first unread message

Diego Massanti

unread,
Aug 18, 2012, 5:09:35 PM8/18/12
to andro...@googlegroups.com, Roberto Estivill
Hello there, i have been testing GCM on device that only have a Wi-Fi connection, as in, no SIM on the device, hence no 3G network on it.

I have noticed that after around 10 minutes, even if the phone's screen is on, the notifications stop being received, however, this is what i get back from Google's GCM servers:

{"multicast_id":8369426514352710830,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1345324060064666%97ac237f9269aa93"}]}

So the notification is properly received by the GCM servers, but the phone is not getting it.

I have found that disabling and re-enabling the Wi-FI on the phone fixes this issue, and i was able to reproduce this issue on more than one device and on different android versions.

The question is: Is there any kind of lock or something on the API that i could use to prevent this from happening ?
Is this behaviour documented somewhere ?

Thanks in advance, Diego Massanti.

francesco nerieri

unread,
Aug 22, 2012, 12:27:00 PM8/22/12
to andro...@googlegroups.com, Roberto Estivill
no, most likely you lose the connection or your connection hangs. I
wouldn't be surprised if on a different wifi network you don't
experience the issue.
f
> --
> You received this message because you are subscribed to the Google Groups "android-gcm" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-gcm...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
---
https://plus.google.com/u/0/104524825852741167674

Diego Massanti

unread,
Aug 26, 2012, 12:12:32 AM8/26/12
to andro...@googlegroups.com, Roberto Estivill
It happens on all wi-fi networks i've tried... is there any way to debug this ?

Rupert Rawnsley

unread,
Nov 22, 2012, 9:27:00 AM11/22/12
to andro...@googlegroups.com
Same here. I've posted a more detailed reproduce on another thread: https://groups.google.com/d/msg/android-gcm/Y33c9ib54jY/vmJRFv0SmKYJ

We could really do with someone on the Android team to take a look at this. Making a simple reproduce for it is hard because of the client-server registration.

On Wednesday, 21 November 2012 16:26:59 UTC, Nacho wrote:
I have the same issue here, you find any solution? Works fine on 3G but suddenly stop work on wifi after few minutes.. Thanks.

weerala...@gmail.com

unread,
Feb 12, 2013, 6:22:27 PM2/12/13
to andro...@googlegroups.com, Roberto Estivill

Hello Fransesco and others,

One of the main problems of losing the connection between your mobile device when your device is behind a WIFI router and GCM is because of the TCP time-out setting in the router (for a NAT-ted connection). Most routers, probably all, have a default TCP time-out setting which is set differently on different routers, but we found that most SOHO routers use a setting of somewhere around 5 minutes. After these 5 minutes the connection between device and GCM is dropped and messages sent from GCM won't reach the device anymore untill the next GCM heartbeat, which is 15 minutes.  As a consequence, depending on the TCP time-out setting a GCM message will be delayed 15m-5m =10 minutes, for a TCP time-out setting of 5m. For routers that have a TCP time-out setting of say 2m, the delay would be 13 minutes.

We develop apps that require delivery delays in the order of seconds, so delays of 10 minutes would seriously jeopardize our proposition, if not make it impossible.

Work arounds:
The GCM heartbeat interval (15 m) is not freely configurable on the phones and can be done on rooted phones, so this is not an option to pursue.
Another way to solve this is to change the TCP time-out on the routers to a value greater than the GCM heartbeat, but, not all (SOHO) routers allow that and you cannot ask clients to configure their routers or buy new routers. Also, when using WIFI hotspots or other public free or paid WIFI routers there is no way to demand any changes to the routers.

Hence, although the above would be solutions in individual cases, they are no option to a general solution.

Solutions:
A more general "solution", however not one that we would prefer, would be to send keepalive GCM messages from our server to the GCM servers and to the phones in every let’s say 4:59 min (assuming that 5 minutes is used by most routers as default TCP time-out setting).
Although we could pursue this solution, we feel that there should be a more structural and less demanding one, and hopefully Google can suggest or make available such.

A better solution would for instance be to send keepalive messages initiated from the device. How to do this? By using some GTALK api to send empty keep alive messages in every 4:59 m:s.
In other words:Is there a way to send a "ping" message on the GCM connection? Is there maybe an API, or can it become available, such that we can have access to the GCM connection, probably indirectly (like a GTALK message)?

Appreciate your feedback!

Greg

Rupert Rawnsley

unread,
Feb 13, 2013, 4:40:44 AM2/13/13
to andro...@googlegroups.com, Roberto Estivill
As far as I know, everything you say is true. Regarding getting the client to send a keep-alive, there isn't any client-to-server channel I'm aware of beyond the GCM registration. There's no limit on the number of times you register, so doing it every three minutes, say, might keep the channel open.

I think that a message to any application should keep the connection alive, so you could set up a dummy service that both sends and receives messages (as the example app I made earlier does). This would have the same effect and be client initiated rather than driven by your server. Given that you are sharing the "private" GCM communication key, it might have security implications I can't foresee  so I would advise caution. It might also violate the GCM terms of service.

The other implication of keeping the client alive is that it might have a detrimental effect on battery life, but you could make it a user option.

彭辉

unread,
Sep 13, 2013, 3:20:20 AM9/13/13
to andro...@googlegroups.com, Roberto Estivill
Hello, Greg.

I am doing some work about the heartbeat of GCM.

And you told us that the heartbeat interval can be configured on rooted phone, could you please tell us how?

在 2013年2月13日星期三UTC+9上午8时22分27秒,Greg写道:

彬邵

unread,
Jan 26, 2015, 10:05:18 PM1/26/15
to andro...@googlegroups.com, roberto....@safertaxi.com
please check this thread https://productforums.google.com/forum/#!msg/nexus/fslYqYrULto/lU2D3Qe1mugJ 

在 2012年8月19日星期日 UTC+8上午5:09:35,Diego Massanti写道:
Reply all
Reply to author
Forward
0 new messages