App Engine, pymongo.errors.ServerSelectionTimeoutError: connection closed,connection closed,connection closed"

Andresse Njeungoue picture Andresse Njeungoue · Mar 5, 2019 · Viewed 9.1k times · Source

I'm using Python 3.7 and Flask 1.0.2

I plugged my app to mongoDB Atlas, and all works fine in local

client = pymongo.MongoClient(connector)

connector is my standard connection string given by Atlas

connector = "mongodb://xxx:<PASSWORD>@xxcluster-shard-00-00-y0phk.gcp.mongodb.net:27017,xxcluster-shard-00-01-y0phk.gcp.mongodb.net:27017,xxxcluster-shard-00-02-y0phk.gcp.mongodb.net:27017/test?ssl=true&replicaSet=xxxCluster-shard-0&authSource=admin&retryWrites=true"

When I deploy my app to Google App Engine standard Python3 runtime environment, it does not works. Would anyone have an idea of the problem?

Code: enter image description here Log of Appengine: enter image description here

Local log(works fine in local): enter image description here

Appengine error:

pymongo.errors.ServerSelectionTimeoutError: connection closed,connection closed,connection closed"

Answer

Andresse Njeungoue picture Andresse Njeungoue · Mar 6, 2019

The problem was the Ip Whitelist, thus I have add via the vpc peering connection with gcp.

To do simple, we can add 0.0.0.0/0 to allow access from anywhere(but, be careful)

.