Getting ServerSelectionTimeoutError

268 views
Skip to first unread message

Ishan

unread,
Jul 25, 2019, 2:39:17 AM7/25/19
to mongodb-user
errorMessage": "ip-10-0-4-14.us-west-2.compute.internal:27017: timed out",
  "errorType": "ServerSelectionTimeoutError",
  "stackTrace": [
    "  File \"/var/task/lambda_function.py\", line 21, in lambda_handler\n    client.fsync()\n",
    "  File \"/var/task/pymongo/mongo_client.py\", line 1909, in fsync\n    read_preference=ReadPreference.PRIMARY, **kwargs)\n",
    "  File \"/var/task/pymongo/database.py\", line 655, in command\n    read_preference) as (sock_info, slave_ok):\n",
    "  File \"/var/lang/lib/python3.7/contextlib.py\", line 112, in __enter__\n    return next(self.gen)\n",
    "  File \"/var/task/pymongo/mongo_client.py\", line 1135, in _socket_for_reads\n    server = topology.select_server(read_preference)\n",
    "  File \"/var/task/pymongo/topology.py\", line 226, in select_server\n    address))\n",
    "  File \"/var/task/pymongo/topology.py\", line 184, in select_servers\n    selector, server_timeout, address)\n",
    "  File \"/var/task/pymongo/topology.py\", line 200, in _select_servers_loop\n    self._error_message(selector))\n"


I am getting this error when I am trying to call client.fsync(). Basically I am writing a lambda function to lock the db, take snapshot and again unlock the db. Any suggestion would be helpful. My env is pymongo version 3 and python 3.7.

Kevin Adistambha

unread,
Aug 2, 2019, 1:39:28 AM8/2/19
to mongodb-user

Hi,

"errorType": "ServerSelectionTimeoutError" means that Pymongo cannot connect to the server. You might want to check the security settings of your instance.

However, why don’t you execute this function from within the EC2 instance itself, e.g. using cron to lock the instance and create an EC2 snapshot? Is there a specific reason why you need to use AWS Lambda?

For more information, there might be an alternative strategy in MongoDB Backup Methods

Best regards,
Kevin

Reply all
Reply to author
Forward
0 new messages