Figma Support Forum

ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

Hi
We use figma REST API for download images in to our Android project
When we make this request: https://api.figma.com/v1/files/Kt0SPhKriaqUtT3NZCudzy/nodes

In random way we get this error:
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

Sometimes requests complete successfully
We use python39, requests.get()

Stacktrace:

C:\Users\ivan.andreyshev\DEV\tools>android_build.bat proapteka                                                                                                                                                     Traceback (most recent call last):
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 411, in connect
    self.sock = ssl_wrap_socket(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 428, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\retry.py", line 531, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 411, in connect
    self.sock = ssl_wrap_socket(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 428, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ivan.andreyshev\DEV\tools\figma_updater.py", line 241, in <module>
    main()
  File "C:\Users\ivan.andreyshev\DEV\tools\figma_updater.py", line 237, in main
    args.func(args)
  File "C:\Users\ivan.andreyshev\DEV\tools\figma_updater.py", line 106, in _android_colors_update
    figma_color_sets = _load_color_sets(args.token, configuration.url)
  File "C:\Users\ivan.andreyshev\DEV\tools\figma_updater.py", line 27, in _load_color_sets
    figma_colors = parser.load_page_colors(parsed_url.page_id)
  File "C:\Users\ivan.andreyshev\DEV\tools\figma\figma.py", line 112, in load_page_colors
    nodes_json = self._api.load_node(page_id)
  File "C:\Users\ivan.andreyshev\DEV\tools\figma\figma.py", line 98, in load_node
    return self._api.load_node(self._file_id, node_id)
  File "C:\Users\ivan.andreyshev\DEV\tools\figma\figma.py", line 35, in load_node
    return self.load_nodes(file_id, [node_id])
  File "C:\Users\ivan.andreyshev\DEV\tools\figma\figma.py", line 32, in load_nodes
    return self._get(url, {"ids": ",".join(node_ids)})
  File "C:\Users\ivan.andreyshev\DEV\tools\figma\figma.py", line 57, in _get
    response = requests.get(url, params, headers=self._headers())
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
Traceback (most recent call last):
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 411, in connect
    self.sock = ssl_wrap_socket(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 428, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\retry.py", line 531, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 411, in connect
    self.sock = ssl_wrap_socket(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 428, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(                                                                                                                                                                             File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create                                                                                                             self.do_handshake()                                                                                                                                                                                              File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake                                                                                                        self._sslobj.do_handshake()                                                                                                                                                                                    urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))                                                                                                                                                                                                                                                            During handling of the above exception, another exception occurred:                                                                                                                                                                                                                                                                                                                                                                   Traceback (most recent call last):                                                                                                                                                                                   File "C:\Users\ivan.andreyshev\DEV\tools\figma_updater.py", line 241, in <module>                                                                                                                                    main()                                                                                                                                                                                                           File "C:\Users\ivan.andreyshev\DEV\tools\figma_updater.py", line 237, in main                                                                                                                                        args.func(args)                                                                                                                                                                                                  File "C:\Users\ivan.andreyshev\DEV\tools\figma_updater.py", line 145, in _android_image_update                                                                                                                       image_updater.update(configuration)                                                                                                                                                                              File "C:\Users\ivan.andreyshev\DEV\tools\android\android_images_updater.py", line 38, in update                                                                                                                      self.__update_all_png(configuration.png, url)                                                                                                                                                                    File "C:\Users\ivan.andreyshev\DEV\tools\android\android_images_updater.py", line 48, in __update_all_png                                                                                                            self.__update_png(                                                                                                                                                                                               File "C:\Users\ivan.andreyshev\DEV\tools\android\android_images_updater.py", line 73, in __update_png                                                                                                                self.__image_downloader.download_images(FigmaImageFormat.PNG, image, image_scale)                                                                                                                                File "C:\Users\ivan.andreyshev\DEV\tools\figma\figma_image_downloader.py", line 52, in download_images                                                                                                               node_ids = self._page_components.get(name_path[0])                                                                                                                                                               File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\functools.py", line 969, in __get__                                                                                                        val = self.func(instance)                                                                                                                                                                                        File "C:\Users\ivan.andreyshev\DEV\tools\figma\figma_image_downloader.py", line 67, in _page_components                                                                                                              response = self._api.load_node(self._page_id)                                                                                                                                                                    File "C:\Users\ivan.andreyshev\DEV\tools\figma\figma.py", line 98, in load_node                                                                                                                                      return self._api.load_node(self._file_id, node_id)                                                                                                                                                               File "C:\Users\ivan.andreyshev\DEV\tools\figma\figma.py", line 35, in load_node                                                                                                                                      return self.load_nodes(file_id, [node_id])                                                                                                                                                                       File "C:\Users\ivan.andreyshev\DEV\tools\figma\figma.py", line 32, in load_nodes                                                                                                                                     return self._get(url, {"ids": ",".join(node_ids)})                                                                                                                                                               File "C:\Users\ivan.andreyshev\DEV\tools\figma\figma.py", line 57, in _get                                                                                                                                           response = requests.get(url, params, headers=self._headers())                                                                                                                                                    File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\api.py", line 76, in get                                                                                            return request('get', url, params=params, **kwargs)                                                                                                                                                              File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\api.py", line 61, in request                                                                                        return session.request(method=method, url=url, **kwargs)                                                                                                                                                         File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 542, in request                                                                                  resp = self.send(prep, **send_kwargs)                                                                                                                                                                            File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 655, in send                                                                                     r = adapter.send(request, **kwargs)                                                                                                                                                                              File "C:\Users\ivan.andreyshev\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 498, in send                                                                                     raise ConnectionError(err, request=request)                                                                                                                                                                    requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))                                      Complete!