I have a node application which calls several google apis. It is deployed to cloud run, and I frequently see errors when it attempts to talk to googles APIs (I am using the google supplied node libraries). Errors take the form of:
{ "message": "request to https://oauth2.googleapis.com/token failed, reason: socket hang up", "type": "system", "errno": "ECONNRESET", "code": "ECONNRESET", "config": { "method": "POST", "url": "https://oauth2.googleapis.com/token", "data": "refresh_token=&client_id=&client_secret=&grant_type=refresh_token", "headers": { "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "google-api-nodejs-client/8.1.0", "x-goog-api-client": "gl-node/16.16.0 auth/8.1.0", "Accept": "application/json" }, "body": "refresh_token=&client_id=&client_secret=&grant_type=refresh_token", "responseType": "json" } }
And
FetchError: request to https://gmail.googleapis.com/gmail/v1/users/me/messages/xxxxxformat=full failed, reason: Client network socket disconnected before secure TLS connection was established
They are not consistent, but happen pretty often, I've never seen this error when I run the apps locally, nor was it happening from app engine. Does anyone know any tricks to make outbound connections on cloud run less flakey?