How to use Firebase behind Firewall / Proxy?
Asked Answered
E

2

11

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!

Ellsworthellwood answered 13/11, 2018 at 7:32 Comment(0)
E
12

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. :-)

Ellsworthellwood answered 16/11, 2018 at 11:49 Comment(0)
E
0

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
Economics answered 23/1, 2023 at 17:27 Comment(2)
on which ports?Horsefaced
@TiagoStapenhorst 443 (https)Economics

© 2022 - 2024 — McMap. All rights reserved.