Answer a question

I've set up the peering connection between MongoDB Atlas and Googles "default" VPC and the connection is labeled as "active" on both ends.

The ip range of the vpc is whitelisted in MongoDB Atlas.

But my node hosted in google-app-engine still gets timed out when accessing the MongoDB.

I use the connection url of mongodb atlas for peered connection in the form of (notice the "-pri"):

mongodb+srv://<username>:<password>@<my-cluster>-pri.rthhs.mongodb.net/<dbname>?retryWrites=true&w=majority

Which part am i missing to establich the connection? Do i need a google vpc connector?

Thanks for any help!

Answers

First of all, make sure you are running M10-Cluster or above!!! VPC-peering is not available for M0/M2/M5...

And YES you do need that connector! All "Serverless"-Services from Gcloud (like GAE in standard environment) need it.

  1. create a connector in the same region as your GAE-App following these instructions. You can find the current region of your GAE-App with gcloud app describe

  2. your app.yaml has to point to that connector like this

app.yaml

runtime: nodejs10

vpc_access_connector:
  name: projects/GCLOUD_PROJECT_ID/locations/REGION_WHERE_GAE_RUNS/connectors/NAME_YOU_ENTERED_IN_STEP_1
  1. Go to your Atlas project, navigate to Network Access and whitelist the IP-range you set for the connector in Step 1

  2. You may also need to whitelist the IP-range from Step 1 for the VPC-Network. You can do that in GCP by navigating to VPC-Network -> Firewall

If you have questions about how to setup the VPC-Peering between Atlas and Gcloud try this tutorial. They do it for Kubernetes-Engine (no connector needed). But adding my steps from above will hopefully do the trick.

Logo

MongoDB社区为您提供最前沿的新闻资讯和知识内容

更多推荐