Cannot get through setup with Mongo



  • Versions tested: 0.6.x & latest git master
    Server: Ubuntu Server 14.04 LTS (DigitalOcean, after dist-upgrade)
    Mongo version: 3.0.1 (from mongodb-org package on official MongoDB repo)

    I cannot seem to get ./nodebb setup to complete with mongo as the server. I'm following this process:

    • type mongo, use nodebb, and db.createUser({user: "nodebb", pwd: "passhere", roles: ["readWrite"]}).
    • edit /etc/mongod.conf, uncomment auth = true line.
    • service mongod restart as root. Successful, and I can type mongo nodebb followed by show users and see my nodebb user.
    • clone NodeBB, run npm install successfully, run ./nodebb setup.

    Here's what happens in the mongo configuration section:

    23/3 22:08 [6595] - info: Now configuring mongo database:
    Host IP or address of your MongoDB instance (127.0.0.1)
    Host port of your MongoDB instance (27017)
    MongoDB username nodebb
    Password of your MongoDB database
    Which database to use (nodebb)
    23/3 22:08 [6595] - info: Configuration Saved OK
    
    > kerberos@0.0.10 install /home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos
    > (node-gyp rebuild 2> builderror.log) || (exit 0)
    
    make: Entering directory `/home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/build'
      CXX(target) Release/obj.target/kerberos/lib/kerberos.o
    make: Leaving directory `/home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/build'
    
    > bson@0.2.21 install /home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson
    > (node-gyp rebuild 2> builderror.log) || (exit 0)
    
    make: Entering directory `/home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/build'
      CXX(target) Release/obj.target/bson/ext/bson.o
      SOLINK_MODULE(target) Release/obj.target/bson.node
      SOLINK_MODULE(target) Release/obj.target/bson.node: Finished
      COPY Release/bson.node
    make: Leaving directory `/home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/build'
    connect-mongo@0.7.0 node_modules/connect-mongo
    ├── depd@1.0.0
    ├── debug@2.1.3 (ms@0.7.0)
    └── lodash@3.5.0
    
    mongodb@2.0.23 node_modules/mongodb
    ├── readable-stream@1.0.31 (isarray@0.0.1, inherits@2.0.1, string_decoder@0.10.31, core-util-is@1.0.1)
    └── mongodb-core@1.1.19 (rimraf@2.2.6, kerberos@0.0.10, bson@0.2.21)
    23/3 22:09 [6595] - error: Error
        at Error.MongoError (/home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/lib/error.js:13:17)
        at /home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:875:28
        at ScramSHA1.auth (/home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/lib/auth/scram.js:109:25)
        at Server.auth (/home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:880:40)
        at Server.auth (/home/tom/NodeBB/node_modules/mongodb/lib/server.js:354:22)
        at Db.authenticate (/home/tom/NodeBB/node_modules/mongodb/lib/db.js:1088:21)
        at /home/tom/NodeBB/src/database/mongo.js:96:8
        at /home/tom/NodeBB/node_modules/mongodb/lib/mongo_client.js:382:15
        at process._tickCallback (node.js:419:13)
    

    I'm very comfortable in Node, and thought it was weird that the stack trace didn't have an error message. So I jumped into the code to debug, and the actual error there is that it's not succeeding to authenticate with the database. However, I can launch mongo -u nodebb -p passhere nodebb and connect with no issue.

    What REALLY blows my freakin' mind is this mongo log of everything that happens during setup -- note each connection saying Successfully authenticated as principal nodebb on nodebb:

    2015-03-23T22:38:48.220-0400 I CONTROL  ***** SERVER RESTARTED *****
    2015-03-23T22:38:48.306-0400 I JOURNAL  [initandlisten] journal dir=/var/lib/mongodb/journal
    2015-03-23T22:38:48.306-0400 I JOURNAL  [initandlisten] recover : no journal files present, no recovery needed
    2015-03-23T22:38:48.420-0400 I JOURNAL  [durability] Durability thread started
    2015-03-23T22:38:48.421-0400 I JOURNAL  [journal writer] Journal writer thread started
    2015-03-23T22:38:48.421-0400 I CONTROL  [initandlisten] MongoDB starting : pid=7088 port=27017 dbpath=/var/lib/mongodb 64-bit host=devrefinery.com
    2015-03-23T22:38:48.422-0400 I CONTROL  [initandlisten]
    2015-03-23T22:38:48.423-0400 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 3750 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.
    2015-03-23T22:38:48.423-0400 I CONTROL  [initandlisten] db version v3.0.1
    2015-03-23T22:38:48.423-0400 I CONTROL  [initandlisten] git version: 534b5a3f9d10f00cd27737fbcd951032248b5952
    2015-03-23T22:38:48.423-0400 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
    2015-03-23T22:38:48.423-0400 I CONTROL  [initandlisten] build info: Linux ip-10-167-176-91 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
    2015-03-23T22:38:48.423-0400 I CONTROL  [initandlisten] allocator: tcmalloc
    2015-03-23T22:38:48.423-0400 I CONTROL  [initandlisten] options: { config: "/etc/mongodb.conf", net: { bindIp: "127.0.0.1" }, security: { authorization: "enabled" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongodb.log" } }
    2015-03-23T22:38:48.547-0400 I NETWORK  [initandlisten] waiting for connections on port 27017
    2015-03-23T22:39:48.771-0400 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:35201 #1 (1 connection now open)
    2015-03-23T22:39:48.779-0400 I NETWORK  [conn1] end connection 127.0.0.1:35201 (0 connections now open)
    2015-03-23T22:39:48.885-0400 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:35202 #2 (1 connection now open)
    2015-03-23T22:39:48.885-0400 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:35203 #3 (2 connections now open)
    2015-03-23T22:39:48.886-0400 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:35204 #4 (3 connections now open)
    2015-03-23T22:39:48.886-0400 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:35205 #5 (4 connections now open)
    2015-03-23T22:39:48.886-0400 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:35206 #6 (5 connections now open)
    2015-03-23T22:39:48.886-0400 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:35207 #7 (6 connections now open)
    2015-03-23T22:39:48.887-0400 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:35208 #8 (7 connections now open)
    2015-03-23T22:39:48.887-0400 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:35209 #9 (8 connections now open)
    2015-03-23T22:39:48.887-0400 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:35210 #10 (9 connections now open)
    2015-03-23T22:39:48.887-0400 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:35211 #11 (10 connections now open)
    2015-03-23T22:39:49.543-0400 I ACCESS   [conn2] Successfully authenticated as principal nodebb on nodebb
    2015-03-23T22:39:49.543-0400 I ACCESS   [conn4] Successfully authenticated as principal nodebb on nodebb
    2015-03-23T22:39:50.905-0400 I ACCESS   [conn5] Successfully authenticated as principal nodebb on nodebb
    2015-03-23T22:39:50.905-0400 I ACCESS   [conn7] Successfully authenticated as principal nodebb on nodebb
    2015-03-23T22:39:50.905-0400 I ACCESS   [conn9] Successfully authenticated as principal nodebb on nodebb
    2015-03-23T22:39:50.906-0400 I ACCESS   [conn6] Successfully authenticated as principal nodebb on nodebb
    2015-03-23T22:39:50.906-0400 I ACCESS   [conn8] Successfully authenticated as principal nodebb on nodebb
    2015-03-23T22:39:50.906-0400 I ACCESS   [conn3] Successfully authenticated as principal nodebb on nodebb
    2015-03-23T22:39:50.907-0400 I ACCESS   [conn10] Successfully authenticated as principal nodebb on nodebb
    2015-03-23T22:39:50.907-0400 I ACCESS   [conn11] Successfully authenticated as principal nodebb on nodebb
    2015-03-23T22:39:50.909-0400 I NETWORK  [conn2] end connection 127.0.0.1:35202 (9 connections now open)
    2015-03-23T22:39:50.909-0400 I NETWORK  [conn3] end connection 127.0.0.1:35203 (8 connections now open)
    2015-03-23T22:39:50.910-0400 I NETWORK  [conn4] end connection 127.0.0.1:35204 (7 connections now open)
    2015-03-23T22:39:50.910-0400 I NETWORK  [conn5] end connection 127.0.0.1:35205 (6 connections now open)
    2015-03-23T22:39:50.910-0400 I NETWORK  [conn6] end connection 127.0.0.1:35206 (5 connections now open)
    2015-03-23T22:39:50.910-0400 I NETWORK  [conn7] end connection 127.0.0.1:35207 (4 connections now open)
    2015-03-23T22:39:50.910-0400 I NETWORK  [conn8] end connection 127.0.0.1:35208 (3 connections now open)
    2015-03-23T22:39:50.911-0400 I NETWORK  [conn9] end connection 127.0.0.1:35209 (2 connections now open)
    2015-03-23T22:39:50.911-0400 I NETWORK  [conn10] end connection 127.0.0.1:35210 (1 connection now open)
    2015-03-23T22:39:50.911-0400 I NETWORK  [conn11] end connection 127.0.0.1:35211 (0 connections now open)
    

    So I thought "What if I disable authentication?" I turned that switch back off, restarted mongo, ran through ./nodebb setup with a blank username and password, and viola! I make it through! But only to the next step, where everything just hangs right here:

    23/3 22:36 [6967] - info: Now configuring mongo database:
    Host IP or address of your MongoDB instance (127.0.0.1)
    Host port of your MongoDB instance (27017)
    MongoDB username
    Password of your MongoDB database
    Which database to use (nodebb)
    23/3 22:36 [6967] - info: Configuration Saved OK
    
    > kerberos@0.0.10 install /home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos
    > (node-gyp rebuild 2> builderror.log) || (exit 0)
    
    make: Entering directory `/home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/build'
      CXX(target) Release/obj.target/kerberos/lib/kerberos.o
    make: Leaving directory `/home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/build'
    
    > bson@0.2.21 install /home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson
    > (node-gyp rebuild 2> builderror.log) || (exit 0)
    
    make: Entering directory `/home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/build'
      CXX(target) Release/obj.target/bson/ext/bson.o
      SOLINK_MODULE(target) Release/obj.target/bson.node
      SOLINK_MODULE(target) Release/obj.target/bson.node: Finished
      COPY Release/bson.node
    make: Leaving directory `/home/tom/NodeBB/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/build'
    connect-mongo@0.7.0 node_modules/connect-mongo
    ├── depd@1.0.0
    ├── debug@2.1.3 (ms@0.7.0)
    └── lodash@3.5.0
    
    mongodb@2.0.23 node_modules/mongodb
    ├── readable-stream@1.0.31 (isarray@0.0.1, inherits@2.0.1, string_decoder@0.10.31, core-util-is@1.0.1)
    └── mongodb-core@1.1.19 (rimraf@2.2.6, kerberos@0.0.10, bson@0.2.21)
    23/3 22:36 [6967] - warn: You have no mongo password setup!
    23/3 22:36 [6967] - info: Populating database with default configs, if not already set...
    

    After more debugging, I see that NodeBB is trying to set a collection of keys to a certain default value by checking to see if that key exists before setting it. It's asking mongo, all at once, for the current value of that list of keys, and not getting a single response. It just hangs. The callback never gets called.

    I'm losing my mind here... especially because no one else seems to be having this problem, but my install is so vanilla that I can't imagine where I'm going wrong. Any help is appreciated!


  • Admin

    Hi if you are using mongodb 3.0.1 then please try this branch

    https://github.com/NodeBB/NodeBB/tree/mongodb-3.0-driver-2.0

    There are some issues that are fixed on this branch for example.

    https://github.com/kcbanner/connect-mongo/issues/161

    Let me know if that branch works.



  • Success!! Thank you so much! Looking forward to thing going to master.



  • Thanks @baris & @TomFrost . I encountered exactly the same problem and this is greatly helpful. 😄


  • Admin

    @yeelan0319 master branch and 0.6.1 branches should have these fixes now too.



  • @julian Thanks, I will pull and merge the latest master now. Thanks for the quick response😆


  • Anime Lovers

    I'm having the same problem, using NodeBB 0.6.1(master branch, cloned from GitHub) and MongoDB 2.6.7 on Mac OSX 10.10


 

| |

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.