You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

lillyeee's avatar
lillyeee
New member | Level 1
2 months ago

API 'Connection Aborted' Error

Hello!

I'm downloading files from an App Folder. I am downloading each one by one, totaling over 3000 files. I left the program to run and after 201 requests I got the error pasted below. I don't have a VPN or anything that would change my wifi connection as far as I know. Here is the code I am using:

print("Initializing Dropbox API...")
dbx = dropbox.Dropbox(AUTHORIZATION_TOKEN)
topn = filenames[:len(filenames)]

for val in topn:
     filepath = val
     #download a file to the local machine

     with open("/Users/<PATH>/dataimport.csv.gz", "wb") as f:
          metadata, res = dbx.files_download(path=filepath)
          f.write(res.content)
     print("download complete")

The error:

RemoteDisconnected                         Traceback (most recent call last)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py:789, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw)
788 # Make the request on the HTTPConnection object -->
789 response = self._make_request(
790 conn,
791 method,
792 url,
793 timeout=timeout_obj,
794 body=body,
795 headers=headers,
796 chunked=chunked,
797 retries=retries,
798 response_conn=response_conn,
799 preload_content=preload_content,
800 decode_content=decode_content,
801 **response_kw,
802 )
804 # Everything went great! File

/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py:536, in HTTPConnectionPool._make_request(self, conn, method, url, body, headers, retries, timeout, chunked, response_conn, preload_content, decode_content, enforce_content_length)
535 try: -->
536 response = conn.getresponse()
537 except (BaseSSLError, OSError) as e:

...

684 except MaxRetryError as e:
685 if isinstance(e.reason, ConnectTimeoutError):
686 # TODO: Remove this in 3.0.0: see #2811
ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    Does this reliably reproduce for you?I just tried this code out, filling in the missing pieces, and the issue didn't occur for me. If it's not consistent, it could be due to random transient server availability or networking issues, in which case you may want to implement additional retries (ideally with exponential backoff) to handle transient issues like this.

    If it is consistent though, does it always reproduce after 201 requests, or perhaps on the same file? If it reproduces on the same file, how large is the file and how long does it take on that file before failing?

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,910 PostsLatest Activity: 4 days ago
333 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!