Tutor Forum Docker does not connect with mongoDB cluster

I am trying to connect the forum docker with MongoDB cluster.
The configurations are -

environment:
  SEARCH_SERVER: "http://elasticsearch:9200"      
  MONGODB_AUTH: "mongouser:password@"
  MONGODB_HOST: "mongo_primary_host_url"
  MONGODB_PORT: 27017
  MONGODB_DATABASE: "cs_comments_service"
  MONGOID_USE_SSL: true
  MONGOID_SSL_VERIFY: true
  MONGOID_READ_MODE: "primary"
  MONGOID_AUTH_MECH: ":mongodb_x509"
  MONGOID_SSL_CA_CERT: "My_certificate_path_in_the_forum_docker"
  MONGOID_TIMEOUT: 10

This is the error i get in the forum.

tutor_local-forum-1 | Waiting for mongodb/elasticsearch…
tutor_local-forum-1 | 2022/06/13 08:47:46 Waiting for: tcp://mongo_primary_host_url:27017
tutor_local-forum-1 | 2022/06/13 08:47:46 Waiting for: http://elasticsearch:9200
tutor_local-forum-1 | 2022/06/13 08:47:46 Connected to tcp://mongo_primary_host_url:27017
tutor_local-forum-1 | 2022/06/13 08:47:46 Received 200 from http://elasticsearch:9200
tutor_local-forum-1 | W, [2022-06-13T08:47:47.948442 #17] WARN – : Overwriting existing field _id in class User.
tutor_local-forum-1 | W, [2022-06-13T08:47:47.977085 #17] WARN – : MONGODB | Unsupported client option ‘max_retries’. It will be ignored.
tutor_local-forum-1 | W, [2022-06-13T08:47:47.977157 #17] WARN – : MONGODB | Unsupported client option ‘retry_interval’. It will be ignored.
tutor_local-forum-1 | W, [2022-06-13T08:47:47.977173 #17] WARN – : MONGODB | Unsupported client option ‘timeout’. It will be ignored.
tutor_local-forum-1 | /app/cs_comments_service/vendor/bundle/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:0x47181947531780 tag_sets=[] max_staleness=nil> using server_selection_timeout=30 and local_threshold=0.015 (Mongo::Error::NoServerAvailable) tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/mongo-2.5.3/lib/mongo/collection/view/iterable.rb:41:in block in each’
tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/mongo-2.5.3/lib/mongo/retryable.rb:44:in read_with_retry' tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/mongo-2.5.3/lib/mongo/collection/view/iterable.rb:40:in each’
tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/mongoid-7.0.5/lib/mongoid/query_cache.rb:227:in each' tutor_local-forum-1 | from /app/cs_comments_service/app.rb:175:in map’
tutor_local-forum-1 | from /app/cs_comments_service/app.rb:175:in <top (required)>' tutor_local-forum-1 | from config/unicorn_tcp.rb:4:in require’
tutor_local-forum-1 | from config/unicorn_tcp.rb:4:in reload' tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/unicorn-5.3.1/lib/unicorn/configurator.rb:84:in instance_eval’
tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/unicorn-5.3.1/lib/unicorn/configurator.rb:84:in reload' tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/unicorn-5.3.1/lib/unicorn/configurator.rb:77:in initialize’
tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/unicorn-5.3.1/lib/unicorn/http_server.rb:77:in new' tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/unicorn-5.3.1/lib/unicorn/http_server.rb:77:in initialize’
tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/unicorn-5.3.1/bin/unicorn:126:in new' tutor_local-forum-1 | from /app/cs_comments_service/vendor/bundle/ruby/2.5.0/gems/unicorn-5.3.1/bin/unicorn:126:in <top (required)>’
tutor_local-forum-1 | from ./bin/unicorn:16:in load' tutor_local-forum-1 | from ./bin/unicorn:16:in ’

The same cluster is used for lms/cms. That works fine, but the forum does not connect.

1 Like

Hi

Could you specify which version of tutor/tutor-forum are you using?

On the other hand, I think tutor k8s patchs expects MONGODB_USERNAME and MONGODB_PASSWORD in env to to set MONGODB_AUTH. I might be wrong, anyway my specualtion is based on this: tutor-forum/k8s-deployments at master ¡ overhangio/tutor-forum ¡ GitHub .

Hi,

tutor==13.0.0
tutor-forum==13.0.0

This is a tutor local setup not k8s. The local setup is connected to a mongodb cluster.

It’s same even for local setup, tutor-forum expects

hence: https://github.com/overhangio/tutor-forum/blob/49d9a49d2544bc55ba61598ee7463c1a35352622/tutorforum/patches/local-docker-compose-jobs-services#L5

Hi,

Changed the MONGODB_AUTH to MONGODB_USERNAME and MONGODB_PASSWORD.

MONGODB_USERNAME: “username”
MONGODB_PASSWORD: “password”
…

The same issue persists.

Can you let me know the steps you did to run tutor and tutor-forum so I can try reproduce your error or see if there was an issue in the steps

Take a fresh env and install tutor and tutor-forum. Create a cluster of mongdb with 3 nodes(1 primary and 2 secondary).

Connect the tutor and forum with the cluster. For tutor we can create a patch for the changes in production.py file(Both CMS and LMS).
Try and connect the tutor-forum also with the mongodb cluster.

Production.py(cms & lms) mongodb parameters.

mongodb_parameters = {
“host”: [“ip1:27017”, “ip2:27017”, “ip3:27017”],
“replicaSet”:‘rs0’,
“user”: “username”,
“password”: “password”,
“ssl”: True,
“tls”: True,
“tlsCAFile”: “path_to_crt_in_the_lms_or_cms_docker”,
“db”: “openedx”
}

The mongodb has ssl/tls authentication enabled(Cannot disable it).

1 Like

Unfortuetnly I haven’t done that before:

Also regarding MONGOID_AUTH_MECH value could you try while setting it to “:scram” instead of “:mongodb_x509”. Because this I think what the forum/comments typically uses.

Technically it is called replication(not clustering…my mistake) and it is not that hard. Just need three mongodb nodes running with replSet enabled. https://www.mongodb.com/docs/manual/core/replica-set-secondary/
https://www.mongodb.com/docs/manual/tutorial/deploy-replica-set/

I tried both of them. Same error.

Since this seems an issue or a bug, with no simple or clear solution. Could please open an issue at Issues ¡ overhangio/tutor-forum ¡ GitHub in the issue add the steps and log files. which I think you already stated here just the part about about creating replica/nodes is missing. Please be an explicit as possible.

As a maintner of tutor-forum myself, I will try to fix/address your issue during this week.

Hey @ghassan,

I opened and issue in github.

Hope we can figure it out soon.
Reach out if there is anything i can help with.

Yeah, I just commented on your issue.

1 Like

Hello @Vamsi_Kundla ,

May I know is it still have issue connect Atlas MongoDB cluster,
MONGODB_HOST: mongodb+srv:// Because I find “MongoDB is using SRV records, so we cannot wait for it to be ready” during tutor local launch. Does someone know the solution? The installation process can run to finish but access to http://local.edly.io/ it show “Internal Server Error”

Warm regard