[GODRIVER-1208] Connect to MongoDB Atlas Sandbox M0 instance Created: 28/Jul/19  Updated: 11/Sep/19  Resolved: 30/Aug/19

Status: Closed
Project: Go Driver
Component/s: Connections
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Alexander La Bianca Assignee: Divjot Arora (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 18.04 (DigitalOcean)



 Description   

Hello,

I am trying to connect a sample go app hosted on a DigitalOcean droplet to a MongoDB sandbox instance. This works fine locally. I build the app using Docker. 

I am using the connection method listed at link [https://docs.atlas.mongodb.com/driver-connection/#driver-examples]

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
client, err := mongo.Connect(ctx, options.Client().ApplyURI(
   "mongodb+srv://<username>:<password>@<cluster-address>/test?w=majority",
))
if err != nil { log.Fatal(err) }

I am getting the following error on application startup:

2019/07/28 20:04:05 server selection error: server selection timeout
current topology: Type: ReplicaSetNoPrimary
Servers:
Addr: rapi0-shard-00-01-yqd60.mongodb.net:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : x509: certificate signed by unknown authority
Addr: rapi0-shard-00-02-yqd60.mongodb.net:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : x509: certificate signed by unknown authority
Addr: rapi0-shard-00-00-yqd60.mongodb.net:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : x509: certificate signed by unknown authority

Looks like it is SSL related. I am confused as to why I don't need to specify any ssl specify configuration when I run my code locally, but I do when I run it remotely on digital ocean. 

 

Please let me know if you need any more info. 

I have already looked at the related issue link GODRIVER-835, but not sure how to fix it on my end. 



 Comments   
Comment by Divjot Arora (Inactive) [ 30/Aug/19 ]

labianca.alex@gmail.com Great to hear that! I'm going to close out this issue.

Comment by Alexander La Bianca [ 30/Aug/19 ]

divjot.arora@mongodb.com That did not solve the issue, but upgrading to Go version 1.12 solved the issue. I was previously on version 1.11.2

I posted on stackoverflow https://stackoverflow.com/questions/57235190/official-mongodb-go-driver-heroku-connection-to-mongodb-atlas-sandbox

Comment by Divjot Arora (Inactive) [ 30/Aug/19 ]

labianca.alex@gmail.com For the reporter of GODRIVER-835, changing the settings for the cert from "Use default settings" to "Always trust" fixed the issue. Can you see if something similar would fix it for you?

Generated at Thu Feb 08 08:35:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.