FCM hostnames whitelist for firewall - node.js

I recently found problem with firebase-admin behind firewall (using firebase-admin for nodejs
).
This is actual error:
Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: Error while making request: connect ECONNREFUSED 142.251.37.109:443. Error code: ECONNREFUSED"
which is quite self explanatory, I can add IP and port to firewall whitelist, but if FCM change their IP my connection will be refused again.
For me, better approach is to add hostname to whitelist, but I can't find in any documentacion what host is called by initializeApp function. For example, it is not any specified hostname from docs (none is resolved to 142.251.37.109, but it is definitely firebase IP according to ip range).

Related

Getting 502 Bad Gateway: Registered endpoint failed to handle the request error on pcf

I have deployed the nodejs application to a pivotal cloud foundry. Deployment is successful, but when I am trying to access any page which has a post request, getting the '502 Bad Gateway: Registered endpoint failed to handle the request' error. For handling port, I have used the cfenv module, but I am getting this error for post requests in which I have post URL with the port as 'https://my-neptune-cluster.cluster-cr2fhfjprba.us-east-1.neptune.amazonaws.com:25881'. Can someone help me with how can we resolve that?

UnknownError: Gateway Timeout while connecting to Codecommit using asdk-sdk nodejs

I have been trying to set up CodeCommit with aws sdk, but when i try and list al the repositories, it says “Unknown Error Gateway Timeout”. The secret keys works fine with S3 but codeCommit gives Gateway timeout error.
Any idea
?
The user with secret keys have administrator privileges
I tried this, where codeCommit has been defined in other file. Any reason why I am getting this error?
const { codeCommit } = require ("./../../aws")
var hello = await codeCommit.listRepositories(params).promise();;
Check if you can connect to connection endpoint [1] via a command like curl:
$ curl https://git-codecommit.us-east-2.amazonaws.com
If not, something in your network is blocking access, presumably a firewall.

Db2 (Warehouse) on Cloud: How to use APIKEY or ACCESSTOKEN to connect from CLP?

I have an instance of Db2 on IBM Cloud. I would like to use my local CLP to connect to it. I set everything up to be able to connect using a username and password. Now, however, I would like to make use of either an APIKEY or ACCESSTOKEN as documented.
My attempts result in either
SQL30082N Security processing failed with reason "25" ("CONNECTION
DISALLOWED"). SQLSTATE=08001
or
SQL30082N Security processing failed with reason "24" ("USERNAME
AND/OR PASSWORD INVALID"). SQLSTATE=08001
I have successfully create an APIKEY and also was able to generate an access token using that API key. But what is needed to connect?
connect to clouddb ACCESSTOKEN "my long token here"
It was a matter of the right setup and correct steps:
IAM support only works with SSL connections
for SSL, I had to use the right port number (50001) and keywords (security ssl) when cataloging the node and database
my Db2 client required additional setup for GSKit and encryption key database
I wrote up a blog post with all the steps and a collection of error message on how to setup a Db2 client to authenticate using either API key or access token. Basically, it is to catalog the server:
db2 catalog tcpip node Db2oCfra remote db2host-fra02-xxx.services.eu-de.bluemix.net
server 50001 security ssl
Then catalog the database:
db2 catalog db bludb as fradb at node db2ocfra
Thereafter, connect:
db2 connect to fradb APIKEY myIBMCloudplatformApiKey
There might be additional steps in order to install GSKit and properly configure SSL support.

Why am I getting connection error on calling notify on Azure SignalR

I have configured a SignalR resource on my Azure account and am sending a message to the SignalR Hub using the below snippet in an Azure Function written in C#:
await signalRMessages.AddAsync(new SignalRMessage()
{
Target = "notify",
Arguments = new object[] { requestBody }
});
However, I keep getting the below error.
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
I have also verified that the Azure function URL for negotiate function returns me the below information as expected.
{"endpoint":"https://xxxxxxx.service.signalr.net:5001/client/?hub=broadcast","accessKey":"yyyyyyy"}
Why am I getting the connection error and what could I change in my configuration?
This error means no server listening at specified ip/port that you are trying to connect to. It can be caused by using the wrong IP address or the wrong PORT.

How to connect to Firebase by Firebase Admin against a proxy?

Currently, I am using Firebase Admin SDK to connect a Firebase database in a NodeJS server side application.
But I do not find an option to connect Firebase via proxy settings, or it can detect my system HTTP_PROXY environment variable.
When I run the node script by node index.js, and got some timeout messages like this(I know in my work network, I can not connect to Firebase directly).
Error: Credential implementation provided to initializeApp() via the "credential
" property failed to fetch a valid Google OAuth2 access token with the following
error: "connect ETIMEDOUT 216.58.200.237:443".
at ....erver\node_modules\firebase-adm
in\lib\firebase-app.js:74:23
at process._tickCallback (internal/process/next_tick.js:103:7)
I also use browser to access the firebase console via proxy, it works.
But how to resolve this issue in NodeJS server side scripts?
This error also happens if the date and time on your host machine where you run NodeJS process is not set right. Make sure to keep the server time synced.
The full error message:
Error: Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: invalid_grant (Invalid JWT: Token must be a short-lived token and in a reasonable timeframe)". The most likely cause of this error is using a certificate key file which has been revoked. Make sure the key ID for your key file is still present at https://console.firebase.google.com/iam-admin/serviceaccounts/project. If not, generatea new key file at https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk.
Faced with the exact same problem yesterday, got it solved.
Let's get it straight, you are getting this error because Google services are banned in your region, therefore you should access firebase through a proxy. Here's a blog explaining how it is done.
For this specific case, you should
Prepare a proxy server that allows you to access Google services, then
Install the https-proxy-agent package through npm or yarn, then
Include the proxy in your firebase app initilization code like this
import HttpsProxyAgent from 'https-proxy-agent';
import * as admin from 'firebase-admin';
...
const agent = new HttpsProxyAgent('url to your proxy server');
admin.initializeApp({
credential: admin.credential.applicationDefault(agent),
// Or any function you would like to use to provide your application's credentials
// But remember to include the proxy agent in the parameter
httpAgent: agent
});
But remember not to commit this change into your repo, since this problem appears specifically in regions without access to Google services.

Resources