Deploying Rocket.chat in 2 separate servers

Description

I’ve been asked at work to test-drive rocket.chat deploying it in two separate servers.

I’ve installed and configured mongo.db on server A along with rocket chat and everything seems to be working, I can connect from the browser and use the clients successfully. I followed the guide in the doc step by step.

I’m now trying to install server B, which in fact was cloned from server A. My intention is having rocket.chat in server B to connect to mongo.db in server A.

This is my /lib/systemd/system/rocketchat.service in server B:

[Unit]
Description=The Rocket.Chat server
After=network.target remote-fs.target nss-lookup.target nginx.target mongod.target
[Service]
ExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.js
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
User=rocketchat
Environment=MONGO_URL=mongodb://10.240.243.111:27017/rocketchat?replicaSet=rs01 MONGO_OPLOG_URL=mongodb://10.240.243.111:27017/local?replicaSet=rs01 ROOT_URL=http://10.240.243.116:3000/ PORT=3000
[Install]
WantedBy=multi-user.target

Where 10.240.243.111 is the IP of Server A (where mongo.db resides)

But when I try to start the service, I get this error message:

Apr 30 06:40:06 ufichjda0 rocketchat: /opt/Rocket.Chat/programs/server/node_modules/fibers/future.js:313
Apr 30 06:40:06 ufichjda0 rocketchat: throw(ex);
Apr 30 06:40:06 ufichjda0 rocketchat: ^
Apr 30 06:40:06 ufichjda0 rocketchat: MongoNetworkError: failed to connect to server [127.0.0.1:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
Apr 30 06:40:06 ufichjda0 rocketchat: at Pool. (/opt/Rocket.Chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/topologies/server.js:564:11)
[...]

Why is it attempting to connect to localhost? What am I missing?

Server Setup Information

  • Version of Rocket.Chat Server: 3.2.0
  • Operating System: CentOS Linux 7 (Core)
  • Deployment Method: tar (manual)
  • Number of Running Instances: 2
  • DB Replicaset Oplog:
  • NodeJS Version: v8.11.4
  • MongoDB Version: 4.0.13
  • Proxy:
  • Firewalls involved:

Any additional Information

I’d like do follow this topic as I think I’ll have to do the same. Do you upload files into Mongo? Looks like it is not a good idea. And if you switch to filesystem you will need to sync files somehow.

I’ll try to deal with that later. I want to have the database connection sorted first. I can’t understand why it claims it can’t connect to localhost if I’m explicitly telling Rocket.Chat that it’s elsewhere, so there must be some key bit of info I might have misunderstood.

Amyways, I think we’ll use a NFS mounted filesystem in both machines and have the files stored there.

Thank you very much for the solution.

Myloweslife

Hey there,

We are looking at doing something similar. Did you ever end up getting this figured out?

mongodb official documentation also has some instructions for replicating the db to geographically separate locations, that we are about to try. BUT, if there is a better option, we are definitely interested in hearing about it.