Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

Grant M.6's avatar
Grant M.6
New member | Level 1
10 years ago

Getting lots of connection timeout issues using Python API

The last few weeks I've been getting connection timeout issues more and more often. I am using the Dropbox Python API version 2.2.0 with Python 2.7.11.

For instance, I received this error when downloading a file that is only 473 KB large:

ConnectTimeoutError at /my_company/file/download.pdf (<urllib3.connectionpool.VerifiedHTTPSConnection instance at 0x7f4eaa950950>, ‘Connection to api-content.dropbox.com timed out. (connect timeout=60.0)’)

Here's the code that is being run inside of the view:

response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="preview.pdf"'
client = dropbox.client.DropboxClient('my_token')
with client.get_file(path) as f:
    response.write(f.read())
return response

Pretty basic stuff. Just downloading the file and rendering it to the response. Yet this resulted in a connection timeout error. Any ideas why?

1 Reply

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    10 years ago

    Hi Grant, thanks for the report. I can't seem to reproduce this here though. About what percent of your API calls are failing?

    For reference, I just tried this simplified code, using v2.2.0 of the SDK:

    import dropbox

    ACCESS_TOKEN = '...'

    client = dropbox.client.DropboxClient(ACCESS_TOKEN)

    for i in range(100):
    print(i)
    # /test.pdf is a 4MB PDF file
    print len(client.get_file("/test.pdf").read())

    I didn't get any timeout failures from that. Can you try it too and let me know what you get? Thanks in advance! 

    Also, there are of course many different factors that can impact network performance and reliability. Can you check on any security software, e.g., anti-virus, firewalls, or proxies that may be impacting your connection? Likewise, are you making many other calls at the same time, or otherwise congesting your network connection? Similarly, your ISP may be having trouble or throttling your connection.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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, Facebook or Instagram.

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!