DEV Community

Euan T
Euan T

Posted on • Originally published at euantorano.co.uk on

Troubleshooting Firebase Cloud Messaging on Android

I’ve spent the first part of this year at work writing and testing a new Android application, and during the course of this I’ve stumbled across some devices which seem to have recurring issues with conenctivity to Google’s Firebase Cloud Messaging service. This issue manifests with the device no longer receiving notifications after being left to idle for a few hours. In this post, I’ll go over some troubleshooting steps that I’ve found.

Check Firebase Service Status

The first step to take is to double check that the Firebase Cloud Messaging service is not having any operational issues. This can be checked on the Firebase Status Dashboard - simply ensure that the Cloud Messaging service has a green tick next to it. There is also a handy RSS feed you can subscribe to for incidents, though there doesn’t seem to be any way to filter this to only report services you are actually using.

Check Your Device’s Connectivity to FCM

The next step is to check your device’s connectivity to Firebase Cloud Messaging itself.

This can be done from the Phone app, though it should be noted that your device may have a custom phone app from your manufacturer (this is definitely true for Samsung devices) - if this is the case, you need to install the Phone by Google app from the Google Play Store.

The steps to take are as follows:

  1. Open the Phone app.

  2. Open the dialler.

  3. Dial the following: *#*#426#*#*.

  4. The FCM Diagnostics screen should open as soon as you finish typing, without having to hit the call button - if it doesn’t appear, hit the call button. If nothing happens, you might be using a custom phone app from your device vendor (looking at you again Samsung…) in which case you need to install the Phone by Google app as explained above.

    The screen should look something like the below screenshot:

    Screenshot of the FCM Diagnostics screen showing as connected

There should be a line that says something like Server: Connected. If it says Not connected or something, then there should also be some information about the last close code and when the connection was lost.

You can also press the Events button to see a live trail of events relating to the connection, including incoming messages.

To see further information about the status, click on the menu button at the top right of the screen and check the Advanced view checkbox.

If the status shows FCM as disconnected and it doesn’t reconnect, you should check your firewall - see Google’s documentation on FCM ports and your firewall.

Unfortunately, I do still have a device which disconnects and steadfastly refuses to reconnect until it’s rebooted. Further troubleshooting is needed!

Top comments (4)

Collapse
 
chaddddddd1 profile image
chad • Edited

Hi Euan, I've been having this trouble on both of my android devices of late. How did you eventually end up fixing your issues? It seems to be related to my VPN connections. Thanks for your post. This is super helpful!

Collapse
 
euantorano profile image
Euan T

On the device I’ve been having problems with, I’ve found that disabling Wi-Fi then turning it on again seems to get it to connect again.

I’ve not found a proper fix or reason yet though. It’s a very annoying problem!

Collapse
 
chaddddddd1 profile image
chad

That works for me too, but then it fails after a few hours. The FCM documentation recommends changing the NAT timeouts to 30m. It's only happening to me over a NordVPN gateway. So, it makes me wonder if NordVPN is terminating the connections too often and FCM doesn't like it. It is strange that it won't connect over my NordVPN network initially, but upon switching wifi to another network and then back to my NordVPN network, it works. It's working for me over my local network and over an ExpressVPN gateway. One day I may try to troubleshoot the NordVPN network again. Thanks for sharing. Those tools you shared have been really helpful!

(In my case I was having the same issue on two different Android devices running Android 11 and Android 12)

Thread Thread
 
euantorano profile image
Euan T

Ah, you seem to be experiencing a similar but slightly different issue.

I’ve got 2 different devices on the same network (one android 12 and one 10) - one stays connected all the time, but the other randomly disconnects after a while and will only reconnect either after a reboot or after toggling WiFi.

FCM’s documentation is quite lacking I’ve found. I’ve contacted the device manufacturer to hopefully see if they can replicate the issue.