[Functions] Problem with connecting to MongoDB Atlas

357 views
Skip to first unread message

Alexis LEBLOND

unread,
Apr 29, 2017, 10:44:23 AM4/29/17
to Firebase Google Group
Hi,

In my Firebase Functions, I need to connect to a MongoDB Atlas Database with mongoose. I saw that the Spark Plan "allows outbound network requests only to Google-owned services".
So I went for the Blake Plan, but I still got an error in the functions logs :
connection error: { MongoError: authentication fail at Function.MongoError.create (/user_code/node_modules/mongoose/node_modules/mongodb-core/lib/error.js:31:11) at /user_code/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/replset.js:1170:38 at /user_code/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:730:7 at /user_code/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:706:20 at finish (/user_code/node_modules/mongoose/node_modules/mongodb-core/lib/auth/scram.js:163:16) at handleEnd (/user_code/node_modules/mongoose/node_modules/mongodb-core/lib/auth/scram.js:173:7) at Object.cb (/user_code/node_modules/mongoose/node_modules/mongodb-core/lib/auth/scram.js:273:11) at Connection.<anonymous> (/user_code/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:243:32) at Connection.g (events.js:291:16) at emitTwo (events.js:106:13) at Connection.emit (events.js:191:7) at TLSSocket.<anonymous> (/user_code/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:185:10) at TLSSocket.g (events.js:291:16) at emitNone (events.js:86:13) at TLSSocket.emit (events.js:185:7) at TLSSocket.Socket._onTimeout (net.js:339:8) name: 'MongoError', message: 'authentication fail', errors: [ { name: 'clustersomwer-shard-00-02-znghe.mongodb.net:27017', err: [Object] } ] }
connection error: { MongoError: authentication fail
    at Function.MongoError.create (/user_code/node_modules/mongoose/node_modules/mongodb-core/lib/error.js:31:11)
    at /user_code/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/replset.js:1170:38
    at /user_code/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:730:7
    at /user_code/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:706:20
    at finish (/user_code/node_modules/mongoose/node_modules/mongodb-core/lib/auth/scram.js:163:16)
    at handleEnd (/user_code/node_modules/mongoose/node_modules/mongodb-core/lib/auth/scram.js:173:7)
    at Object.cb (/user_code/node_modules/mongoose/node_modules/mongodb-core/lib/auth/scram.js:273:11)
    at Connection.<anonymous> (/user_code/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:243:32)
    at Connection.g (events.js:291:16)
    at emitTwo (events.js:106:13)
    at Connection.emit (events.js:191:7)
    at TLSSocket.<anonymous> (/user_code/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:185:10)
    at TLSSocket.g (events.js:291:16)
    at emitNone (events.js:86:13)
    at TLSSocket.emit (events.js:185:7)
    at TLSSocket.Socket._onTimeout (net.js:339:8)
  name: 'MongoError',
  message: 'authentication fail',
  errors: 
   [ { name: 'XXXXX.mongodb.net:27017',
       err: [Object] } ] }

I didn't find any solution to my problem.
By the way, the connection worked on my own NodeJS server, so I can't figure out why it is not working here, maybe it is allowed to requests only Google Services for all Plan ?

Thanks !

Kato Richardson

unread,
May 1, 2017, 3:26:32 PM5/1/17
to Firebase Google Group
Alexis,

That doesn't look like a problem with the outgoing HTTP connection; that looks like an issue with the Mongo auth credentials. I'd start there : )

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/80a2bc25-d022-4eea-817a-f529132105c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Reply all
Reply to author
Forward
0 new messages