PRAKHAR KAUSHIK
PRAKHAR KAUSHIK

Reputation: 133

Trying to Connect to azure cosmos client using python, Gives 104 connection aborted error

Okay so I have an azure cosmos subscription, where I have created a Mongo DB resource, Now when I am using python SDK to connect it, now it's given when 104, error, connection reset by peer.

Now I am not sure what's the issue, I am using endpoint with SSL True and Primary Key.

code
endpoint = "http://XXX.mongo.cosmos.azure.com:10255/?ssl=true"
key = 'xxxxxxxxxxxxxxxx'

# <create_cosmos_client>
client = CosmosClient(endpoint, key)

Upvotes: 2

Views: 1175

Answers (1)

David Makogon
David Makogon

Reputation: 71024

When choosing the MongoDB API, you must use a native MongoDB SDK (in your case, pymongo); the wire protocol is MongoDB, and operations are performed via the same protocol as MongoDB.

Your code is attempting to use the Cosmos DB SDK, which is specific to, and will only work with, the Core (SQL) API.

If you look in the portal blade for your MongoDB-API instance, you'll see examples under Quick Start tab, which each use a MongoDB SDK in its examples (or the mongo shell). Same thing with the Connection Strings tab, showing native MongoDB connection strings (as well as the separate parts of the connection string).

Upvotes: 1

Related Questions