Could not connect Mongodb enabled with Replicaset from Visual studio code mongodb externsion without using direct connections

Hello All,
We have mongodb enabled with replica set.
When we tried to connect our db from visual studio code mongodb extension, facing error as server timeout.
But if i am using directionconnection=true in connection string, it is working but this directionconnection suppress replicaset enabled in db so my application is not getting connected.
Can someone help us to give mongodb connection string with replicaset to connect db.
Thanks

Could you give more information about the problem?

Like versions of your extension, database version, and error stack trace.

Hi Jennysson, I have similar issue where Despite the successful upgrade, we are encountering issues with establishing a connection to MongoDB from the IIS server. Previously, the connection string in the appsettings.json file utilized the complete replica set connection string. However, attempts to connect using the full connection string result in a timeout error after 30,000ms.

Observed Differences:
Upon further investigation, we noticed a disparity between the member configuration in the MongoDB replica set from the old setup to the new one. Specifically, the application seems to be attempting connections using the headless service, which is causing connectivity issues.

Request for Assistance:
We seek your expertise in resolving this connectivity issue and optimizing the connection string to ensure seamless communication with the MongoDB replica set. Our objective is to enable the application to establish connections using the complete replica set connection string, similar to the previous setup, thereby ensuring robust and reliable connectivity.

Your insights and assistance in addressing this matter would be greatly appreciated. Please feel free to reach out for any further clarification or collaboration required from our end.

Upgrade Details:

Modules and charts across xxxxx-Infrastructure were upgraded to ensure compatibility and prevent any deprecated functionality.
Following the upgrade, the MongoDB version was advanced from 4.2.3 to 6.0.10, along with Helm chart version 13.18.5.

Subject: Issue with MongoDB Connection from IIS Server Post-Upgrade

Dear [Application Team],

I hope this message finds you well. I wanted to provide you with an update following our today’s discussions regarding the upgrade of all modules and Helm charts in the xxxxx-Infrastructure environment.

I’m pleased to reiterate that all modules and charts within xxxxx-Infrastructure on QA environment were successfully upgraded, overcoming various challenges along the way.
This upgrade was essential to ensure compatibility, address potential issues, and eliminate any deprecated charts and Modules.
However, despite the successful upgrade, we have encountered a minor challenge related to connecting to MongoDB from the IIS server post-upgrade.

The MongoDB version was advanced from 4.2.3 to 6.0.10, alongside Helm chart version 13.18.5.

Our primary concern now revolves around establishing a connection to MongoDB from the IIS server. Despite our efforts, we are facing difficulties connecting to MongoDB using the complete replica set connection string.
Attempts to do so result in a timeout error after 30,000ms.
This is the connection string which is there always and used to connect with replicaset in old version.
“EnrichmentCluster”: {
“ConnectionString”: “mongodb://mongo-0.xxxx:27017,mongo-1.xxxxx.local:27017,mongo-2.xxxxx.local:27017/MCUploadAssistantDatabase?connect=replicaSet&replicaSet=rs0”,
“CollectionName”: “EnrichmentClusters”
},
“UploadedFiles”: {
“ConnectionString”: “mongodb://mongo-0.xxxxx.local:27017,mongo-1.xxxxx.local:27017,mongo-2.xxxxx.local:27017/MCUploadAssistantDatabase?connect=replicaSet&replicaSet=rs0”,
“CollectionName”: “UploadFiles”
},
“ValidationLog”: {
“ConnectionString”: “mongodb://mongo-0.xxxxx.local:27017,mongo-1.xxxxx.local:27017,mongo-2.xxxxx.local:27017/ValidationLog”,
“CollectionName”: “ValidationLog”
}
},

Now we have changed the connection string as mentioned below then only it connects which is not ideal condition.

Mongo": {
“EnrichmentCluster”: {
“ConnectionString”: “mongodb://mongo-0.xxxxx.local:27017/MCUploadAssistantDatabase”,
“CollectionName”: “EnrichmentClusters”
},
“UploadedFiles”: {
“ConnectionString”: “mongodb://mongo-0.xxxxx.local:27017/MCUploadAssistantDatabase”,
“CollectionName”: “UploadFiles”
},
“ValidationLog”: {
“ConnectionString”: “mongodb://mongo-0.xxxxx.local:27017/ValidationLog”,
“CollectionName”: “ValidationLog”
}
},