Heroku托管的应用程序连接到Atlas MongoDb时出现“超出上下文截止日期”错误

时间:2020-10-28 14:57:49

标签: mongodb go heroku

在连接至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) }

其他人是否遇到过此问题,或者知道可能是什么问题?

0 个答案:

没有答案