Koa Discussion Forum With Remote mongoDB?

Does anyone know the secret for getting the Koa Discussion Forum to use a remote mongo service instead of the local service? The remote mongo service in question works fine with LMS and CMS and I can connect to it remotely from the command line using the cs_comments_service mongo username, and so I’ve ruled out remote connectivity errors.

Summarizing what I’ve already attempted:

  1. Modify MONGOHQ_URL in /edx/app/forum/forum_env, changing “localhost” to the remote host (again, I have already verified that the remote host is actually reachable).

  2. Modify /edx/app/forum/cs_comments_service/config/mongoid.yml, replacing the tag MONGOHQ_URL with the literal URI from forum_env.

I followed both modifications with a restart of the Discussion Forum using
/edx/bin/supervisorctl restart forum
I next tried a full edxapp instance reboot using sudo reboot. In each case the Discussion Forum still connects to the local mongo service instead of the remote service.

Perplexed. :thinking:

the following Jira from Mongodb suggests that it might be necessary to address the remote mongo server via IPv6.

Mongoid.purge! fails after upgrading to mongo 2.5.0

Separately, I reviewed and ruled out the following Jira Epic & PR: Discussion forum errors in latest master with mongo 3.2

Also, a correction to the symptom that i describe above. The discussion service does not connect to the local service unless I revert to the original config, with host=localhost. What actually happens when I attempt to set the host to a remote host is the following run-time exception:

/edx/app/forum/.gem/ruby/2.5.0/gems/mongo-2.5.3/lib/mongo/server_selector/selectable.rb:110:in `select_server': No server is available matching preference: #<Mongo::ServerSelector::Primary:0x47148013197240 tag_sets=[] max_staleness=nil> using server_selection_timeout=30 and local_threshold=0.015 (Mongo::Error::NoServerAvailable)

For the avoidance of doubt, following are the forum_env settings I’m using.

export RBENV_ROOT="/edx/app/forum/.rbenv"
export GEM_HOME="/edx/app/forum/.gem"
export GEM_PATH="/edx/app/forum/.gem"
export PATH="/edx/app/forum/cs_comments_service/bin:/edx/app/forum/.rbenv/bin:/edx/app/forum/.rbenv/shims:/edx/app/forum/.gem/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export RACK_ENV="production"
export SINATRA_ENV="production"
export API_KEY="baCXRhFN3pjzdxkIhHGkIdl1IP7SfrXBpuK"
export SEARCH_SERVER="http://localhost:9200"
export SEARCH_SERVER_ES7="http://localhost:9200"
export MONGOHQ_URL="mongodb://cs_comments_service:[PASSWORD]@[IPv4 Address]:27017/cs_comments_service"
export MONGOID_AUTH_MECH=":scram"
export HOME="/edx/app/forum"
export NEW_RELIC_APP_NAME="default_env-default_deployment-forum"
export DATA_DIR="/edx/var/forum"
export LISTEN_HOST=""
export LISTEN_PORT="4567"

eval "$(rbenv init -)"

I did before :

  1. modify the MONGOHQ_URL(ip) in /edx/app/forum/forum_env
  2. modify the all the host (ip) which connect to port 27017 in /edx/etc/lms.yml (studio.yml)
  3. make sure the two passwords could access the remote MongoDB/cs_comments_service
  4. make sure the firewall is ok .

I only did the things above and Koa forum with remote MongoDB is working for your reference.

Hello @lpm0073,
Have you found any solution for this?
I have installed CMS, Mongo, Elasticsearch on the same server and LMS, Forum on another.
Getting the same error.
I have checked, I can connect the mongo instance on LMS via the Private IP.

hi @billatedx, i and a couple others in this thread are trouble shooting a problem with getting the discussion forum to work with a remote mongo host. we represent a few different open edx installations all running on koa.master, each with the same problem: stopping the local mongo service breaks the discussion forum, even when the host credentials have been correctly modified in forum_env or farther downstream in /conf.

i’m reaching out to you bc last year around this time you were part of a collection of three pull requests related to upgrading the ruby gems for mongo, and then shortly after, reverting these:

driver upgraded 19-feb-2020: https://github.com/edx/cs_comments_service/pull/298
reversion 1 on 3-march-2020: Revert "Upgrade mongodb ruby driver" by bderusha · Pull Request #313 · edx/cs_comments_service · GitHub
reversion 2 on 5-march-2020: Revert "Revert "Upgrade mongodb ruby driver"" by bderusha · Pull Request #315 · edx/cs_comments_service · GitHub

i’m curious if you’re familiar with this problem and might be able to provide some context?

@anjali while the remote connectivity problems remains, i’m curious if you’ve considered/attempted to install the discussion forum on a standalone EC2 instance along with its own local installation of mongo, and then integrate this to your LMS?

i succeeded in creating a remote discussion forum. i set the host name COMMENTS_SERVICE_URL to the internal IP address of the server, and, i modified the nginx config on the remote server to make the forum service listen on port 80 as the default_server. i’m running a local mongo service on that server.

this seems to be working for now, provided that this EC2 instance can manage the load on its own.

thanks for these suggestions. i think there have been some commits to cs_discussion_service since you launched your koa.master instance, and that one of these commits is the cause of the problems we are experiencing.

Hello @lpm0073 , are you going to update your blog with the new discoveries you have made?

Since I am also stuck in the forums part

Thanks in advance

Hi @lpm0073,
Thanks for sharing the solution!
I have tried the below steps, but for me still, the discussion forum is not working.

  1. Change the CS_COMMENTS_SERVICE URL from IP to LMS host.
  2. Modified the Nginx forum config file to listen on port 80.

For your information, I am running the LMS and Forum on the same instance and mongo and other services on another instance.

Could you please help me with this?

I can’t see it working in any other scenario apart from discussion forum server and mongo server being in the same server.

The issue is most probably because of ruby’s mongo version of 2.5.3

If you downgrade to 2.4.3 there is undefined variable error of select_server which most probably is because of mongo id version 7.x.x

I tried several combinations of several versions of mongo and mongoid and other stuff.

What ultimately worked was as @lpm0073 mentioned to have mongo in same server as forum.

Somehow I wasn’t able to get it to take another ip (Private or public and even domain for that matter).

If someone else finds any solution please do tell.