Skip to content

Timeout error doing db.list_collection_names() in CosmosDB-MongoDB-vCore_AzureOpenAI_Tutorial.ipynb #37

Open

Description

@francesco-bellei

Hi, I'm trying the tutorial notebook for CosmosDB-MongoDB-vCore.
I have no problems connecting with:

mongo_conn = "mongodb+srv://"+urllib.parse.quote(COSMOS_MONGO_USER)+":"+urllib.parse.quote(COSMOS_MONGO_PWD)+"@"+COSMOS_MONGO_SERVER+"?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000"
mongo_client = pymongo.MongoClient(mongo_conn)

But then when creating the the DB and listing collection names with:

db = mongo_client['ExampleDB']
COLLECTION_NAME = "ExampleCollection"
collection = db[COLLECTION_NAME]
if COLLECTION_NAME not in db.list_collection_names():
    db.create_collection(COLLECTION_NAME)

the call of:

db.list_collection_names()

doesn't go through and return the error:

ServerSelectionTimeoutError: c.cosmos-db-openai-explore.mongocluster.cosmos.azure.com:10260: timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms), Timeout: 30s, Topology Description: <TopologyDescription id: 6602e5685fa5c332a820d706, topology_type: Unknown, servers: [<ServerDescription ('c.cosmos-db-openai-explore.mongocluster.cosmos.azure.com', 10260) server_type: Unknown, rtt: None, error=NetworkTimeout('c.cosmos-db-openai-explore.mongocluster.cosmos.azure.com:10260: timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>]>

Any advice? Thanks in advance!

Activity

  1. francesco-bellei commented on Mar 28, 2024

    @francesco-bellei
    Author

    Good evening, I have already tried adding a rule to the firewall as suggested here to fix the issue:
    https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/troubleshoot-common-issues?source=recommendations#unable-to-connect-to-azure-cosmos-db-for-mongodb-vcore---timeout-error

    But I still get the same timeout error.
    Any help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions