[COMPASS-4960] directConnection still applied to connection when it is changed to srv after failed connection attempt Created: 20/Jul/21  Updated: 27/Oct/23  Resolved: 07/Feb/22

Status: Closed
Project: Compass
Component/s: Connectivity
Affects Version/s: None
Fix Version/s: 1.31.0

Type: Bug Priority: Major - P3
Reporter: Rhys Howell Assignee: Unassigned
Resolution: Gone away Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File srv connect fail.mp4    
Epic Link: COMPASS-4948
Documentation Changes: Not Needed
Sprint: Iteration Geneva

 Description   

Repro (vid attached):
Connect to a single connection that fails (localhost:27099), cancel the connection. Fill in a connection string with `mongodb+srv` and try connecting, it will fail with `directConnection not supported with SRV URI`
We probably need to update where we are setting the `directConnection` on a connection



 Comments   
Comment by Rhys Howell [ 07/Feb/22 ]

This has gone away with the new connection form.

Comment by Junio Silva [ 03/Sep/21 ]

I recently faced a similar issue. The difference is that I was not using SRV records.

In my case:

  • I was connecting to a Replica Set without SRV records
  • I created the connection, pointing to a replica set node, but forgot to add the Replica Set Name in the More Options section
  • The connection failed, with the following message: **
    An error occurred while loading navigation: 'not master and slaveOk=false': It is recommended to change your read preference in the connection dialog to Primary Preferred or Secondary Preferred or provide a replica set name for a full topology connection.
     
  • I went to the More Options and added the Replica Set name, saved, and tried again. I got the same error. 
  • When changing into the connection string mode, I was inspecting it and realized that both options were set: replicaSet and directConnection=true

 
&replicaSet=<ReplicaSetName>&readPreference=primary&appname=MongoDB%20Compass&directConnection=true
 

  • Something I noticed is that even if you set directConnection to false or remove it from the connection string, it was being added again (as true) (together with the replicaSet parameter). 
  • The only solution to me was to delete the connection and create a new one, making sure Replica Set Name was filled before I hit the Connect button

 

I was using MongoDB Compass 1.27.1 for Ubuntu 64bit

Generated at Wed Feb 07 22:37:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.