Having an issue connecting to an AWS Document DB cluster.
Its a standard setup cluster with 3 nodes.
The datasource is configured as follows:
DbNosql: {
name: "DbNosql",
connector: "mongodb",
url: "mongodb://user:password@<db_identifier>.docdb.amazonaws.com:27017/<db_name>?replicaSet=rs0",
useNewUrlParser: true,
poolSize: 100
},
This has worked perfectly with the below dependencies:
"@loopback/boot": "^1.5.11",
"@loopback/context": "^1.23.5",
"@loopback/core": "^1.10.7",
"@loopback/openapi-v3": "^1.10.1",
"@loopback/repository": "^1.15.4",
"@loopback/rest": "^1.23.0",
"@loopback/rest-explorer": "^1.4.4",
"@types/ejs": "^2.6.3",
"@types/uuid": "^3.4.6",
"aws-sdk": "^2.572.0",
"axios": "^0.19.0",
"bcryptjs": "^2.4.3",
"chance": "^1.1.3",
"ejs": "^2.7.2",
"http-errors": "^1.7.3",
"isemail": "^3.2.0",
"js-yaml": "^3.13.1",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.15",
"loopback-component-storage": "^3.6.3",
"loopback-connector-kv-redis": "^3.0.2",
"loopback-connector-mongodb": "^5.2.0",
"loopback-connector-mysql": "^5.4.1",
"loopback-connector-rest": "^3.6.0",
"moment": "^2.24.0",
"morgan": "^1.9.1",
"swagger-ui-dist": "^3.24.2",
"uuid": "^3.2.1",
"winston": "^3.2.1"
"@loopback/testlab": "^1.9.4",
"@types/bcryptjs": "^2.4.2",
"@types/js-yaml": "^3.12.1",
"@types/lodash": "^4.14.147",
"@types/mocha": "^5.2.7",
"@types/morgan": "^1.7.37",
"@types/node": "~10.14.22",
"copyfiles": "^2.1.1",
"mocha": "^6.2.2",
"rimraf": "^3.0.0",
"source-map-support": "^0.5.16",
"tsc-watch": "^2.4.0",
"typescript": "~3.6.4"
However when the dependencies were upgraded to:
"@loopback/boot": "^1.6.0",
"@loopback/context": "^1.25.0",
"@loopback/core": "^1.12.0",
"@loopback/openapi-v3": "^1.10.3",
"@loopback/repository": "^1.16.0",
"@loopback/rest": "^1.25.0",
"@loopback/rest-explorer": "^1.4.6",
"@types/ejs": "^2.7.0",
"@types/uuid": "^3.4.6",
"aws-sdk": "^2.597.0",
"axios": "^0.19.0",
"bcryptjs": "^2.4.3",
"chance": "^1.1.4",
"ejs": "^2.7.4",
"http-errors": "^1.7.3",
"isemail": "^3.2.0",
"js-yaml": "^3.13.1",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.15",
"loopback-component-storage": "^3.6.3",
"loopback-connector-kv-redis": "^3.0.2",
"loopback-connector-mongodb": "^5.2.1",
"loopback-connector-mysql": "^5.4.1",
"loopback-connector-rest": "^3.6.0",
"moment": "^2.24.0",
"morgan": "^1.9.1",
"swagger-ui-dist": "^3.24.3",
"uuid": "^3.2.1",
"winston": "^3.2.1"
"@loopback/testlab": "^1.10.0",
"@types/bcryptjs": "^2.4.2",
"@types/js-yaml": "^3.12.1",
"@types/lodash": "^4.14.149",
"@types/mocha": "^5.2.7",
"@types/morgan": "^1.7.37",
"@types/node": "~10.14.22",
"copyfiles": "^2.1.1",
"mocha": "^6.2.2",
"rimraf": "^3.0.0",
"source-map-support": "^0.5.16",
"tsc-watch": "^2.4.0",
"typescript": "~3.7.2"
First the app starts fine. Then when a model is called which uses a NoSql repository, I get this error:
500 Error: Timeout in connecting after 5000 ms
at Timeout._onTimeout (/project_dir/node_modules/loopback-datasource-juggler/lib/datasource.js:2617:10)
at listOnTimeout (internal/timers.js:537:17)
at processTimers (internal/timers.js:481:7)
Then shortly after the app crashes with this error:
/project_dir/node_modules/mongodb/lib/core/sdam/server_selection.js:308
new MongoTimeoutError(
^
MongoTimeoutError: Server selection timed out after 30000 ms
at Timeout._onTimeout (/project_dir/node_modules/mongodb/lib/core/sdam/server_selection.js:308:9)
at listOnTimeout (internal/timers.js:537:17)
at processTimers (internal/timers.js:481:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `yarn run build && node -r source-map-support/register .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2020-01-13T09_39_36_414Z-debug.log
My frist thought would be to downgrade the loopback-connector-mongodb package back to 5.2.0 but this did not resolve the issue.
The database is still working and I can connect to it by other means, and the app will also work fine if I use the version previously built with the dependencies listed above.
Any help would be appreciated
@technicaljones Just for the records - What was your solution?
It was down to a certificate update and different versions of the certificate being stored in source.