问题
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:
- Open ports 5228, 5229, 5230 for Firebase communication.
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
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 });
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