Conection error with MongoDB

Can someone explain to me how to effectively connect to the Mongo server so that I can create a vector database? I am studying the course provided on the DeepLearningAI platform and implementing the steps in my own Google Colab. When I execute the following code snippets, I encounter the error shown below.

MONGO_URI = "mongodb+srv://BrunoLoducca:<password>@brunolod.xoargtz.mongodb.net/?appName=BrunoLod"

os.environ["MONGODB_URI"] = MONGO_URI

# Creating a function that extracts the client, which allows access 
# and creation of vector databases in MongoDB.

def get_mongo_client(mongo_uri): 

  client = MongoClient(mongo_uri, appname = "deeplearningai.lesson1", 
                       server_api=ServerApi('1'))
  
  # Send a ping to confirm a successful connection
  try:
    client.admin.command('ping')
    print("Pinged your deployment. You successfully connected to MongoDB!")
    return client
  
  except Exception as e:
    print(e)
    return None

error:

SSL handshake failed: ac-jaaodbx-shard-00-00.xoargtz.mongodb.net:27017: [SSL: TLSV1_ALERT_INTERNAL_ERROR] tlsv1 alert internal error (_ssl.c:1007) (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms),SSL handshake failed: ac-jaaodbx-shard-00-01.xoargtz.mongodb.net:27017: [SSL: TLSV1_ALERT_INTERNAL_ERROR] tlsv1 alert internal error (_ssl.c:1007) (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms),SSL handshake failed: ac-jaaodbx-shard-00-02.xoargtz.mongodb.net:27017: [SSL: TLSV1_ALERT_INTERNAL_ERROR] tlsv1 alert internal error (_ssl.c:1007) (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms), Timeout: 30s, Topology Description: <TopologyDescription id: 66a263b80cdcecaefd992eb9, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-jaaodbx-shard-00-00.xoargtz.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('SSL handshake failed: ac-jaaodbx-shard-00-00.xoargtz.mongodb.net:27017: [SSL: TLSV1_ALERT_INTERNAL_ERROR] tlsv1 alert internal error (_ssl.c:1007) (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>, <ServerDescription ('ac-jaaodbx-shard-00-01.xoargtz.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('SSL handshake failed: ac-jaaodbx-shard-00-01.xoargtz.mongodb.net:27017: [SSL: TLSV1_ALERT_INTERNAL_ERROR] tlsv1 alert internal error (_ssl.c:1007) (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>, <ServerDescription ('ac-jaaodbx-shard-00-02.xoargtz.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('SSL handshake failed: ac-jaaodbx-shard-00-02.xoargtz.mongodb.net:27017: [SSL: TLSV1_ALERT_INTERNAL_ERROR] tlsv1 alert internal error (_ssl.c:1007) (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>]>

Are you blocked behind a firewall?

1 Like

Hi @Bruno_Loducca!

Similar to @Jack_Woehr’s question, you might need to make sure that you whitelist the IP address that corresponds with your colab notebook. You should see an alert for this within the Atlas UI when in the cluster page.

Let me know if that helps,
Henry

1 Like