I'm trying to verify the firebase token with Firebase Admin SDK(VerifyIdToken()) to receive uid using NestJS Web Socket. It worked pretty well when the server was single WAS. But after I scaled up the server with Load Balancer it always return this error.
Error
FirebaseAuthError: Error while making request: connect ETIMEDOUT
errorInfo: {
code: 'auth/argument-error',
message: 'Error while making request: connect ETIMEDOUT 'IP Address:443.'
}
Servers connected to Load Balancer(I Connected two server) have different IP with exactly same logic. Every server have Firebase Token Verification function.
//To Verify Firebase Token, return uid
async VerifyFirebaseToken(Token: string): Promise<string> {
try {
const VerifiedToken = await this.firebaseVerifierApp
.auth()
.verifyIdToken(Token);
return VerifiedToken.uid;
} catch (error) {
console.log(
'Critical error occured!! See details below.',
);
console.log(error);
return '';
}
}
and how I initialized the firebase app
this.firebaseVerifierApp = firebase.initializeApp({
credential: firebase.credential.cert(firebase_params),
});
I think the problem is, the Load Balancer is not guarantee the firebase Verification callback goes back to where the request sended.(Sended to other server or somewhere else I guess).
How can I guarantee the verification call back goes back to where the request sended? If what I guessed is wrong, is there anyway to fix it?