Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest develop docker image ignores MONGO_URL variable #26231

Closed
bkraul opened this issue Jul 12, 2022 · 8 comments
Closed

Latest develop docker image ignores MONGO_URL variable #26231

bkraul opened this issue Jul 12, 2022 · 8 comments

Comments

@bkraul
Copy link

bkraul commented Jul 12, 2022

Description:

Starting with git hash 8158bee, rocketchat image doesn't seem to be respecting the MONGO_URL variable. As a result, it tries to find the database on localhost, and it fails with the following error:

MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017

A previous develop image (git hash 4f390d7) does not seem to have this problem.

Steps to reproduce:

  1. Pull latest develop docker image
  2. Attempt to restart the stack
  3. Startup will fail with connection refused error

Expected behavior:

Rocketchat should normally start

Actual behavior:

Fails with following error:

rocketchat_1          | /app/bundle/programs/server/node_modules/fibers/future.js:313
rocketchat_1          |                                                 throw(ex);
rocketchat_1          |                                                 ^
rocketchat_1          |
rocketchat_1          | MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
rocketchat_1          |     at Timeout._onTimeout (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/sdam/topology.js:312:38)
rocketchat_1          |     at listOnTimeout (internal/timers.js:557:17)
rocketchat_1          |     at processTimers (internal/timers.js:500:7) {
rocketchat_1          |   reason: TopologyDescription {
rocketchat_1          |     type: 'ReplicaSetNoPrimary',
rocketchat_1          |     servers: Map(1) {
rocketchat_1          |       'localhost:27017' => ServerDescription {
rocketchat_1          |         _hostAddress: HostAddress { isIPv6: false, host: 'localhost', port: 27017 },
rocketchat_1          |         address: 'localhost:27017',
rocketchat_1          |         type: 'Unknown',
rocketchat_1          |         hosts: [],
rocketchat_1          |         passives: [],
rocketchat_1          |         arbiters: [],
rocketchat_1          |         tags: {},
rocketchat_1          |         minWireVersion: 0,
rocketchat_1          |         maxWireVersion: 0,
rocketchat_1          |         roundTripTime: -1,
rocketchat_1          |         lastUpdateTime: 1584242409,
rocketchat_1          |         lastWriteDate: 0,
rocketchat_1          |         error: MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017
rocketchat_1          |             at connectionFailureError (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/connect.js:381:20)
rocketchat_1          |             at Socket.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/connect.js:301:22)
rocketchat_1          |             at Object.onceWrapper (events.js:520:26)
rocketchat_1          |             at Socket.emit (events.js:400:28)
rocketchat_1          |             at emitErrorNT (internal/streams/destroy.js:106:8)
rocketchat_1          |             at emitErrorCloseNT (internal/streams/destroy.js:74:3)
rocketchat_1          |             at processTicksAndRejections (internal/process/task_queues.js:82:21)
rocketchat_1          |       }
rocketchat_1          |     },

Server Setup Information:

  • Version of Rocket.Chat Server: 5.0.0-develop
  • Operating System: Ubuntu 22.04 LTS
  • Deployment Method: docker
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Enabled
  • NodeJS Version: v14.18.3
  • MongoDB Version: 5.0.9

Client Setup Information

  • Desktop App or Browser Version: 3.8.6, Firefox 102.0.1
  • Operating System: Windows 11

Additional context

Relevant logs:

@bkraul
Copy link
Author

bkraul commented Jul 13, 2022

Any ideas or workarounds for this?

@bkraul
Copy link
Author

bkraul commented Jul 14, 2022

For those who find this issue, I resolved it by changing the host name of the primary member in mongo. Original implementations of the compose file for rocketchat initialized the replica with hostname localhost:27017. I have been using Rocketchat for years, and apparently new versions of node don't play well with a mongodb replicaset set up with localhost as the host name.

In my stack, my mongo container is named mongo.

The solution was to log in to the mongo container, and get into the mongo shell with mongo.

Once in the shell, this sequence of commands solved my issue:

cfg = rs.conf()
cfg.members[0].host = "mongo:27017"
rs.reconfig(cfg)

After this, rocketchat was able to connect properly to the mongo instance.

@klangborste
Copy link

Thanks that did the trick for me @bkraul 👍

Once in the shell, this sequence of commands solved my issue:

cfg = rs.conf()
cfg.members[0].host = "mongo:27017"
rs.reconfig(cfg)

@hueyyeng
Copy link

For those who find this issue, I resolved it by changing the host name of the primary member in mongo. Original implementations of the compose file for rocketchat initialized the replica with hostname localhost:27017. I have been using Rocketchat for years, and apparently new versions of node don't play well with a mongodb replicaset set up with localhost as the host name.

In my stack, my mongo container is named mongo.

The solution was to log in to the mongo container, and get into the mongo shell with mongo.

Once in the shell, this sequence of commands solved my issue:

cfg = rs.conf()
cfg.members[0].host = "mongo:27017"
rs.reconfig(cfg)

After this, rocketchat was able to connect properly to the mongo instance.

This solved my issue too when I upgrade from 4.8.0 to 5.0.0 and was hitting this error.

For context, my scenario is the same as described by @bkraul as I've been using the RocketChat Official Docker repo without any changes except for testing out 5.0.0 because the current official "5.0.0" release from https://releases.rocket.chat/5.0.0/download is from early June 2022 commit. To be exact this is the commit 83851a0

I ended up building my own Rocket.Chat dist from the 5.0.0 tag and edited the Dockerfile to use that instead of the official release and ended up hitting this error where it has been running fine with 4.8.0.

@xcpdq
Copy link

xcpdq commented Jul 27, 2022

I was getting the same error in Mongo after upgrading to 5.0.0. I did the below steps and *somehow it worked. I say somehow because when I accessed my Rocket Chat URL for a second I could see the login section but then I was asked to create an Admin account (basically set up Rocket Chat from scratch).

Anyone know why this could be?

Thank you!

cfg = rs.conf()
cfg.members[0].host = "mongo:27017"
rs.reconfig(cfg)

@bkraul
Copy link
Author

bkraul commented Jul 27, 2022

That only works if your container's name in the stack is mongo, you might have mongodb and therefore you'd need to use mongodb:27017. Also make sure your replica container is using the same version of mongo as your mongo db container.

@bkraul
Copy link
Author

bkraul commented Jul 27, 2022

On one of my deployments I encountered a weird issue where I had to like remove several indexes and had them be recreated (because they were showing as non-unique or something like that. Hopefully that won't be your case).

@zagrev
Copy link

zagrev commented Sep 4, 2022

I am having this problem with docker image 5.1.0. The workaround fixes the problem, but it would be nice if the bug was fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants