[JAVA-2895] Atlas connection string question Created: 26/Jun/18 Updated: 27/Oct/23 Resolved: 29/Jun/18 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Question | Priority: | Major - P3 |
| Reporter: | Max R | Assignee: | Ross Lawley |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | cluster, driver, issue, tier | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
OS Windows 10 |
||
| Attachments: |
|
| Description |
|
I've created Atlas M0 (Free Tier) cluster. (screen) I want to add db with info to this cluster. When I tried to connect to tier cluster via driver3.6 or later and wrote mongodb+srv://user:<PASSWORD>@cluster0-ox90k.mongodb.net/test?retryWrites=true, I always get an error: Connection strings must start with 'mongodb://'. Okay, I deleted the snippet +srv and wrote the same way mongodb://user:<PASSWORD>@cluster0-ox90k.mongodb.net/test?retryWrites=true and was unable to connect. So, I finally solved it via driver 3.4 or earlier, I wrote mongodb://user:<PASSWORD>@cluster0-shard-00-00-ox90k.mongodb.net:27017,cluster0-shard-00-01-ox90k.mongodb.net:27017,cluster0-shard-00-02-ox90k.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true Why did I solve it only via 3.4 driver? |
| Comments |
| Comment by Ross Lawley [ 29/Jun/18 ] |
|
Hi romax300@ukr.net, Thanks for the ticket. Connection strings starting with mongodb+srv:// are only supported when using the version 3.6+ of the Java driver. DNS resolution lookup was added in the 3.6 version of the Java driver. As such removing the +srv component of the connection string would not work / resolve to your atlas cluster. Adding the full connection string with multiple hosts is the correct way to connect to Atlas for users of the older Java drivers. However, we would recommend upgrading the driver to the latest version (3.8) to take advantage of the DNS look up and other new MongoDB features. For more information regarding connecting to atlas please see the driver connection example and the linked MongoDB Driver compatibility matrix. I hope that helps, Ross |