Install plugins forum connect mongodb

Hello everyone,

I’m currently exploring the process of setting up a discussion forum. I have a server that contains my MongoDB data. I’ve installed forum plugins to enable the discussion functionality. I ran the command “tutor local launch” but when it comes to the forum connecting to MongoDB, I encountered an " Authentication failed" error.

 /app/cs_comments_service/lib/tasks/flags.rake:6: warning: already initialized constant ROOT
/app/cs_comments_service/lib/tasks/deep_search.rake:7: warning: previous definition of ROOT was here
/app/cs_comments_service/lib/tasks/kpis.rake:7: warning: already initialized constant ROOT
/app/cs_comments_service/lib/tasks/flags.rake:6: warning: previous definition of ROOT was here
/app/cs_comments_service/models/constants.rb:2: warning: already initialized constant COURSE_ID
/app/cs_comments_service/lib/tasks/db.rake:28: warning: previous definition of COURSE_ID was here
W, [2023-08-24T08:42:08.307019 #15]  WARN -- : Overwriting existing field _id in class User.
W, [2023-08-24T08:42:08.409547 #15]  WARN -- : MONGODB | Unsupported client option 'max_retries'. It will be ignored.
W, [2023-08-24T08:42:08.409633 #15]  WARN -- : MONGODB | Unsupported client option 'retry_interval'. It will be ignored.
W, [2023-08-24T08:42:08.409657 #15]  WARN -- : MONGODB | Unsupported client option 'timeout'. It will be ignored.
W, [2023-08-24T08:42:08.420711 #15]  WARN -- : MONGODB | Failed to authenticate to :27017: Mongo::Auth::Unauthorized: User funixLMSUser (mechanism: scram) is not authorized to access lms2019 (auth source: admin, used mechanism: SCRAM-SHA-1, used server: :27017 (STANDALONE)): [18:AuthenticationFailed]: Authentication failed.
rake aborted!
Mongo::Auth::Unauthorized: User funixLMSUser (mechanism: scram) is not authorized to access lms2019 (auth source: admin, used mechanism: SCRAM-SHA-1, used server: :27017 (STANDALONE)): [18:AuthenticationFailed]: Authentication failed. (modern retry, attempt 1)
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/auth/base.rb:135:in `validate_reply!'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/auth/base.rb:114:in `dispatch_msg'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/auth/base.rb:89:in `converse_multi_step'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/auth/scram.rb:63:in `login'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/server/pending_connection.rb:186:in `block in authenticate!'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/server.rb:479:in `handle_auth_failure!'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/server/pending_connection.rb:178:in `authenticate!'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/server/pending_connection.rb:95:in `handshake_and_authenticate!'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/server/connection.rb:249:in `do_connect'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/server/connection.rb:215:in `connect!'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/server/connection_pool.rb:863:in `connect_connection'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/server/connection_pool.rb:419:in `check_out'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/server/connection_pool.rb:666:in `with_connection'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/server.rb:448:in `with_connection'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/operation/shared/polymorphic_operation.rb:35:in `execute'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/collection/view/iterable.rb:197:in `send_initial_query'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/collection/view/iterable.rb:127:in `block in select_cursor'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/retryable.rb:64:in `block in read_with_retry_cursor'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/retryable.rb:370:in `modern_read_with_retry'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/retryable.rb:127:in `read_with_retry'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/retryable.rb:63:in `read_with_retry_cursor'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/collection/view/iterable.rb:126:in `select_cursor'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/mongo-2.18.1/lib/mongo/collection/view/iterable.rb:60:in `each'
/app/cs_comments_service/app.rb:173:in `map'
/app/cs_comments_service/app.rb:173:in `<top (required)>'
/app/cs_comments_service/Rakefile:24:in `require'
/app/cs_comments_service/Rakefile:24:in `block in <top (required)>'
/app/cs_comments_service/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'

I’m certain that my user has the necessary access privileges because I can still interact with my MongoDB server without any issues, even without the forum plugins.

Could anyone help me with this? Thank you!

Maybe this is related to the auth source?

can you access lms2019 with the user funixLMSUser using admin as the authentication database?

You can configure the authentication database with the MONGODB_AUTH_SOURCE variable which defaults to admin.

Hello @MoisesGonzalezS ,
Thank you for your assistance. I have created a user in MongoDB with admin privileges and it was successful. However, I am encountering an error:

lms_1                        | Traceback (most recent call last):
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
lms_1                        |     response = get_response(request)
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
lms_1                        |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
lms_1                        |   File "/opt/pyenv/versions/3.8.12/lib/python3.8/contextlib.py", line 75, in inner
lms_1                        |     return func(*args, **kwds)
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
lms_1                        |     return view_func(*args, **kwargs)
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/rest_framework/viewsets.py", line 125, in view
lms_1                        |     return self.dispatch(request, *args, **kwargs)
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
lms_1                        |     response = self.handle_exception(exc)
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
lms_1                        |     response = handler(request, *args, **kwargs)
lms_1                        |   File "/openedx/edx-platform/./lms/djangoapps/discussion/rest_api/views.py", line 507, in list
lms_1                        |     return get_thread_list(
lms_1                        |   File "/openedx/edx-platform/./lms/djangoapps/discussion/rest_api/api.py", line 828, in get_thread_list
lms_1                        |     context = get_context(course, request)
lms_1                        |   File "/openedx/edx-platform/./lms/djangoapps/discussion/rest_api/serializers.py", line 71, in get_context
lms_1                        |     cc_requester = CommentClientUser.from_django_user(requester).retrieve()
lms_1                        |   File "/openedx/edx-platform/./openedx/core/djangoapps/django_comment_common/comment_client/models.py", line 67, in retrieve
lms_1                        |     self._retrieve(*args, **kwargs)
lms_1                        |   File "/openedx/edx-platform/./openedx/core/djangoapps/django_comment_common/comment_client/user.py", line 152, in _retrieve
lms_1                        |     response = utils.perform_request(
lms_1                        |   File "/openedx/edx-platform/./openedx/core/djangoapps/django_comment_common/comment_client/utils.py", line 65, in perform_request
lms_1                        |     response = requests.request(
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/requests/api.py", line 59, in request
lms_1                        |     return session.request(method=method, url=url, **kwargs)
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/requests/sessions.py", line 587, in request
lms_1                        |     resp = self.send(prep, **send_kwargs)
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/requests/sessions.py", line 701, in send
lms_1                        |     r = adapter.send(request, **kwargs)
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/requests/adapters.py", line 565, in send
lms_1                        |     raise ConnectionError(e, request=request)
lms_1                        | requests.exceptions.ConnectionError: HTTPConnectionPool(host='forum', port=4567): Max retries exceeded with url: /api/v1/users/17180?complete=True&request_id=609f68ed-45a3-4828-8c90-502d2241482f (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3c886fa220>: Failed to establish a new connection: [Errno -2] Name or service not known'))

I tried running “tutor local init” again, but it still doesn’t work. On the MongoDB server, I removed

security:
authorization: enabled

in file mongod.conf, and it was successful. However, there is an issue that if I remove security, my MongoDB server will be left unprotected. How can I resolve this situation?

I appreciate your help.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.