[GODRIVER-1039] mongo-go-driver fails with Server Selection Timeout when using MongoDB Atlas Created: 13/May/19 Updated: 13/May/19 Resolved: 13/May/19 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | None |
| Affects Version/s: | 1.0.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Ayush Gupta [X] | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
Go Version: 1.12.5 I have this code which uses the node.js mongo driver const MongoClient = require('mongodb').MongoClient; ); client.connect(async (err) => { const collection = client.db("dbname").collection("collectionName"); Which works fine. Using the `mongo-go-driver`, I do: client, err := mongo.NewClient(options.Client().ApplyURI(os.Getenv("MONGO_HOST") + "dbname?retryWrites=true") ctx, _ := context.WithTimeout(context.Background(), 10*time.Second) err = client.Connect(ctx) if err != nil { panic(err) } database := client.Database("dbname") res, err := collection.Find(context.Background(), bson.M{}, &options.FindOptions{ , results := make([]structs.ResponseType, 0) err = res.All(context.Background(), &results) if err != nil { panic(err) } But this panics with: panic: server selection error: server selection timeout I am not running this inside a container/docker. |
| Comments |
| Comment by Ayush Gupta [X] [ 13/May/19 ] |
|
I just used dep and froze on v1.0.1 and it works, so something broke after that |
| Comment by Ayush Gupta [X] [ 13/May/19 ] |
|
Version var Driver = "v1.1.0+prerelease" |
| Comment by Ayush Gupta [X] [ 13/May/19 ] |
|
A formatted version of the issue/question can be found at https://stackoverflow.com/questions/56111999/mongo-go-driver-fails-with-server-selection-timeout-when-using-mongodb-atlas |