I'm running a Node.js server on a Google Cloud Platform (GCP) Virtual Machine. This server interacts with the Twitter V2 API to search for tweets. Everything runs smoothly as long as I stick to the default ephemeral IP address provided by GCP for the VM.
However, as soon as I switch to using a reserved, permanent external IP address that I reserved from GCP, I start getting read ECONNRESET errors from the Twitter API servers. It's worth noting that I only get this error for about 40% of the calls, while the other 60% pass without any errors.
Here are some more info regarding the reserved external IP:
- The IP is in the same region as the VM (asia-east1-b).
- It does not make a difference if I choose a 'Premium' or a 'Standard' network service tier.
- It's IPv4.
EDIT: I also discovered that changing the VM back from the external IP to the ephemeral still produced the same error. To eliminate the error, I'd have to completely delete the VM and create a new one using a machine image I have.
There can be a lot of points you need to check in order for you to determine the cause of the ECONNRESET error. Based on the information at hand, it seems like it's an intermittent disconnection. You may consider using vpc flow logs for you to have better visibility of the traffic.[1] Also, you may want to double check the firewalls on both ends as this may be a factor.
Regarding the network tier, the main difference between a standard and premium tier is that the premium tier basically as the name states is all about performance while the standard tier is aligned on the cost-effectivity. I attached the documentation for the networks tiers as a supplementary read.[2]
[1] https://cloud.google.com/vpc/docs/using-flow-logs
[2] https://cloud.google.com/network-tiers/docs/overview