Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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"

like image 618
Andresse Njeungoue Avatar asked Mar 05 '19 14:03

Andresse Njeungoue


2 Answers

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)

.

like image 175
Andresse Njeungoue Avatar answered Sep 27 '22 23:09

Andresse Njeungoue


In my case, I had ssl=False. Hope this helps someone!

like image 33
bwl1289 Avatar answered Sep 28 '22 00:09

bwl1289