Manoj Goel
Manoj Goel

Reputation: 2120

How to use Firebase behind Firewall / Proxy?

We are running a simple application that connects to Firebase are reads some data. It fails to connect with the following timeout error:

@firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential",
"message":"Credential implementation provided to initializeApp() 
via the \"credential\" property failed to fetch a valid Google OAuth2 access token 
with the following error: \"Failed to parse access token response: Error: Error 
while making request: connect ETIMEDOUT

We are behind Firewall / Proxy and it appears that is blocking traffic to/from Firebase and hence failed connection. My question is what ports need to be opened and to what destination URLs to make this application work normally?

Any help will be much appreciated!

Upvotes: 11

Views: 15094

Answers (2)

xinthose
xinthose

Reputation: 3848

I used Wireshark to monitor a local install of a Node.js application using the Admin SDK for firestore. I also referenced this list by Netify. This is what I found:

*.firebaseio.com
*.google.com
*.google-analytics.com
*.googleapis.com
*.firebase.com
*.firebaseapp.com

Upvotes: 0

Manoj Goel
Manoj Goel

Reputation: 2120

Finally, after struggling with the issue for several days got it working. Needed to contact network team and request to perform following actions:

  1. Open ports 5228, 5229, 5230 for Firebase communication.
  2. Opened communication at proxy level between the source server and following URLs:

    fcm.googleapis.com

    gcm-http.googleapis.com

    accounts.google.com

    {project-name}.firebaseio.com

  3. Added following code in my node.js application:

    var globalTunnel = require('global-tunnel-ng');
    
    globalTunnel.initialize({
      host: '<proxy-url>',
      port: <proxy-port>,
      //proxyAuth: 'userId:password', // optional authentication
      sockets: 50 // optional pool size for each http and https
    });
  4. Installed module global-tunnel-ng:

    npm install global-tunnel-ng

It solved the my problem and I hope it can help others too. :-)

Upvotes: 12

Related Questions