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 WORKER_PROCESSES="4"
export DATA_DIR="/edx/var/forum"
export LISTEN_HOST="0.0.0.0"
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.