Rocket.Chat - SLACK alternative (with MongoDB as backend)

Docker Rocket.Chat - SLACK alternative (with MongoDB as backend)

Currently reading
Docker Rocket.Chat - SLACK alternative (with MongoDB as backend)

Have you run the db.createUser command that’s mentioned in the tutorial as a note in case you do get similar errors?

Yes, I tried this too. After starting the Mongo-Container I go to the terminal and do this:

Code:
root@mongo:/# mongo -u root -p 7vt4vg239w --authenticationDatabase admin       
MongoDB shell version v4.4.1                                                   
connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&
gssapiServiceName=mongodb                                                       
Implicit session: session { "id" : UUID("234dfd32-e9a7-471c-bb89-3b8b2d8e0c66")
}                                                                               
MongoDB server version: 4.4.1                                                   
---                                                                             
The server generated these startup warnings when booting:                       
        2020-09-24T10:46:03.040+00:00: Using the XFS filesystem is strongly reco
mmended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/p
rodnotes-filesystem                                                             
---                                                                             
---                                                                             
        Enable MongoDB's free cloud-based monitoring service, which will then re
ceive and display                                                               
        metrics about your deployment (disk utilization, CPU, operation statisti
cs, etc).                                                                       
                                                                                
        The monitoring data will be available on a MongoDB website with a unique
 URL accessible to you                                                         
 and anyone you share the URL with. MongoDB may use this information to m
ake product                                                                     
        improvements and to suggest MongoDB products and deployment options to y
ou.                                                                             
                                                                                
        To enable free monitoring, run the following command: db.enableFreeMonit
oring()                                                                         
        To permanently disable this reminder, run the following command: db.disa
bleFreeMonitoring()                                                             
---                                                                             
>

The command line is just >, nothing like rs:PRIMARY... But I'm sure I saw also rs:PRIMARY or similar before...

And now, when using the db.createUser command, I get this:

Code:
> db.createUser({user: "admin", pwd: "7vt4vg239w", roles: [{role: "readWrite", d
b: "db"}]})                                                                     
uncaught exception: Error: couldn't add user: not master :                     
_getErrorWithCode@src/mongo/shell/utils.js:25:13                               
DB.prototype.createUser@src/mongo/shell/db.js:1361:11                           
@(shell):1:1                                                                   
>

Arrgggh, I'm sure this worked before, but now I'm stucked here already... Why looks the command line so different?
 
Why looks the command line so different?
Because db.createuser is not always needed. Now that your are a prompt in order to get to PRIMARY or SECONDARY prompt your Mongo needs to in replica mode. To do that just continue with the command line that will initiate a replica.
 
Because db.createuser is not always needed. Now that your are a prompt in order to get to PRIMARY or SECONDARY prompt your Mongo needs to in replica mode. To do that just continue with the command line that will initiate a replica.

Ok, doing this, it looks ok:

Code:
> rs.initiate({ _id: 'rs0', members: [ { _id: 0, host: 'localhost:27017' } ]}) 
{ "ok" : 1 }                                                                   
rs0:secondary>

So I configure the RC container how it is described in your tutorial. After doing this, I can export these settings with the GUI to JSON. They look like this:

Code:
{
   "cap_add" : null,
   "cap_drop" : null,
   "cmd" : "node main.js",
   "cpu_priority" : 50,
   "devices" : null,
   "enable_publish_all_ports" : false,
   "enable_restart_policy" : true,
   "enabled" : false,
   "entrypoint_default" : "docker-entrypoint.sh",
   "env_variables" : [
      {
         "key" : "PATH",
         "value" : "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
      },
      {
         "key" : "NODE_VERSION",
         "value" : "12.16.1"
      },
      {
         "key" : "YARN_VERSION",
         "value" : "1.22.0"
      },
      {
         "key" : "DEPLOY_METHOD",
         "value" : "docker"
      },
      {
         "key" : "NODE_ENV",
         "value" : "production"
      },
      {
         "key" : "MONGO_URL",
         "value" : "mongodb://root:7vt4vg239w@db:27017/db?authSource=admin"
      },
      {
         "key" : "HOME",
         "value" : "/tmp"
      },
      {
         "key" : "PORT",
         "value" : "3000"
      },
      {
         "key" : "ROOT_URL",
         "value" : "http://localhost:3000"
      },
      {
         "key" : "Accounts_AvatarStorePath",
         "value" : "/app/uploads"
      },
      {
         "key" : "MONGO_OPLOG_URL",
         "value" : "mongodb://root:7vt4vg239w@db:27017/local?authSource=admin​"
      }
   ],
   "exporting" : false,
   "id" : "fab28c6ca4ff5096e0502f8b8d7754e334a6eed9227324f2939d8d02a7237951",
   "image" : "rocketchat/rocket.chat:latest",
   "is_ddsm" : false,
   "is_package" : false,
   "links" : [
      {
         "alias" : "db",
         "link_container" : "mongo"
      }
   ],
   "memory_limit" : 0,
   "name" : "rocketchat-rocket.chat",
   "network" : [
      {
         "driver" : "bridge",
         "name" : "bridge"
      }
   ],
   "network_mode" : "bridge",
   "port_bindings" : [
      {
         "container_port" : 3000,
         "host_port" : 3000,
         "type" : "tcp"
      }
   ],
   "privileged" : false,
   "shortcut" : {
      "enable_shortcut" : false
   },
   "use_host_network" : false,
   "volume_bindings" : []
}

But when running the container, it still stops after a few seconds. This is the log:

Code:
app/bundle/programs/server/node_modules/fibers/future.js:313

                        throw(ex);

                        ^

MongoNetworkError: failed to connect to server [db:27017] on first connect [MongoError: Authentication failed.

    at Function._getError (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/auth/scram.js:141:14)

    at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/auth/scram.js:191:31

    at _callback (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:349:5)

    at Connection.messageHandler (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:378:5)

    at Connection.emit (events.js:311:20)

    at processMessage (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:384:10)

    at Socket.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:553:15)

    at Socket.emit (events.js:311:20)

    at addChunk (_stream_readable.js:294:12)

    at readableAddChunk (_stream_readable.js:275:11)

    at Socket.Readable.push (_stream_readable.js:209:10)

    at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {

  name: 'MongoError',

  [Symbol(mongoErrorContextSymbol)]: {}

}]

    at Pool.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/topologies/server.js:438:11)

    at Pool.emit (events.js:311:20)

    at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/pool.js:561:14

    at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/pool.js:994:11

    at callback (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:97:5)

    at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:396:21

    at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/auth/auth_provider.js:66:11

    at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/auth/scram.js:193:16

    at _callback (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:349:5)

    at Connection.messageHandler (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:378:5)

    at Connection.emit (events.js:311:20)

    at processMessage (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:384:10)

    at Socket.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:553:15)

    at Socket.emit (events.js:311:20)

    at addChunk (_stream_readable.js:294:12)

    at readableAddChunk (_stream_readable.js:275:11) {

  name: 'MongoNetworkError',

  [Symbol(mongoErrorContextSymbol)]: {}

}

/app/bundle/programs/server/node_modules/fibers/future.js:313

                        throw(ex);

                        ^

Any suggestions? I really have no clue what is going wrong here...
 
Ok, doing this, it looks ok:

Code:
> rs.initiate({ _id: 'rs0', members: [ { _id: 0, host: 'localhost:27017' } ]})
{ "ok" : 1 }                                                                  
rs0:secondary>

So I configure the RC container how it is described in your tutorial. After doing this, I can export these settings with the GUI to JSON. They look like this:

Code:
{
   "cap_add" : null,
   "cap_drop" : null,
   "cmd" : "node main.js",
   "cpu_priority" : 50,
   "devices" : null,
   "enable_publish_all_ports" : false,
   "enable_restart_policy" : true,
   "enabled" : false,
   "entrypoint_default" : "docker-entrypoint.sh",
   "env_variables" : [
      {
         "key" : "PATH",
         "value" : "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
      },
      {
         "key" : "NODE_VERSION",
         "value" : "12.16.1"
      },
      {
         "key" : "YARN_VERSION",
         "value" : "1.22.0"
      },
      {
         "key" : "DEPLOY_METHOD",
         "value" : "docker"
      },
      {
         "key" : "NODE_ENV",
         "value" : "production"
      },
      {
         "key" : "MONGO_URL",
         "value" : "mongodb://root:7vt4vg239w@db:27017/db?authSource=admin"
      },
      {
         "key" : "HOME",
         "value" : "/tmp"
      },
      {
         "key" : "PORT",
         "value" : "3000"
      },
      {
         "key" : "ROOT_URL",
         "value" : "http://localhost:3000"
      },
      {
         "key" : "Accounts_AvatarStorePath",
         "value" : "/app/uploads"
      },
      {
         "key" : "MONGO_OPLOG_URL",
         "value" : "mongodb://root:7vt4vg239w@db:27017/local?authSource=admin​"
      }
   ],
   "exporting" : false,
   "id" : "fab28c6ca4ff5096e0502f8b8d7754e334a6eed9227324f2939d8d02a7237951",
   "image" : "rocketchat/rocket.chat:latest",
   "is_ddsm" : false,
   "is_package" : false,
   "links" : [
      {
         "alias" : "db",
         "link_container" : "mongo"
      }
   ],
   "memory_limit" : 0,
   "name" : "rocketchat-rocket.chat",
   "network" : [
      {
         "driver" : "bridge",
         "name" : "bridge"
      }
   ],
   "network_mode" : "bridge",
   "port_bindings" : [
      {
         "container_port" : 3000,
         "host_port" : 3000,
         "type" : "tcp"
      }
   ],
   "privileged" : false,
   "shortcut" : {
      "enable_shortcut" : false
   },
   "use_host_network" : false,
   "volume_bindings" : []
}

But when running the container, it still stops after a few seconds. This is the log:

Code:
app/bundle/programs/server/node_modules/fibers/future.js:313

                        throw(ex);

                        ^

MongoNetworkError: failed to connect to server [db:27017] on first connect [MongoError: Authentication failed.

    at Function._getError (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/auth/scram.js:141:14)

    at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/auth/scram.js:191:31

    at _callback (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:349:5)

    at Connection.messageHandler (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:378:5)

    at Connection.emit (events.js:311:20)

    at processMessage (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:384:10)

    at Socket.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:553:15)

    at Socket.emit (events.js:311:20)

    at addChunk (_stream_readable.js:294:12)

    at readableAddChunk (_stream_readable.js:275:11)

    at Socket.Readable.push (_stream_readable.js:209:10)

    at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {

  name: 'MongoError',

  [Symbol(mongoErrorContextSymbol)]: {}

}]

    at Pool.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/topologies/server.js:438:11)

    at Pool.emit (events.js:311:20)

    at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/pool.js:561:14

    at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/pool.js:994:11

    at callback (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:97:5)

    at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:396:21

    at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/auth/auth_provider.js:66:11

    at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/auth/scram.js:193:16

    at _callback (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:349:5)

    at Connection.messageHandler (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:378:5)

    at Connection.emit (events.js:311:20)

    at processMessage (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:384:10)

    at Socket.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:553:15)

    at Socket.emit (events.js:311:20)

    at addChunk (_stream_readable.js:294:12)

    at readableAddChunk (_stream_readable.js:275:11) {

  name: 'MongoNetworkError',

  [Symbol(mongoErrorContextSymbol)]: {}

}

/app/bundle/programs/server/node_modules/fibers/future.js:313

                        throw(ex);

                        ^

Any suggestions? I really have no clue what is going wrong here...
Now try the db.CreateUser permissions but I am pretty sure that will not help. This looks like a problem with RC connecting to the mongo DB.

Also, before this, make sure that the Mongo instance has created some files in its docker volume folder. If not, you have permission problems on Mongo container/folder
 
Now try the db.CreateUser permissions but I am pretty sure that will not help. This looks like a problem with RC connecting to the mongo DB.

Also, before this, make sure that the Mongo instance has created some files in its docker volume folder. If not, you have permission problems on Mongo container/folder

The mongodb-folder in the docker volume folder is populated with a lot of files, so obviously mongo has the permissions to create files there.

I ran the db.createUser command with this result:

Code:
rs0:PRIMARY> db.createUser({user: "admin", pwd: "7vt4vg239w", roles: [{role: "re
adWrite", db: "db"}]})                                                         
Successfully added user: {                                                     
        "user" : "admin",                                                       
        "roles" : [                                                             
                {                                                               
                        "role" : "readWrite",                                   
                        "db" : "db"                                             
                }                                                               
        ]                                                                       
}                                                                               
rs0:PRIMARY>

It seems like there was no user admin before...But no difference when starting the RC container.... Still MongoNetworkError: failed to connect to server [db:27017] on first connect [MongoError: Authentication failed.... :(
 
The mongodb-folder in the docker volume folder is populated with a lot of files, so obviously mongo has the permissions to create files there.

I ran the db.createUser command with this result:

Code:
rs0:PRIMARY> db.createUser({user: "admin", pwd: "7vt4vg239w", roles: [{role: "re
adWrite", db: "db"}]})                                                        
Successfully added user: {                                                    
        "user" : "admin",                                                      
        "roles" : [                                                            
                {                                                              
                        "role" : "readWrite",                                  
                        "db" : "db"                                            
                }                                                              
        ]                                                                      
}                                                                              
rs0:PRIMARY>

It seems like there was no user admin before...But no difference when starting the RC container.... Still MongoNetworkError: failed to connect to server [db:27017] on first connect [MongoError: Authentication failed.... :(
Alias "db" created?
 
Yes, if you mean the link defined for the RC container:

Code:
   "links" : [
      {
         "alias" : "db",
         "link_container" : "mongo"
      }
Try and edit the MONGO_URL and OPLOG variables from db:27017 to "yourNASip:27017" and remove DB link option.
 
Try and edit the MONGO_URL and OPLOG variables from db:27017 to "yourNASip:27017" and remove DB link option.
Also try and change the password (even though it is not complex). Just to get that out of the way. On that topic, you are using the same password with mongoDB as a variable, right?

Any FW on NAS layer? Are you sure that you have no problem containers talking to each other?
 
Also try and change the password (even though it is not complex). Just to get that out of the way. On that topic, you are using the same password with mongoDB as a variable, right?

Any FW on NAS layer? Are you sure that you have no problem containers talking to each other?

Ok, I tried to remove the link and use the NAS-IP in the RC variables.... no success

I changed the password (the same in the mongodb variable and in RC)... no success

Of course the firewall on the NAS is active. I thought it won't interfere with the containers talking to each other, because it's just for in- and outbound network traffic. But just to be sure, I opened ports 3000 and 27017 already yesterday... no success.

In fact I think that RC is able to reach Mongo, because there is an error in the mongo log when trying to start RC:

Code:
"ctx":"conn23","msg":"Authentication failed","attr":{"mechanism":"SCRAM-SHA-1","principalName":"root","authenticationDatabase":"admin","client":"172.17.0.1:35784","result":"UserNotFound: Could not find user \"root\" for db \"admin\""}}

No user root for db admin? But I'm able to log into the database from mongo bash with these credentials... Mysterious...
 
It is getting even more weird.... When showing the users of my db:

Code:
rs0:PRIMARY> show users                                                         
{                                                                               
        "_id" : "test.admin",                                                   
        "userId" : UUID("b165d449-7a19-4587-a4a7-8b7f44821ef9"),               
        "user" : "admin",                                                       
        "db" : "test",                                                         
        "roles" : [                                                             
                {                                                               
                        "role" : "readWrite",                                   
                        "db" : "db"                                             
                }                                                               
        ],                                                                     
        "mechanisms" : [                                                       
                "SCRAM-SHA-1",                                                 
                "SCRAM-SHA-256"                                                 
        ]                                                                       
}

Why DB "test"?? I never set anything like "test".....
 
It is getting even more weird.... When showing the users of my db:

Code:
rs0:PRIMARY> show users                                                        
{                                                                              
        "_id" : "test.admin",                                                  
        "userId" : UUID("b165d449-7a19-4587-a4a7-8b7f44821ef9"),              
        "user" : "admin",                                                      
        "db" : "test",                                                        
        "roles" : [                                                            
                {                                                              
                        "role" : "readWrite",                                  
                        "db" : "db"                                            
                }                                                              
        ],                                                                    
        "mechanisms" : [                                                      
                "SCRAM-SHA-1",                                                
                "SCRAM-SHA-256"                                                
        ]                                                                      
}

Why DB "test"?? I never set anything like "test".....
Odd. I have mongo 4.2.3 version running and on it multiple RC instances.

Maybe try with that specific version of mongo?
 
Odd. I have mongo 4.2.3 version running and on it multiple RC instances.

Maybe try with that specific version of mongo?

I tried this, but it still doesn't work. When starting RC, mongo logs an access error saying "UserNotFound: Could not find user "root" for db "admin"". o_O

I think I'll give up. No time for diving deep enough into mongo db management to fix that. But if anybody has a hint, I would be very happy to get it running finally. @Rusty: Thank you very much for your patience and efforts!!
 
I tried this, but it still doesn't work. When starting RC, mongo logs an access error saying "UserNotFound: Could not find user "root" for db "admin"". o_O

I think I'll give up. No time for diving deep enough into mongo db management to fix that. But if anybody has a hint, I would be very happy to get it running finally. @Rusty: Thank you very much for your patience and efforts!!
Today I have been working on the same problem with another user, and I mean exact same problem. In the end docker reset + fresh mongo instance did the trick
 
Today I have been working on the same problem with another user, and I mean exact same problem. In the end docker reset + fresh mongo instance did the trick

Nice to see that I'm not the only one struggeling with this problem and that there might be a solution. Could you please explain what is meant by "docker reset"? Concerning the mongo instance I created a fresh one severel times already during my efforts to get this running...
 
Nice to see that I'm not the only one struggeling with this problem and that there might be a solution. Could you please explain what is meant by "docker reset"? Concerning the mongo instance I created a fresh one severel times already during my efforts to get this running...
Simply stop and start the docker package in the Package center and then try again. Truth be told we ended up rerunning both mongo and rc as a fresh container after this.
 
Simply stop and start the docker package in the Package center and then try again. Truth be told we ended up rerunning both mongo and rc as a fresh container after this.

Unfortunately it's still not working.... RC tries to log into mongo, mongo says "UserNotFound". I even tried to change the user from root to admin within the RC variable, but the result is the same...
 
Last edited:
Unfortunately it's still not working.... RC tries to log into mongo, mongo says "UserNotFound". I even tried to change the user from root to admin within the RC variable, but the result is the same...
I was doing this:
1) deleted mongo container.
2) deleted rocketchat container.
3) deleted all mess by portainer after those instances.
4) deleted images from the repository of these two.
5) stopped docker app at all. Then started again.
6) created a new "mongo" folder in docker folder and placed there "mongod.conf" with given parameters. Also set a full rights on the "mongo" folder for "everyone"
7) downloaed new images of mongo (latest) and rocketchat (official version)
8) ....was doing all steps according the Rusty's tutorial.
 
I was doing this:
1) deleted mongo container.
2) deleted rocketchat container.
3) deleted all mess by portainer after those instances.
4) deleted images from the repository of these two.
5) stopped docker app at all. Then started again.
6) created a new "mongo" folder in docker folder and placed there "mongod.conf" with given parameters. Also set a full rights on the "mongo" folder for "everyone"
7) downloaed new images of mongo (latest) and rocketchat (official version)
8) ....was doing all steps according the Rusty's tutorial.

I tried it, and checked several times, that I did'nt miss a step.... it's still not working 😖
I'll have the chance to test it with a newly installed NAS soon. I will report here whether I ran into the same problem.... Thank you for your help!
 
I'll have the chance to test it with a newly installed NAS soon. I will report here whether I ran into the same problem.... Thank you for your help!
I am beginning to doubt my sanity. Tried it on another NAS now... Same problem. 😭 Unfortunately, there is not much time for further tests at the moment. I will continue reading here and try again sometime. Maybe others will encounter the same problem and find a solution...
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Welcome to SynoForum.com!

SynoForum.com is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Back
Top