i have a node.js application running from my local mac. I use it connect to AzureCosmos db instances which have public access enabled without error.
I created a cosmosdb instance with private-endpoint and public access enabled.
In my node.js application i use the endpoint which is public(i.e without private endpoint enabled)
the privatelink format is
testcosmosdb.privatelink.mongo.cosmos.azure.com
In my node.js application i use the endpoint which is public(i.e without private endpoint in the string, testcosmosdb.mongo.cosmos.azure.com
)
MONGODB_CONNECTION="mongodb://testcosmosdb:xR7xqQPOeMegN2LuXPVt5IUwb9HsGEyC0mkASzNwlmb6PEwehRkZCNpfrCxHHErqyP7lCXjxjWwACDbftND3w==@testcosmosdb.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@testcosmosdb@"
getting this error when the app tries to retrieve collection from cosmosdb:
MongoServerSelectionError: connection <monitor> to 20.63.92.0:10255 closed
at Timeout._onTimeout (/my-dev/node_modules/mongodb/lib/sdam/topology.js:277:38)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7) {
reason: TopologyDescription {
type: 'ReplicaSetNoPrimary',
servers: Map(1) {
'testcosmosdb.mongo.cosmos.azure.com:10255' => [ServerDescription]
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: 'globaldb',
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined,
[Symbol(errorLabels)]: Set(0) {}
} [
'MongoServerSelectionError: connection <monitor> to 20.63.92.0:10255 closed',
' at Timeout._onTimeout (/my-dev/node_modules/mongodb/lib/sdam/topology.js:277:38)',
' at listOnTimeout (node:internal/timers:559:17)',
' at processTimers (node:internal/timers:502:7)'
]
I am not getting this error for cosmosdb instances with just public access and no private endpoints.
if i do ns lookup i am getting proper response
nslookup testcosmosdb.mongo.cosmos.azure.com
Server: 3201:1200:61a9:6b1c::ee
Address: 2301:3900:71c9:5f1c::8e#53
Non-authoritative answer:
testcosmosdb.mongo.cosmos.azure.com canonical name = testcosmosdb.privatelink.mongo.cosmos.azure.com.
testcosmosdb.privatelink.mongo.cosmos.azure.com canonical name = ces-ms-prod-westeurope1-fe1.westeurope.cloudapp.azure.com.
Name: ces-ms-prod-westeurope1-fe1.westeurope.cloudapp.azure.com
Address: 20.63.92.0
Can anyone help here? Thanks