Hi,
We developed REST API using AWS Lambda. In these lambda we connect to Atlas MongoDB (we tested M1 to M3 instances). During performance test that we recently executed we notices following errors (reported by Python MongoDB client). There are two types of errors:
[ERROR] ServerSelectionTimeoutError: No replica set members match selector "Primary()", Timeout: 1.0s, Topology Description: <TopologyDescription id: 65b8bcfbb1668c0d7aca80ae, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('aws-prod-prod-shard-00-00.rip0z.mongodb.net', 27017) server_type: RSSecondary, rtt: 0.007091070000001309>, <ServerDescription ('aws-prod-prod-shard-00-01.rip0z.mongodb.net', 27017) server_type: RSSecondary, rtt: 0.018172891799986247>, <ServerDescription ('aws-prod-prod-shard-00-02.rip0z.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('SSL handshake failed: aws-prod-prod-shard-00-02.rip0z.mongodb.net:27017: EOF occurred in violation of protocol (_ssl.c:1006) (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>]>
Traceback (most recent call last):
File "/var/lang/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/var/task/handler.py", line 14, in <module>
from lib.platform.defaults import get_platform_dependent_defaults
File "/var/task/lib/platform/defaults.py", line 36, in <module>
from lib.access_layer.mongodb.mdb_access_layer import TTMongoDBAccessLayer
File "/var/task/lib/access_layer/mongodb/mdb_access_layer.py", line 13, in <module>
from lib.connections.prime_db_connection import default_mongo_client
File "/var/task/lib/connections/prime_db_connection.py", line 69, in <module>
default_mongo_client = _initialize_mongodb_client()
File "/var/task/lib/connections/prime_db_connection.py", line 60, in _initialize_mongodb_client
mongo_client.admin.command('ping') # blocks until connected
File "/var/task/pymongo/_csot.py", line 107, in csot_wrapper
return func(self, *args, **kwargs)
File "/var/task/pymongo/database.py", line 890, in command
with self.__client._conn_for_reads(read_preference, session) as (
File "/var/task/pymongo/mongo_client.py", line 1346, in _conn_for_reads
server = self._select_server(read_preference, session)
File "/var/task/pymongo/mongo_client.py", line 1303, in _select_server
server = topology.select_server(server_selector)
File "/var/task/pymongo/topology.py", line 302, in select_server
server = self._select_server(selector, server_selection_timeout, address)
File "/var/task/pymongo/topology.py", line 286, in _select_server
servers = self.select_servers(selector, server_selection_timeout, address)
File "/var/task/pymongo/topology.py", line 237, in select_servers
server_descriptions = self._select_servers_loop(selector, server_timeout, address)
File "/var/task/pymongo/topology.py", line 259, in _select_servers_loop
raise ServerSelectionTimeoutError(
and second type of error:
[ERROR] ServerSelectionTimeoutError: SSL handshake failed: aws-prod-prod-shard-00-02.rip0z.mongodb.net:27017: EOF occurred in violation of protocol (_ssl.c:1006) (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms), Timeout: 1.0s, Topology Description: <TopologyDescription id: 65b8bcfbdd51187a286bc39f, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('aws-prod-prod-shard-00-00.rip0z.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('aws-prod-prod-shard-00-01.rip0z.mongodb.net', 27017) server_type: Unknown, rtt: None>, <ServerDescription ('aws-prod-prod-shard-00-02.rip0z.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('SSL handshake failed: aws-prod-prod-shard-00-02.rip0z.mongodb.net:27017: EOF occurred in violation of protocol (_ssl.c:1006) (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>]>
Traceback (most recent call last):
File "/var/lang/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/var/task/handler.py", line 14, in <module>
from lib.platform.defaults import get_platform_dependent_defaults
File "/var/task/lib/platform/defaults.py", line 36, in <module>
from lib.access_layer.mongodb.mdb_access_layer import TTMongoDBAccessLayer
File "/var/task/lib/access_layer/mongodb/mdb_access_layer.py", line 13, in <module>
from lib.connections.prime_db_connection import default_mongo_client
File "/var/task/lib/connections/prime_db_connection.py", line 69, in <module>
default_mongo_client = _initialize_mongodb_client()
File "/var/task/lib/connections/prime_db_connection.py", line 60, in _initialize_mongodb_client
mongo_client.admin.command('ping') # blocks until connected
File "/var/task/pymongo/_csot.py", line 107, in csot_wrapper
return func(self, *args, **kwargs)
File "/var/task/pymongo/database.py", line 890, in command
with self.__client._conn_for_reads(read_preference, session) as (
File "/var/task/pymongo/mongo_client.py", line 1346, in _conn_for_reads
server = self._select_server(read_preference, session)
File "/var/task/pymongo/mongo_client.py", line 1303, in _select_server
server = topology.select_server(server_selector)
File "/var/task/pymongo/topology.py", line 302, in select_server
server = self._select_server(selector, server_selection_timeout, address)
File "/var/task/pymongo/topology.py", line 286, in _select_server
servers = self.select_servers(selector, server_selection_timeout, address)
File "/var/task/pymongo/topology.py", line 237, in select_servers
server_descriptions = self._select_servers_loop(selector, server_timeout, address)
File "/var/task/pymongo/topology.py", line 259, in _select_servers_loop
raise ServerSelectionTimeoutError(
Does this mean we should choose a more powerful MongoDB instance? Or do we need to change some instance settings?