fastify / fastify-mongodb

Fastify MongoDB connection plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ScaleGrid connection

johntom opened this issue · comments

After updating a production repo to testing repo 1 error is raised when attaching to a scalegrid mongodb database. If I test on local computer with the old setup it connects as designed.
// Paste your code here
Current update
"fastify": "^2.13.1",
"fastify-autoload": "^1.2.2",
"fastify-cli": "^1.5.0",
"fastify-cookie": "^3.6.0",
"fastify-cors": "^3.0.3",
"fastify-favicon": "^2.0.0",
"fastify-jwt": "^1.3.1",
"fastify-mongodb": "^1.0.1",
"fastify-multipart": "^1.0.5",
"fastify-mysql": "^1.0.0",
"fastify-plugin": "^1.6.1",
"fastify-session": "^3.3.0",
"fastify-swagger": "^2.5.1",
Previous versions:
"fastify": "^2.13.1",
"fastify-autoload": "^1.2.2",
"fastify-cli": "^1.5.0",
"fastify-cookie": "^3.6.0",
"fastify-cors": "^3.0.3",
"fastify-favicon": "^2.0.0",
"fastify-jwt": "^1.3.1",
"fastify-mongodb": "^2.0.0",
"fastify-multipart": "^1.0.5",
"fastify-mysql": "^1.0.0",
"fastify-plugin": "^1.6.1",
"fastify-session": "^3.3.0",
"fastify-swagger": "^2.5.1",

Expected behavior

MONGODB_URLmas=mongodb://admin:@SG-Brookbridge-22047.servers.mongodirector.com:48815,SG-Brookbridge-22048.servers.mongodirector.com:48815,SG-Brookbridge-22049.servers.mongodirector.com:48815/admin?replicaSet=RS-Brookbridge-0&ssl=true&databases=mas

.register(require('fastify-mongodb'), useNewUrlParser: true, url: process.env.MONGODB_URLmas, name: 'mas' })
error upon start

002===plugin================fastify mongodb======
(node:45476) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
assert.js:749
    throw newErr;
    ^

AssertionError [ERR_ASSERTION]: ifError got unwanted exception: failed to connect to server [sg-brookbridge-22049.servers.mongodirector.com:48815] on first connect [MongoNetworkError: connection 6 to sg-brookbridge-22049.servers.mongodirector.com:48815 closed]
    at wrap (D:\fastify\mongodonBRMwithFBNew\server.js:111:5)
    at ready.err (D:\fastify\mongodonBRMwithFBNew\node_modules\fastify\lib\server.js:130:31)
    at Object._encapsulateThreeParam (D:\fastify\mongodonBRMwithFBNew\node_modules\avvio\boot.js:450:13)
    at Boot.timeoutCall (D:\fastify\mongodonBRMwithFBNew\node_modules\avvio\boot.js:370:5)
    at Boot.callWithCbOrNextTick (D:\fastify\mongodonBRMwithFBNew\node_modules\avvio\boot.js:351:19)
    at release (D:\fastify\mongodonBRMwithFBNew\node_modules\fastq\queue.js:140:16)
    at Object.resume (D:\fastify\mongodonBRMwithFBNew\node_modules\fastq\queue.js:74:7)
    at Boot.Plugin.loadPlugin.call (D:\fastify\mongodonBRMwithFBNew\node_modules\avvio\boot.js:161:18)
    at toLoad.finish (D:\fastify\mongodonBRMwithFBNew\node_modules\avvio\plugin.js:190:7)
    at done (D:\fastify\mongodonBRMwithFBNew\node_modules\avvio\plugin.js:136:5)
    at Pool.<anonymous> (D:\fastify\mongodonBRMwithFBNew\node_modules\mongodb\lib\core\topologies\server.js:438:11)
    at Pool.emit (events.js:189:13)
    at createConnection (D:\fastify\mongodonBRMwithFBNew\node_modules\mongodb\lib\core\connection\pool.js:561:14)
    at connect (D:\fastify\mongodonBRMwithFBNew\node_modules\mongodb\lib\core\connection\pool.js:1008:9)
    at callback (D:\fastify\mongodonBRMwithFBNew\node_modules\mongodb\lib\core\connection\connect.js:97:5)
    at runCommand (D:\fastify\mongodonBRMwithFBNew\node_modules\mongodb\lib\core\connection\connect.js:124:7)
    at _callback (D:\fastify\mongodonBRMwithFBNew\node_modules\mongodb\lib\core\connection\connect.js:349:5)
    at Connection.errorHandler (D:\fastify\mongodonBRMwithFBNew\node_modules\mongodb\lib\core\connection\connect.js:365:5)
    at Object.onceWrapper (events.js:277:13)
    at Connection.emit (events.js:189:13)
// All other connections work (local, ObjectRocket and mlab)

Your Environment

  • node version: 10.15.3 and tested with 11.10.0
  • fastify version: >=2.0.0
  • os: Windows10

I'm unsure what the problem is. Can you connect with the plain mongodb driver? We are just passing options through.

Not sure what the issue was but after a windows update and reboot it worked again. Nothing to do with fastify, my code nor scalegrid!
Thanks!