How to use Firebase behind Firewall / Proxy?

半世苍凉 提交于 2019-12-25 20:28:23

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/53275949/how-to-use-firebase-behind-firewall-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!