[GODRIVER-835] Querying Atlas sandbox cluster returns server selection timeout Created: 18/Feb/19  Updated: 14/Mar/19  Resolved: 14/Mar/19

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

Type: Bug Priority: Major - P3
Reporter: Junaid Warwani Assignee: Scott L'Hommedieu (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Atlas Sandbox replica cluster with 3 nodes, deployed on AWS M0 instances, Version 4.0.6


Issue Links:
Duplicate
duplicates GODRIVER-351 Investigate Darwin root certs Go bug ... Closed

 Description   

I'm able to connect to an Atlas-hosted sandbox replica set cluster, but running any subsequent query (e.g. drop collection) is returning the following error:

Database connection established
panic: server selection error: server selection timeout
current topology: Type: ReplicaSetNoPrimary
Servers:
Addr: <address0>, Type: Unknown, State: Connected, Avergage RTT: 0, Last error: x509: certificate signed by unknown authority
Addr: <address1>, Type: Unknown, State: Connected, Avergage RTT: 0, Last error: x509: certificate signed by unknown authority
Addr: <address2>, Type: Unknown, State: Connected, Avergage RTT: 0, Last error: x509: certificate signed by unknown authority

The code I'm using to connect is this:

package main
 
import (
    "fmt"
    "github.com/mongodb/mongo-go-driver/mongo"
    "context"
)
 
func main() {
    client, err := mongo.NewClient("<srv-connection-string>")
    if err != nil {
        panic(err)
    }
    if err := client.Connect(context.Background()); err != nil {
        panic(err)
    }
    db := client.Database("test")
    fmt.Println("Database connection established")
    if err := db.Collection("messages").Drop(context.Background()); err != nil {
        panic(err)
    }
}

Connecting via Python works:

>>> import pymongo
>>> client = pymongo.MongoClient("<srv-connection-string>")
>>> db = client.test
>>> print(db.messages.insert_one({"a": 1}))
<pymongo.results.InsertOneResult object at 0x107fe22c8>
>>> db.messages.find_one()
{'_id': ObjectId('5c6aec3224444fbd3fa43121'), 'a': 1} 
>>> print(db.messages.drop())
None
>>> print(db.messages.find_one())
None

 

 



 Comments   
Comment by Scott L'Hommedieu (Inactive) [ 14/Mar/19 ]

DUP OF  GODRIVER-351

Comment by Junaid Warwani [ 13/Mar/19 ]

You're right! It is related to GODRIVER-351. I found the cert in my settings and changing it from `Use default settings` to `Always trust` which fixed the issue.

Comment by Scott L'Hommedieu (Inactive) [ 12/Mar/19 ]

Can you provide your system info and go version.  

It's possible that there are some issues related to GODRIVER-351

Comment by Junaid Warwani [ 12/Mar/19 ]

Why would I have an issue with validating the cert with the go driver but not the python driver or the mongo shell? What is the go driver doing that's different than the python driver / mongo shell? 

I'm able to connect and run queries with the mongo shell, so I'm failing to see how this could be an issue on my side, unless you've got a suggestion?

Comment by Scott L'Hommedieu (Inactive) [ 12/Mar/19 ]

It looks like you are having issues specifically with validating x509 certs.  

The error is occuring on first operation because the driver has deferred the connection and auth until the operation occurs. 

 

Comment by Junaid Warwani [ 22/Feb/19 ]

I tried running your code, and got the same error. It panicked after getting an error at `insertResult, err := collection.InsertOne(context.TODO(), ash)`:

$go run main1.go 
Database connection established
panic: server selection error: server selection timeout
current topology: Type: ReplicaSetNoPrimary
Servers:
Addr: <>, Type: Unknown, State: Connected, Avergage RTT: 0, Last error: x509: certificate signed by unknown authority
Addr: <>, Type: Unknown, State: Connected, Avergage RTT: 0, Last error: x509: certificate signed by unknown authority
Addr:<>, Type: Unknown, State: Connected, Avergage RTT: 0, Last error: x509: certificate signed by unknown authority

I do have the latest go driver–version 0.3.0.

Our Atlas cluster has the following config:

  • Instance size: M0 (General)
  • Region: AWS / N. Virginia (us-east-1)
  • Type: Replica Set - 3 nodes
  • Linked Stitch App: None Linked
  • MongoDB Version: 4.0.6

It is also connected to our VPC via Peering.

Comment by Scott L'Hommedieu (Inactive) [ 22/Feb/19 ]

I've run this code successfully against an atlas 4.0.6 3 node replset.  Can you try this in your setup and report back the results?

Do you have the latest go driver? Can you share config details of your atlas cluster?

 

Comment by Junaid Warwani [ 22/Feb/19 ]

Additionally, the code works with mongo running locally.

Comment by Junaid Warwani [ 22/Feb/19 ]

I have confirmed that I can connect with pymongo and with the shell, and run queries on both. I'm only having trouble with the go driver, where I can connect but any subsequent query is failing.

Comment by Junaid Warwani [ 22/Feb/19 ]

I don't know what other details would be relevant. Ours is a sandbox cluster–not sure if that makes a difference.

Is there anything else that could affect this? Is there some sort of configuration dump I can get from our cluster that might help you debug the issue?

Comment by Scott L'Hommedieu (Inactive) [ 21/Feb/19 ]

I don't have any issue running this code (with driver on master) or other examples against a 4.0.6 3-node repl set in Atlas.  

Are there any other details that I'm missing?

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