从loopback mongodb驱动程序连接时如何增加Mongolab的连接超时

时间:2021-12-15 13:00:41

I have hosted my mongodb in mongolab. I have created a ODM in loopback and made a connection to mongolab. Sometimes the connection gets established but other times due to bad connection it gets timedout. I want to increase this timeout so that it does get connected everytime. I did not find any solution even on Strongloop site.

我在mongolab主持了我的mongodb。我在环回中创建了一个ODM并建立了与mongolab的连接。有时连接会建立,但其他时候由于连接错误而导致时间延长。我想增加这个超时,以便它每次都能连接。即使在Strongloop网站上我也找不到任何解决方案。

I tried even adding a query string param in connection string for mongolab: ?connectTimeoutMS=1000000 Even this did not help.

我甚至尝试在mongolab的连接字符串中添加查询字符串参数:?connectTimeoutMS = 1000000即使这没有帮助。

1 个解决方案

#1


5  

Use the connectionTimeout setting in your dataSources.json file.

使用dataSources.json文件中的connectionTimeout设置。

{
  "YourMongoDB": {
    "name": "YourMongoDB",
    "connector": "mongodb",
    "connectionTimeout": 1000000
  }
}

#1


5  

Use the connectionTimeout setting in your dataSources.json file.

使用dataSources.json文件中的connectionTimeout设置。

{
  "YourMongoDB": {
    "name": "YourMongoDB",
    "connector": "mongodb",
    "connectionTimeout": 1000000
  }
}