Reputation: 643
Our Android application is working over 2000 devices on field. This is a corporate app, not published on Google Play and we are managing our operations via these devices. Most important point for us: All of our client Android devices are behind proxy. (We have already take all actions on Firebase document warning about "If your organization has a firewall...")
We are testing to adapt FCM to our app for receiving notifications. We are using HTTP Protocol, sending Post requests to https://fcm.googleapis.com/fcm/send URL address, so our choice is Downstream HTTP Messages (JSON) and we are sending data messages both via Postman and also via our .Net desktop app. Firebase Cloud Messaging notifications are working successfully when device is connected to Internet via independent WiFi. It is also working successfully when device is connected to Internet via mobile network operator SIM card (No Proxy). But these methods are not a solution for us, because all of our devices are working behind proxy.
Is Firebase Cloud Messaging notifications not working on devices behind proxy? I found some bad news about FCM and behind proxy devices, but I am not sure. We want to use FCM notifications, however 3rd party extra apps is not a good solution for us. Because we are managing too many devices on field and we have also security issues. Is there any alternative solution to solve this issue about proxy?
Upvotes: 4
Views: 6310
Reputation: 985
Please note that as of 2019 Firebase has some Proxy Support, at least using Java or Node.js, see this Article about it: https://medium.com/faun/firebase-accessing-firestore-and-firebase-through-a-proxy-server-c6c6029cddb1
In case the Link is down, this is an example for Java configuration, all credits go to Hiranya Jayathilaka who wrote this great Tutorial (many thanks!)
String myProxyHost = "localhost"; // REPLACE
int myProxyPort = 3128; // REPLACE
InetSocketAddress address = new InetSocketAddress(myProxyHost, myProxyPort);
HttpTransport transport = new NetHttpTransport.Builder()
.setProxy(new Proxy(Proxy.Type.HTTP, address))
.build();
FirebaseOptions.Builder builder = new FirebaseOptions.Builder();
builder.setHttpTransport(transport);
// ... further configuration ...
Addition:
I have tried this solution and setting the HttpTransport only proxies requests to "fcm.googleapis.com", which is not sufficient in my case, because the Firebase Sdk first retrieves an Authorization Token from "accounts.google.com".
To Proxy requests to "accounts.google.com" also, I had to use System-Properties like this:
System.setProperty("https.proxyHost", proxyHost);
System.setProperty("https.proxyPort", String.valueOf(proxyPort));
System.setProperty("com.google.api.client.should_use_proxy", "true");
Upvotes: 1
Reputation: 643
I have received an answer from Firebase support team about this question. The answer is below:
Please note that FCM do not support Proxy at the moment, however we will take a note of this and we could consider it moving forward. I can't give you a definite timeline for this, rest assured your feedback has been acknowledged. We are constantly working on providing developers a more friendly experience hence your inputs are greatly appreciated.
We have spent some effort and time with our app development and network team about this Proxy issue. Please note that FCM do not support Proxy at this time. I hope they can support Proxy in the future, because FCM have many benefits.
Upvotes: 4
Reputation: 12717
If you took the actions described in if your organization has a firewall
then the devices should be able to receive the messages.
https://firebase.google.com/docs/cloud-messaging/server#response
Please note that those action have to be taken in the network where the devices are connected, not in the network where the notification is sent.
Upvotes: 3