open-craft / xblock-eoc-journal

Course Journal XBlock
GNU Affero General Public License v3.0
1 stars 7 forks source link

(Koa) Failed to establish a new connection: [Errno 111] Connection refused') #43

Closed BbrSofiane closed 3 years ago

BbrSofiane commented 3 years ago

Following my issues with issue#42, I tried the Xblock on a devstack instance of Koa and I got a different error.

image

Are the two issues related?

 2021-02-05 17:48:18,582 WARNING 15 [cms.djangoapps.contentstore.views.preview] [user 3] [ip 172.20.0.1] preview.py:329 - Unable to render author_view for <VerticalBlockWithMixins @1919 parent=BlockUsageLocator(CourseLocator('edX', 'DemoX', 'Demo_Course', None, None), 'sequential', 'edx_introduction'), name=None, tags=[], display_name='Unit', course_edit_method='Studio', days_early_for_beta=None, due=None, edxnotes=False, edxnotes_visibility=True, giturl=None, graceperiod=datetime.timedelta(seconds=18000), graded=False, group_access={}, in_entrance_exam=False, matlab_api_key=None, max_attempts=None, rerandomize='never', self_paced=False, show_correctness='always', show_reset_button=False, showanswer='attempted', start=datetime.datetime(1970, 1, 1, 5, 0, tzinfo=tzlocal()), static_asset_path='', use_latex_compiler=False, user_partitions=[], video_auto_advance=False, video_bumper={}, video_speed_optimizations=True, visible_to_staff_only=False, xqa_key='qaijS3UatK020Wc0sfCtFe0V6jpB4d64', chrome=None, default_tab=None, format=None, hide_from_toc=False, source_file=None, children=[BlockUsageLocator(CourseLocator('edX', 'DemoX', 'Demo_Course', None, None), 'eoc-journal', '9a15f298b9de4739b5f07b2cadd48211')], hide_after_due=False, is_entrance_exam=False, position=None, xml_attributes={}>
edx.devstack-koa.master.studio    | Traceback (most recent call last):
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/urllib3/connection.py", line 169, in _new_conn
edx.devstack-koa.master.studio    |     conn = connection.create_connection(
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/urllib3/util/connection.py", line 96, in create_connection
edx.devstack-koa.master.studio    |     raise err
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/urllib3/util/connection.py", line 86, in create_connection
edx.devstack-koa.master.studio    |     sock.connect(sa)
edx.devstack-koa.master.studio    | ConnectionRefusedError: [Errno 111] Connection refused
edx.devstack-koa.master.studio    |
edx.devstack-koa.master.studio    | During handling of the above exception, another exception occurred:
edx.devstack-koa.master.studio    |
edx.devstack-koa.master.studio    | Traceback (most recent call last):
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
edx.devstack-koa.master.studio    |     httplib_response = self._make_request(
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/urllib3/connectionpool.py", line 394, in _make_request
edx.devstack-koa.master.studio    |     conn.request(method, url, **httplib_request_kw)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/urllib3/connection.py", line 234, in request
edx.devstack-koa.master.studio    |     super(HTTPConnection, self).request(method, url, body=body, headers=headers)
edx.devstack-koa.master.studio    |   File "/usr/lib/python3.8/http/client.py", line 1255, in request
edx.devstack-koa.master.studio    |     self._send_request(method, url, body, headers, encode_chunked)
edx.devstack-koa.master.studio    |   File "/usr/lib/python3.8/http/client.py", line 1301, in _send_request
edx.devstack-koa.master.studio    |     self.endheaders(body, encode_chunked=encode_chunked)
edx.devstack-koa.master.studio    |   File "/usr/lib/python3.8/http/client.py", line 1250, in endheaders
edx.devstack-koa.master.studio    |     self._send_output(message_body, encode_chunked=encode_chunked)
edx.devstack-koa.master.studio    |   File "/usr/lib/python3.8/http/client.py", line 1010, in _send_output
edx.devstack-koa.master.studio    |     self.send(msg)
edx.devstack-koa.master.studio    |   File "/usr/lib/python3.8/http/client.py", line 950, in send
edx.devstack-koa.master.studio    |     self.connect()
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/urllib3/connection.py", line 200, in connect
edx.devstack-koa.master.studio    |     conn = self._new_conn()
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/urllib3/connection.py", line 181, in _new_conn
edx.devstack-koa.master.studio    |     raise NewConnectionError(
edx.devstack-koa.master.studio    | urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fcda850d4c0>: Failed to establish a new connection: [Errno 111] Connection refused
edx.devstack-koa.master.studio    |
edx.devstack-koa.master.studio    | During handling of the above exception, another exception occurred:
edx.devstack-koa.master.studio    |
edx.devstack-koa.master.studio    | Traceback (most recent call last):
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
edx.devstack-koa.master.studio    |     resp = conn.urlopen(
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
edx.devstack-koa.master.studio    |     retries = retries.increment(
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/urllib3/util/retry.py", line 573, in increment
edx.devstack-koa.master.studio    |     raise MaxRetryError(_pool, url, error or ResponseError(cause))
edx.devstack-koa.master.studio    | urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=18000): Max retries exceeded with url: /api/courses/v1/blocks?course_id=course-v1%3AedX%2BDemoX%2BDemo_Course&all_blocks=False&depth=all&requested_fields=student_view_data%2Cchildren&student_view_data=pb-answer&block_types_filter=pb-answer%2Cproblem-builder%2Cvertical%2Csequential%2Cchapter%2Ccourse&username=edx (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fcda850d4c0>: Failed to establish a new connection: [Errno 111] Connection refused'))
edx.devstack-koa.master.studio    |
edx.devstack-koa.master.studio    | During handling of the above exception, another exception occurred:
edx.devstack-koa.master.studio    |
edx.devstack-koa.master.studio    | Traceback (most recent call last):
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/edx-platform/cms/djangoapps/contentstore/views/preview.py", line 327, in get_preview_fragment
edx.devstack-koa.master.studio    |     fragment = module.render(preview_view, context)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/core.py", line 199, in render
edx.devstack-koa.master.studio    |     return self.runtime.render(self, view, context)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/x_module.py", line 1979, in render
edx.devstack-koa.master.studio    |     return self.__getattr__('render')(block, view_name, context)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/x_module.py", line 1423, in render
edx.devstack-koa.master.studio    |     return super(MetricsMixin, self).render(block, view_name, context=context)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 826, in render
edx.devstack-koa.master.studio    |     frag = view_fn(context)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/vertical_block.py", line 152, in author_view
edx.devstack-koa.master.studio    |     self.render_children(context, fragment, can_reorder=True, can_add=True)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/studio_editable.py", line 29, in render_children
edx.devstack-koa.master.studio    |     rendered_child = child.render(StudioEditableModule.get_preview_view_name(child), context)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/core.py", line 199, in render
edx.devstack-koa.master.studio    |     return self.runtime.render(self, view, context)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/x_module.py", line 1979, in render
edx.devstack-koa.master.studio    |     return self.__getattr__('render')(block, view_name, context)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/x_module.py", line 1423, in render
edx.devstack-koa.master.studio    |     return super(MetricsMixin, self).render(block, view_name, context=context)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 826, in render
edx.devstack-koa.master.studio    |     frag = view_fn(context)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/eoc_journal/eoc_journal.py", line 231, in student_view
edx.devstack-koa.master.studio    |     context.update(self._get_user_state())
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/eoc_journal/eoc_journal.py", line 206, in _get_user_state
edx.devstack-koa.master.studio    |     "answer_sections": self.list_user_pb_answers_by_section(),
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/eoc_journal/eoc_journal.py", line 306, in list_user_pb_answers_by_section
edx.devstack-koa.master.studio    |     blocks = self.list_pb_answers()
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/eoc_journal/eoc_journal.py", line 382, in list_pb_answers
edx.devstack-koa.master.studio    |     response = self._fetch_pb_answer_blocks(all_blocks)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/eoc_journal/eoc_journal.py", line 534, in _fetch_pb_answer_blocks
edx.devstack-koa.master.studio    |     response = client.get_blocks(
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/eoc_journal/course_blocks_api.py", line 20, in get_blocks
edx.devstack-koa.master.studio    |     return self.client.get(
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/requests/sessions.py", line 555, in get
edx.devstack-koa.master.studio    |     return self.request('GET', url, **kwargs)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
edx.devstack-koa.master.studio    |     resp = self.send(prep, **send_kwargs)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
edx.devstack-koa.master.studio    |     r = adapter.send(request, **kwargs)
edx.devstack-koa.master.studio    |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
edx.devstack-koa.master.studio    |     raise ConnectionError(e, request=request)
edx.devstack-koa.master.studio    | requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=18000): Max retries exceeded with url: /api/courses/v1/blocks?course_id=course-v1%3AedX%2BDemoX%2BDemo_Course&all_blocks=False&depth=all&requested_fields=student_view_data%2Cchildren&student_view_data=pb-answer&block_types_filter=pb-answer%2Cproblem-builder%2Cvertical%2Csequential%2Cchapter%2Ccourse&username=edx (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fcda850d4c0>: Failed to establish a new connection: [Errno 111] Connection refused'))
arbrandes commented 3 years ago

Acknowledging this one as well. Will check if somebody on our team can take a look.

shimulch commented 3 years ago

@BbrSofiane, Thanks for reporting the issue. Similar to #42, this xblock is only known to work till Ginkgo. We are yet to find out its compatibility with Juniper and later releases.

BbrSofiane commented 3 years ago

@shimulch fair enough. Are there any plans to make it compatible with Juniper and/or Koa?

Kelketek commented 3 years ago

Just some context here, based on what I'm seeing in the exception:

18000 is the default LMS port. Is the LMS running? If it is and you're getting this error, this might be due to the differences between the docker devstack and the vagrant box devstack of Ginkgo yore. On the vagrant devstack, all of the services ran from one VM. With the docker devstack, the containers have their own network and communicate with each other via DNS-style names. localhost might not work there since the studio container is a different one and I'm not sure they share ports via localhost, too.

However my biggest suspicion is that the LMS isn't running since the tracebacks don't mention any code within the XBlock itself, only internal platform code. If that's not the case then it must be that this XBlock is accessing studio code that is rarely used within other XBlocks and so hasn't been made aware within the devstack of the new arrangements. Or that the traceback is missing something important.

Either way, I hope that helps you diagnose the issue. Unfortunately we don't have any active plans to port this XBlock forward. We'd be happy to accept pull requests for it, and in the future we upgrade it if one of our clients decides to use it with an upgraded version.

BbrSofiane commented 3 years ago

@Kelketek thanks for the update.

The LMS was running when I tried on devstack. Could it be that the edx-rest-api-client needs to be updated to 5.2.1? I'll dig into it and I'll post here if I get anywhere.

xitij2000 commented 3 years ago

@BbrSofiane This block should work on Juniper, however it is designed for the solutions fork of the edx-platform and will not work without modification on the regular version. It should be possible to disable the features that depend on the solutions fork, or find alternative APIs that work on the standard edX version.

We'd be happy to accept PRs for the same.

Kelketek commented 3 years ago

Closing this issue since we don't have any plans to upgrade compatibility at this time. As mentioned, we'd be happy to review a PR if one comes in. Thanks, all!