在连接至Atlas MongoDb时,我的Heroku托管应用出现context deadline exceeded
错误。该应用程序在本地运行时运行良好,我认为我已经通过增加从10*time.Second
开始的时间解决了该问题。根据Atlas Mongodb文档,我正在使用以下Go代码:
ctx, cancel = context.WithTimeout(context.Background(), 60000*time.Second)
client, err := mongo.Connect(ctx, options.Client().ApplyURI(
"mongodb+srv://RicXX:XXXXXXXXXXX@cluster0.o6pnq.gcp.mongodb.net/XXXXXXXX?retryWrites=true&w=majority",
))
if err != nil { log.Fatal(err) }
其他人是否遇到过此问题,或者知道可能是什么问题?