Hi All
I have a mongodb database wrapped inside Azure CosmosDB, I am using a node.js v16.17.1 application using the backend as azure CosmosDB. This application is deployed as a ContainerApp in Azure, there it is working fine while connecting to cosmos-db.
When I connect through localhost:5173:
It was working fine, but suddenly i am getting the below error from a particular day.
MongoServerSelectionError: Server selection timed out after 30000 ms
at Timeout._onTimeout (node_modules/mongodb/lib/sdam/topology.js:291:38)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7) {
reason: TopologyDescription {
type: 'ReplicaSetNoPrimary',
servers: Map(1) {
'my-db.mongo.cosmos.azure.com:10255' => ServerDescription {
address: my-db.mongo.cosmos.azure.com:10255',
type: 'Unknown',
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 7381815,
lastWriteDate: 0,
error: null,
topologyVersion: null,
setName: null,
setVersion: null,
electionId: null,
logicalSessionTimeoutMinutes: null,
primary: null,
me: null,
'$clusterTime': null
}
},
Even though the error show Server selection timed out after 30000 ms
it does not take that much time too.
There are no permissions or network issue as I have allowed public network access to the db instance and it was always working.
even from mongsh <connectionstring>
i am getting the same error.
Connection : is through my home wifi network which uses wpa2 personal. Before sometime back i was using wpa security. I am using a mac . My organization disallowed wpa security so i switched to wpa2 and ever since i notice this error when connecting from my localhost with my wifi network
ConnectionString:
mongodb://my-db-:abcdefghijklmnopqrst==@my-db.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@my-db@
Mobile hotspot:
Able to connect with my mobile-hotspot in the same machine to the same remote db without any errors.
Tried this will different versions of node.js and mongodb libraries including latest but the same error .
Can any one help here? Thanks