-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Connections
-
None
I didn't have any problem till updating mongodb go driver today. This is the connection:
connInfo.Url is the URL of MongoDB Atlas gives me and username and password are replaced
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) client, error := mongo.NewClient(options.Client().ApplyURI(connInfo.Url)) checkError(error) //Call the connect function of client error = client.Connect(ctx) checkError(error) //Checking the connection error = client.Ping(context.TODO(), nil) if error != nil { log.Fatal(error) } fmt.Println("Connected to MongoDB!")
Result:
2019/05/09 19:42:29 Defaulting to port 8080 2019/05/09 19:42:29 Listening on port 8080 2019/05/09 19:43:07 server selection error: server selection timeout current topology: Type: ReplicaSetNoPrimary Servers: Addr: mongodev-shard-00-01-hs9hf.mongodb.net:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: (CommandNotFound) command not found Addr: mongodev-shard-00-02-hs9hf.mongodb.net:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: (CommandNotFound) command not found Addr: mongodev-shard-00-00-hs9hf.mongodb.net:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: (CommandNotFound) command not found exit status 1
It was working before go get -u go.mongodb.org/mongo-driver/mongo
- is duplicated by
-
GODRIVER-1038 MongoDB Go Driver does not connect to M0 Free Tier Instance
- Closed
-
GODRIVER-1039 mongo-go-driver fails with Server Selection Timeout when using MongoDB Atlas
- Closed
- related to
-
GODRIVER-1042 Don't add read preference for non-mongos server with OP_QUERY
- Closed