I am having trouble connecting to the mongoDB atlas servers when connecting to the database.I have also tried increasing timeout values.
from pymongo.mongo_client import MongoClientfrom pymongo.server_api import ServerApiuri = "mongodb+srv://KaraboM:<password>@bigdata.maa2f.mongodb.net/?retryWrites=true&w=majority&appName=BigData"# Create a new client and connect to the serverclient = MongoClient(uri, server_api=ServerApi('1'))# Send a ping to confirm a successful connectiontry: client.admin.command('ping') print("Pinged your deployment. You successfully connected to MongoDB!")except Exception as e: print(e)
Output should be:
Pinged your deployment. You successfully connected to MongoDB!
Error:
bigdata-shard-00-01.maa2f.mongodb.net:27017: timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms),bigdata-shard-00-02.maa2f.mongodb.net:27017: timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms),bigdata-shard-00-00.maa2f.mongodb.net:27017: timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms), Timeout: 30s, Topology Description: <TopologyDescription id: 66ef302b30237da477ea951b, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('bigdata-shard-00-00.maa2f.mongodb.net', 27017) server_type: Unknown, rtt: None, error=NetworkTimeout('bigdata-shard-00-00.maa2f.mongodb.net:27017: timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>, <ServerDescription ('bigdata-shard-00-01.maa2f.mongodb.net', 27017) server_type: Unknown, rtt: None, error=NetworkTimeout('bigdata-shard-00-01.maa2f.mongodb.net:27017: timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>, <ServerDescription ('bigdata-shard-00-02.maa2f.mongodb.net', 27017) server_type: Unknown, rtt: None, error=NetworkTimeout('bigdata-shard-00-02.maa2f.mongodb.net:27017: timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')> ]>