Problems with Identicon/Gravatar (ConnectionResetError(104, 'Connection reset by peer'))

Hey, I have got a problem with a fresh Installation of Indico. Every time someone opens the Profile Picture Page of Indico the Server sends the Error Log below.
I think that this could be a problem of the Proxy Configuration. Does Indico fetch its proxy configs out of the /etc/environment? Or is there a possibility to configure a Proxy?
Thanks in advance :blush:

2022-03-01 12:51:30,629  b86fb5c83ca74606  1       indico.flask - ERROR errors.py:98 -- ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

Traceback (most recent call last):
  File "/opt/indico/.venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/opt/indico/.venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "/opt/indico/.venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "/opt/indico/.venv/lib/python3.9/site-packages/urllib3/connection.py", line 416, in connect
    self.sock = ssl_wrap_socket(
  File "/opt/indico/.venv/lib/python3.9/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "/opt/indico/.venv/lib/python3.9/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python3.9/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/lib/python3.9/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/usr/lib/python3.9/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/indico/.venv/lib/python3.9/site-packages/requests/adapters.py", line 440, in send
    resp = conn.urlopen(
  File "/opt/indico/.venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/opt/indico/.venv/lib/python3.9/site-packages/urllib3/util/retry.py", line 532, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/opt/indico/.venv/lib/python3.9/site-packages/urllib3/packages/six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "/opt/indico/.venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/opt/indico/.venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "/opt/indico/.venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "/opt/indico/.venv/lib/python3.9/site-packages/urllib3/connection.py", line 416, in connect
    self.sock = ssl_wrap_socket(
  File "/opt/indico/.venv/lib/python3.9/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "/opt/indico/.venv/lib/python3.9/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python3.9/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/lib/python3.9/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/usr/lib/python3.9/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/indico/.venv/lib/python3.9/site-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/indico/.venv/lib/python3.9/site-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/opt/indico/.venv/lib/python3.9/site-packages/indico/web/flask/util.py", line 79, in wrapper
    return obj().process()
  File "/opt/indico/.venv/lib/python3.9/site-packages/indico/web/rh.py", line 281, in process
    res = self._do_process()
  File "/opt/indico/.venv/lib/python3.9/site-packages/indico/web/rh.py", line 252, in _do_process
    rv = self._process()
  File "/opt/indico/.venv/lib/python3.9/site-packages/webargs/core.py", line 450, in wrapper
    return func(*args, **kwargs)
  File "/opt/indico/.venv/lib/python3.9/site-packages/indico/modules/users/controllers.py", line 237, in _process
    gravatar = get_gravatar_for_user(self.user, source == ProfilePictureSource.identicon, size=80)[0]
  File "/opt/indico/.venv/lib/python3.9/site-packages/indico/modules/users/util.py", line 425, in get_gravatar_for_user
    resp = requests.get(gravatar_url, params=params, headers=headers)
  File "/opt/indico/.venv/lib/python3.9/site-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/opt/indico/.venv/lib/python3.9/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/opt/indico/.venv/lib/python3.9/site-packages/requests/sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "/opt/indico/.venv/lib/python3.9/site-packages/requests/sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "/opt/indico/.venv/lib/python3.9/site-packages/requests/adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

{'data': {'get': {},
          'headers': {'Accept': 'image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8',
                      'Accept-Encoding': 'gzip, deflate, br',
                      'Accept-Language': 'de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7',
                      'Connection': 'close',
                      ***
                      'Host': 'events.geomar.de',
                      'Referer': 'https://events.geomar.de/user/1/profile/picture',
                      'Sec-Ch-Ua': '" Not A;Brand";v="99", "Chromium";v="98", '
                                   '"Opera";v="84"',
                      'Sec-Ch-Ua-Mobile': '?0',
                      'Sec-Ch-Ua-Platform': '"Windows"',
                      'Sec-Fetch-Dest': 'image',
                      'Sec-Fetch-Mode': 'no-cors',
                      'Sec-Fetch-Site': 'same-origin',
                      'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
                                    'AppleWebKit/537.36 (KHTML, like Gecko) '
                                    'Chrome/98.0.4758.102 Safari/537.36 '
                                    'OPR/84.0.4316.21',
                      'X-Forwarded-For': '172.21.212.8'},
          'json': None,
          'post': {},
          'url': {'source': 'gravatar'}},
 'endpoint': 'users.profile_picture_preview',
 'id': 'b86fb5c83ca74606',
 'ip': '193.174.124.227',
 'method': 'GET',
 'referrer': 'https://events.geomar.de/user/1/profile/picture',
 'rh': 'RHProfilePicturePreview',
 'time': '2022-03-01T12:51:30.639709',
 'url': 'https://events.geomar.de/user/profile/picture/preview/gravatar',
 'user': {'email': 'xyz@mail.de', 'id': x, 'name': 'xyz'},
 'user_agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '
               '(KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 '
               'OPR/84.0.4316.21'}

Yes, this looks like it can’t make an outgoing connection. Is internet access restricted on your server?

If yes you probably need to send environment variables such as http_proxy (most likely via uwsgi.ini) so Indico uses whatever proxy you need when making outgoing connections.

Thanks for the answer :slight_smile:

/etc/uwsgi-indico.ini

env = HTTP_PROXY=http://ourproxy:8080
env = HTTPS_PROXY=http://ourproxy:8080

Did the Trick