The Vera Community forums have moved!

General => Remote Control => VeraAlerts => Topic started by: gsheremeta on June 28, 2015, 11:56:07 am

Title: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: gsheremeta on June 28, 2015, 11:56:07 am
I wanted to let you know about a GCM issue I've struggled with for the last month. From what I can gather, it looks like an issue with Android 5.0.2 and the latest GCM client. I believe it's an issue with IPv6, but it could also be an Atheros radio issue.

Basically, people on Android 5.0.2 (Xperia Z3c, Galaxy S6) aren't getting GCM messages while the phone is sleeping (screen off).

For me, makes my phone pretty useless, as I then can't get home automation alerts from Vera Alerts! Vera Alerts uses GCM.

Turns out swapping my router fixed the issue when I'm on wifi. I switched from an Atheros-based OpenWrt router with IPv6 to an old Broadcom-based router running Tomato and IPv4 only. For 4G, I've disabled IPv6 on the APN. Still testing that part.

So if you start seeing posts about delayed notification issues on newer phones, consider disabling IPv6 or swapping routers!
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: BOFH on June 28, 2015, 12:00:21 pm
My LG G2 runs 5.02. Thanks for the heads up. Luckily the GetVera Android app does not seem to be affected by this. I know my home WiFi uses a Broadcom chip but I'm unsure as to what the one at work uses.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: ShawnInFL on September 08, 2015, 01:36:24 am
So glad to see I am not the only one dealing with this madness. Drives me CRAZY!! Like you, while my S6 Edge is in sleep mode, anytime the display is not lit, I get no Vera Alerts while on WiFi. I set the Always option in advanced WiFi on the S6 but no luck. I would send test alerts to the locked phone, nothing. As soon as I unlock the phone, here they come. To make things worse, if I leave the property and hit 4G, here they come, one after another. It really makes the notifications pointless. After trying different apps like push notification fixer with no results, I just turned off WiFi for the last month. I am at the end of my billing cycle and nearing my 12G data limit. Very rare I use this kind of data and this notification issue prevents me from using my data when off WiFi as I usually would. Like enjoying my usual streaming of content. It was this data months data limit warning that drove me to seek a better solution.

I currently just use the router that is built in with my Comcast voice/data modem. I don'tr eally see a way to disable ipv6 with this device. Wondering, is there any drawback to removing ipv6 from the network? I do a great deal of streaming through NetFlix, DirecTV, Video Cams...the usual tons of devices for surfing.

I had read where some folks had rooted the S6 to disable ipv6 at the phone. Have you tried this prior to the router solution? My phone is not rooted right now but it might be soon if thats what it takes to finally get this issue resolved. 

Let me know your thoughts please and previous attemps/results.

Thanks for the post, I knew I was not the only S6 owner with push issues but glad to find someone with the same issues with Vera Alerts.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: James92TSi on September 29, 2015, 11:21:01 am
I am having similar trouble on HTC One M7 with android 5.0.2.  While phone is asleep on the home wifi, I get no VeraAlerts. As soon as I unlock it, the alerts come rolling in.  I do not have this problem when on mobile data.

If it makes any difference, my home wireless is a comcast xfinity gateway.

Is there any known resolution at this point other than turning wifi off on the phone?

Thanks!
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: ShawnInFL on September 29, 2015, 11:34:33 am
Sadly, this is all I have figured out to do. As you say, turn the wifi off on the phone. I was having the same issue with Pandora. If on WiFI, it would play one song and then stop, as soon as I opened the phone, the music would begin playng again. If the phone is off wifi, the songs play one after another, no problem, while the phone is locked or in stanby. I will say this, I love my S6 but this is total BS!! I will think twice about another Samsung for my next purchase if they can't get this resolved soon. My Galaxy S 10.5 Tablet works just fine. It's something to do with the new Wifi radio in the S6 I believe. Nothing I have tried works. I got rid of ip6, the hearbeat app, none of it made any difference. I even told Vera to text me an alert to wake the phone up so I could then get the Vera alerts. That was half-a$$ as well. Now, I just stay off wifi unless I am doing a lot of surfing on the phone. Its a real bummer but without the Vera Alerts, my Vera system is pretty weak in my book. I have photo beams and stuff on the property that I need to be accurate and fast alerts. GOOD LUCK!! Please, if you find any solution, share here. I will be sure to do the same. BTW - I too am on Xfinity and use their router for phone/data, no TV, I use direct TV. You can turn off ip6 on the router but it didn't do anything for me. Even after rebooting every device in the entire network.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: James92TSi on September 29, 2015, 11:54:31 am
I've been thinking of disabling the wireless functionality of the xfinity gateway and using an Ubiquiti AP instead, but honestly I get decent enough coverage from the xfinity AP that it isn't high on my priority list.

I am not so sure it is a phone hardware issue with your S6, as I am having the same issue on a 2+ year old HTC phone.  ATT did just recently push the update to android 5.0.2 on my phone, for whatever that's worth.  Unfortunately I was not using VeraAlerts prior to the 5.0.2 update, so I do not know if 5.0.2 is a contributing cause.

I am going to setup a second profile on my work phone (galaxy s4 running 5.0.1) and see what happens.  Might be too many variables changed to be a worthwhile test, though.

It would be interesting to know if your S6 and my One M7 use the same wifi chip or not.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: ShawnInFL on September 29, 2015, 01:04:21 pm
Very interesting. I can tell you this though. I don't use the XFinity router/modem for wifi at all. I have it turned off and ONLY use Ubiquiti AP's for my wifi. I have 3 on my property. I get the issues regardless of the AP. Others feel it's an ip6 issue but I had no luck. I did just receive the latest OS update but it appears to be only for security. I am on Verizon wireless BTW. Maybe buying a different router from Best Buy, trying it out and then return if doesn;t work is an option? Since I do voice and data over the modem, I have always just stuck with the Xfinity one. Not to mention lightning is a bitch down here in FL. Have had my modem replaced by Xfinity twice last 3 years.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: RichardTSchaefer on September 29, 2015, 01:14:57 pm
I am on AT&T and use an S4. I like the features on it.
I usually do not have any problems as leaving the house every day cycles between wifi and Celluar data. I have only had problems if I, or at least my phone, stays home for a couple of days in a row,
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: ShawnInFL on September 29, 2015, 01:21:00 pm
Hi Richard, are you on Comcast? Do you use the Comcast Modem/Router? Do you get voice/data/tv? Just curious if we can isolate the issue. It's very odd to me that my samsung tablet works just fine. Thanks
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: James92TSi on September 29, 2015, 03:55:01 pm
After configuring the second phone/profile, I only had a short while at home this morning before I had to leave. 

With both phones (HTC One M7 running 5.0.2, and Galaxy S4 running 5.0.1) out in the wild on mobile data, I am not seeing any difference between them. They are both notifying me as alerts occur.

I'll give this configuration some more time for differences to become apparent when both are on the home wifi and possibly on other wifi networks.

I forgot that I have an older samsung tablet (galaxy tab 10.1 wifi only, running CM7) that I could test with as well.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: James92TSi on September 29, 2015, 05:17:40 pm
Some possibly related reading:
http://eladnava.com/google-cloud-messaging-extremely-unreliable/

I might try this out:
https://play.google.com/store/apps/details?id=com.andqlimax.pushfixer.noroot&hl=en

If the issue is that my home wireless AP is closing the socket after x minutes, in theory setting the heartbeat on pushfixer to a shorter interval could serve as a workaround.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: ShawnInFL on September 29, 2015, 05:21:28 pm
I tried the heartbeat long ago, no help. Please, do keep us posted though and GL
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: James92TSi on September 29, 2015, 08:33:21 pm
I've installed the PNF no-root version set for 5 minutes on the One M7... will continue to monitor timeliness of its notifications vs those on the Galaxy S4.

Thinking about this problem, I'd always noticed that google talk messages would come through on my GS4 while they would not come through on the M7 until I woke it up.  Likely the same root cause.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: tomtcom on September 29, 2015, 10:00:47 pm
I researched this up and down a while ago. The ports for gcm 5229 I believe have a short time out on most wifi routers versus 4g unless your software on the router has some advanced options on keeping connections alive.

Push fixer never worked. I reported all this to Joao for autoapps too.

You can try to send sms or emails to yourself or even tasker to switch wifi on and off which is a battery drain.

I believe when I get this issue it's around 15-30 minute delays give or take.

The only true way to get gcm to stay alive is if you could construct your own gcm packet to google but this requires an active development project and key.

Using port scanner apps on the phone, sending an email or SMS doesn't always wake up gcm as there is first your typical https 443 connection.

So I've not yet found a solid method to fix this.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: tomtcom on September 29, 2015, 10:04:01 pm
Actually, the last method in my opinion would try to have Vera alerts or autovera to run as a service in the pull down. That's the last idea I thought of.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: ShawnInFL on September 30, 2015, 12:43:39 am
Hey Tom, thanks for your expertise on the subject. Yikes, I get the feeling if you can't beat it, I don't know that it will be beaten LOL The timeout issues sounds like the real deal and perhaps makes some sense of why the original poster, gsheremeta, seems to have resolved his issue by replacing his new version router with a much older router. Perhaps the timeouts are different. gGsheremeta mentions he felt it was an ipv6 issue. I could not conclude the same result as it didn't work for me when I turned off ipv6 on my comcast router. This does provide a shred of hope though :-)

Question, do you know of a router that would provide such capabilities? I would be more than happy to purchase a more robust router with additional options to resolve this issue once and for all.

Again, thanks for your input and contribution to the cause!!
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: tomtcom on September 30, 2015, 04:07:22 pm
Hey Tom, thanks for your expertise on the subject. Yikes, I get the feeling if you can't beat it, I don't know that it will be beaten LOL The timeout issues sounds like the real deal and perhaps makes some sense of why the original poster, gsheremeta, seems to have resolved his issue by replacing his new version router with a much older router. Perhaps the timeouts are different. gGsheremeta mentions he felt it was an ipv6 issue. I could not conclude the same result as it didn't work for me when I turned off ipv6 on my comcast router. This does provide a shred of hope though :-)

Question, do you know of a router that would provide such capabilities? I would be more than happy to purchase a more robust router with additional options to resolve this issue once and for all.

Again, thanks for your input and contribution to the cause!!

Hey Shawn, I'm not sure what router to choose. What I would tell you when researching is get reviews of the software on the router and what you can actually do with it. That might tell you if you can increase the timeout before a port will close it's connection.

DD-Wrt has cool software mods for the Buffalo routers which comes pre-loaded, that might do the trick.

I have the newer Comcast xfinity gateway. I was not able to find a way to turn off IPv6, how did you do it? Maybe I missed it?

I also thought about port forwarding GCM 5229, perhaps the rules of port forwarding on the Comcast router might have longer keep alives but I doubt it. If you explore this option make sure all IP's on your home network get this forwarded or no one but you will get push messages. :)

Make sure you review the ports, I think it is 5229 only but might need to look that up again.

Push NOtification didn't work because all it does is broadcast an intent. I configured Tasker to do this as well and proved with logs that it would send out the intent. But since there is no data to transmit it doesn't use 5229 to transmit anything thereby not "waking" the port up.

Good luck, I still face the problem and would like a fix where I didn't have to pay money. :(
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: ShawnInFL on September 30, 2015, 05:27:44 pm
Thanks for all the input, will have to do some research on a good router. My guess, nothing I can easily buy/try/return at Best Buy for the sake of research. Headed out for the evening but I did want to share this image with you. I had called and asked tech support for Comcast how to disable iPv6 (insert grain of salt). This is what they had indicated would do the trick. Selecting and saving the bottom option, disable entire firewall for the iPv6 option. I agree my friend, paying more to get what should already work doesn't sound like fun LOL I do wonder if it's Comcast related though. I'm pretty sure they prevent me from getting 3D content over NetFlix as well. Both customer support departments are usually worthless.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: tomtcom on September 30, 2015, 09:35:43 pm
I don't think it's comcast only but Comcast seems to give us the Fisher price of options to control anything.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: James92TSi on October 01, 2015, 10:24:17 am
Would any of the other push software variations available under veraalerts potentially work around this issue?

I am not familiar at all with pushbullet or the other options to know if they use GCM.

Down the road I also want to attach pictures to alerts (once I have cameras...) which I suspect might only be available in the veraalerts app itself, or via SMTP (and I am trying to avoid using email for this).

Thanks both of you for the information you're sharing!
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: ShawnInFL on October 01, 2015, 10:40:10 am
First, I have tried the Push Notification Fixer App from Play Store to adjust the hearbeat and have had no luck in the past. On the use of Pushbullet for notifications, I believe this would not give you the voice notifications you get with Vera Alerts. To me, those voice notifications are the best thing going for Vera. I rely on them big time.

I just created two tasks and profiles in tasker to make my phone turn off wifi anytime my phone display is in the off state and turn wifi back on anytime the phone display is in the on state. So far it seems to work fine and resolve the push issue while hopefully cutting down my data use while at home. Tired of sacrificing my data for the ability to get timely notifications. I wish I could find a router to resolve this issue. Still looking. Agree with tom, the comcast router is a joke at best.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: tomtcom on October 01, 2015, 12:53:22 pm
Shawn what interval do you have between turning off the wifi and back on?
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: ShawnInFL on October 01, 2015, 01:06:24 pm
Pretty new to tasker but I think the answer is none. I simply created two separate profiles and two separate tasks. Does this help? Playing with Autovoice now... :-)
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: James92TSi on October 01, 2015, 05:36:55 pm
I'm giving this a try in tasker as well.

I first set up the display state off = wifi off portion of it, and upon doing so received a note that wifi would return to its previous state when the profile became inactive.

As such I only have the one profile setup (turns wifi off when display state is off) and it automatically turns wifi back on if I had it on prior.

Will see if this works out....
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: tomtcom on October 01, 2015, 08:42:26 pm
Those are probably good ideas too. I'm one of those that has the screen timeout set for 10 minutes. That's just me. Since I already occasionally get disconnect/reconnect I could probably set this up for whatever interval. The tricky thing for me is the interval without killing battery, might not be to bad but there's some articles indicating timeouts on ports somewhere like 17 minutes or something I read so if you miss the interval and switch to 4g to late you could still encounter latency. Eh, I'll experiment on it.

Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: ShawnInFL on October 02, 2015, 12:55:08 am
Seems to have resolved my issue while still spending most of my data on wifi. Notifications are solid and fast. Right on time. Keep us posted.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: tomtcom on October 02, 2015, 06:16:09 pm
If you are interested, get the app on mios called Push Notification. You can then sign up for various push accounts. I used pushover. I paid for the android app, $4.99.

So my point and a caveat....

Looks like development stopped and it doesn't send the messages in UI7 *however* if you by chance run the AltUI plugin on this forum (I highly suggest you do) it works from there.

The app is designed to be able to code a scene. You could silence the notifications so you don't see them but the purpose is to keep your GCM port alive since they are push messages.

I'll try and experiment to see. I know it's an app cost and partially broke since you have to get AltUI to see if it works but whatever solution is best for each person.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: ShawnInFL on October 02, 2015, 06:26:08 pm
Please do let us know. I really don't mind the $5 for a fix. I am still on UI5, "if it ain't broke" LOL

Any thoughts on Android apps like Keep Wi-Fi alive?
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: tomtcom on October 02, 2015, 06:46:41 pm
I think any new phone shouldn't have a need for keep wifi alive app. In our advanced settings you know there is keep wifi on during sleep and judging by your Tasker screenshots, looks like you have a Samsung phone...just guessing.

I set up a scene in AltUI (this is a mod for the entire Vera UI. It works for UI5 too).
http://forum.micasaverde.com/index.php/board,78.0.html
Have a look, custom themes, advanced options, all sorts of goodies.

I believe for the Push Notification app for the Vera, somewhere they have a device variable wrong which I'll look at later but after getting it to work in AltUI, the Vera UI now shows the app working correctly however I can't send manually from the Vera UI but not a problem since the AltUI scene works like a champ.

I set it every 1 minute, works great but that's a test, so now it's every 15 minutes. I hide notifications from the Pushover app on the phone.

There was a site that went in depth on the GCM polling interval...can't find the darn site...talking about 3g/4g having sockets open for 17 minutes or something while home wifi was 28 minutes. I could be saying this wrong but the point is 1 message every 15 minutes is being sent by Vera which is always on and internet connected to work to keep your phone's push active.

I can't say this has solved it, I'll have to notice a problem or lack of problems before I know for sure.

Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: RichardTSchaefer on October 02, 2015, 08:09:02 pm
You are mixing apples and oranges.

The problem is not to keep the WIFI active ... it's to keep a particular socket active.
Socket's are being closed because of inactivity ... a socket is a link between an APP and a server.
In this case from the Google Play Services APP and the Google GCM server.

Opening another socket from a different app to a different server does not change this behavior.

Techniques to solved the problem involve sending packets at a LOWER LEVEL network stack protocol, in a manner  that do not impact the higher level protocol.
This is typically only available to apps running as ROOT.

Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: tomtcom on October 03, 2015, 01:21:25 pm
Hi Richard, I agree with you in terms of keeping the socket alive, that is my goal. Normally apps would open some form of upnp socket and that is why I would agree it might not do what I'm looking for, however here: http://updates.pushover.net/ is a snippet that leads me to believe I'm on the right trail:

In early versions of Android, Google provided a mechanism for apps like Pushover to receive notifications called C2DM, which Pushover used until Google deprecated it in June 2012. In version 1.6.2 of Pushover for Android we started switching devices to Google?s new notification system called GCM, which the majority of Pushover users are now using. In August 2014 we finally removed all support for C2DM in our Android app and required all new devices to use GCM.

I can't root the Note 4 the way I would like, they only have a temp root solution that I do not care for. Otherwise your comments about lower level network stack I'm in agreement with.

So my point is I will simply run some tests to see if the outcome helps me. If it does then I will stick with it. If it does not then that is that.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: RichardTSchaefer on October 03, 2015, 01:33:09 pm
With C2DM and GCM  the APP (i.e PushOver or Vera Alerts) never actually open the socket ... The socket was always managed by Googles Software ... for GCM it's Google Play Services. The Google software calls back apps on the Android (PushOver, Vera Alerts, App Store Updates, ....) when there is data for them. The idea behind C2DM/GCM is that there is only a single network socket polling loop, independent of the # of application protocols an Android App was running. Having servers that can handle an unbounded number of connections is a technically challenging job ... and Google decided it would be best if they managed that problem.


You can't get at the socket for that ... With root you can find the socket and do some low level socket communication that does not effect the higher level socket protocol.


You may help for the cases where the LOCAL phone hardware is dropping the connections because of data inactivity. That's the case for S6 running IPv6.
The only way to solve this for everyone is for Google to lower there interval (or at least provide an option for users to lower the interval) to a value that is smaller than ALL
of the HARDWARE between the APP and the Server that is looking to drop connections to save resources:

This includes:
1) Your Phone (power savings)
2) Your Data Carriers (free up server resources)
3) Google (I am pretty sure they are not dropping the connections)
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: ShawnInFL on December 22, 2015, 12:40:02 pm
FYI - I just recently received an update to my Samsung Galaxy S6 Edge through Verizon. I noticed in the notes it mentioned "IMPROVED WI-FI PERFORMANCE". Since the update, my alerts, Pandora and other apps that were being delayed and effected by being on Wi-Fi seem to be working as they should, even while on Wi-Fi. Meaning, no need for my tasker fix to turn the Wi-Fi off while screen is locked and back on when screen is unlocked. Just wanted to pass along that it looks as though this issue is finally resolved!!
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: tomtcom on December 22, 2015, 02:32:23 pm
Is that the 5.1 update? I wasn't sure if M was available yet.
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: ShawnInFL on December 22, 2015, 02:47:58 pm
Looks like I am on 5.1.1
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: tomtcom on December 22, 2015, 05:11:27 pm
Looks like I am on 5.1.1

Ok, I think the Note 4 for Verizon will be February and not sure if it will be 5.1.1 or M. But this is better news. Thanks!
Title: Re: heads up -- GCM bug on Android 5.0.2 devices (affects Vera Alerts)
Post by: ShawnInFL on December 22, 2015, 05:13:21 pm
Looking forward to marshmallow myself! Keep me posted when you get your update and let me know if that did the trick. There is a light at the end of the tunnel. Luckily, for me, it wasn't a train :-)