Is there any reason why connecting to my atlas instance can be blocked by go
Am I missing out on something like firewall settings which are tied to the app
The same uri works with the node version of the app + in the prod deployment and I should add that it stopped working randomly for my local dev env of go. I have been told the error is due to network connectivity being blocked but not sure where to start debugging this
I am using the mongo go driver.
The error is "NoReplicaSetForPrimary" it is emitted after the timeout for all types of query.
It is strange since this happened completely randomly. I have the version of this app running on cloud and it works fine. I have connected using the same uri in multiple applications and it works perfectly.
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
serverAPIOptions := options.ServerAPI(options.ServerAPIVersion1)
clientOptions := options.Client().
ApplyURI(os.Getenv("MONGODB_URI")).
SetServerAPIOptions(serverAPIOptions)
//.SetDirect(true)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
conn, merr := mongo.Connect(ctx, clientOptions)
if merr != nil {
log.Fatal(merr)
}