cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you interested in hearing how one of our Community members uses Dropbox for sailing trips? Read all about it here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: list_folder_continue -> 504 errors

list_folder_continue -> 504 errors

deeuu
Explorer | Level 4
Go to solution

Hello,

I'm using `list_folder_continue` of the Python SDK to recursively traverse (via pagination) a folder with a very large number of files (hundreds of thousands).  After a while, I'm running into internal server errors. Here's the log:

2018-09-24 20:09:12,831 - dropbox - INFO - Request to files/list_folder/continue
2018-09-24 20:10:42,843 - urllib3.connectionpool - DEBUG - https://api.dropboxapi.com:443 "POST /2/files/list_folder/continue HTTP/1.1" 504 35
2018-09-24 20:10:42,845 - dropbox - INFO - HttpError status_code=504: Retrying in 0.7 seconds
2018-09-24 20:10:43,505 - dropbox - INFO - Request to files/list_folder/continue
2018-09-24 20:12:13,521 - urllib3.connectionpool - DEBUG - https://api.dropboxapi.com:443 "POST /2/files/list_folder/continue HTTP/1.1" 504 35
2018-09-24 20:12:13,522 - dropbox - INFO - HttpError status_code=504: Retrying in 0.8 seconds
2018-09-24 20:12:14,320 - dropbox - INFO - Request to files/list_folder/continue
2018-09-24 20:13:44,336 - urllib3.connectionpool - DEBUG - https://api.dropboxapi.com:443 "POST /2/files/list_folder/continue HTTP/1.1" 504 35
2018-09-24 20:13:44,337 - dropbox - INFO - https://www.google.com/search?client=ubuntu&channel=fs&q=recusrively+traverse+&ie=utf-8&oe=utf-8Http... status_code=504: Retrying in 6.8 seconds
2018-09-24 20:13:51,148 - dropbox - INFO - Request to files/list_folder/continue
2018-09-24 20:15:21,163 - urllib3.connectionpool - DEBUG - https://api.dropboxapi.com:443 "POST /2/files/list_folder/continue HTTP/1.1" 504 35
2018-09-24 20:15:21,165 - dropbox - INFO - HttpError status_code=504: Retrying in 9.4 seconds
2018-09-24 20:15:30,565 - dropbox - INFO - Request to files/list_folder/continue
2018-09-24 20:17:00,580 - urllib3.connectionpool - DEBUG - https://api.dropboxapi.com:443 "POST /2/files/list_folder/continue HTTP/1.1" 504 35
2018-09-24 20:17:00,582 - dropbox - INFO - HttpError status_code=504: Retrying in 2.0 seconds
2018-09-24 20:17:02,557 - dropbox - INFO - Request to files/list_folder/continue
2018-09-24 20:18:32,572 - urllib3.connectionpool - DEBUG - https://api.dropboxapi.com:443 "POST /2/files/list_folder/continue HTTP/1.1" 504 35

Is this attributable to the overall activity in the account (tis a business account with 10 users)?

Many thanks

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

Thanks for the report! This can be related to these operations taking a long time due to a large number of files and/or a large amount of file activity in the affected account(s).

We'll look into it, but there are a few potential workarounds:

1) Use the 'limit' parameter on files_list_folder:

https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.dropbox.Dropbox.files_lis...

If you specify a smaller value (the default is effectively around 2000), that should help reduce how long each of these calls takes and reduce the likelihood that they will fail. Note that you supply the 'limit' value to files_list_folder itself, and it will apply to all results from files_list_folder_continue using the returned cursor as well.

2) If you are using recursive=True, switch to recursive=False when calling files_list_folder. This means you would need to make a call for each sub-folder you need though.

View solution in original post

8 Replies 8

deeuu
Explorer | Level 4
Go to solution

I should also add that when re-running my script, calling list_folder_continue with the most recent cursor prior to catching the InternalServerError, takes a very long time to get going again, with the same API request attempts:

2018-09-25 08:59:14,422 - dropbox - INFO - Request to files/list_folder/continue
2018-09-25 09:00:44,445 - urllib3.connectionpool - DEBUG - https://api.dropboxapi.com:443 "POST /2/files/list_folder/continue HTTP/1.1" 504 35
2018-09-25 09:00:44,446 - dropbox - INFO - HttpError status_code=504: Retrying in 2.0 seconds
2018-09-25 09:00:46,445 - dropbox - INFO - Request to files/list_folder/continue
2018-09-25 09:02:16,463 - urllib3.connectionpool - DEBUG - https://api.dropboxapi.com:443 "POST /2/files/list_folder/continue HTTP/1.1" 504 35
2018-09-25 09:02:16,464 - dropbox - INFO - HttpError status_code=504: Retrying in 3.8 seconds
2018-09-25 09:02:20,277 - dropbox - INFO - Request to files/list_folder/continue
2018-09-25 09:03:50,319 - urllib3.connectionpool - DEBUG - https://api.dropboxapi.com:443 "POST /2/files/list_folder/continue HTTP/1.1" 504 35
2018-09-25 09:03:50,320 - dropbox - INFO - HttpError status_code=504: Retrying in 7.6 seconds
2018-09-25 09:03:57,961 - dropbox - INFO - Request to files/list_folder/continue
2018-09-25 09:05:27,982 - urllib3.connectionpool - DEBUG - https://api.dropboxapi.com:443 "POST /2/files/list_folder/continue HTTP/1.1" 504 35
2018-09-25 09:05:27,984 - dropbox - INFO - HttpError status_code=504: Retrying in 0.3 seconds
2018-09-25 09:05:28,278 - dropbox - INFO - Request to files/list_folder/continue

Greg-DB
Dropbox Staff
Go to solution

Thanks for the report! This can be related to these operations taking a long time due to a large number of files and/or a large amount of file activity in the affected account(s).

We'll look into it, but there are a few potential workarounds:

1) Use the 'limit' parameter on files_list_folder:

https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.dropbox.Dropbox.files_lis...

If you specify a smaller value (the default is effectively around 2000), that should help reduce how long each of these calls takes and reduce the likelihood that they will fail. Note that you supply the 'limit' value to files_list_folder itself, and it will apply to all results from files_list_folder_continue using the returned cursor as well.

2) If you are using recursive=True, switch to recursive=False when calling files_list_folder. This means you would need to make a call for each sub-folder you need though.

deeuu
Explorer | Level 4
Go to solution

Thanks for getting back to me Greg.

I'd rather not have to go with #2 because this implies I can't reliably check for changes in the folder at a later stage using the cursor obtained from `files_list_folder_get_latest_cursor`. i.e. #1 would require me to traverse the entire folder each time I want to check for changes (or require me to store multiple cursors for sub-directories etc.).

I've already been `running files_list_folder` with `limit` set to 500, and each time the internal server error occurs after about approx 310,000 files/folders. So I can almost predict when the error will occur.

I'll try it again with `limit` set to 50 and report back tomorrow.

Is this issue related to the number of files in a folder, i.e. limit -> 1 as number of files -> infinity? If so, I'll stop using cursors altogether.

 

 

 

 

 

 

Greg-DB
Dropbox Staff
Go to solution

Yes, this is likely related to the number of files, but possibly also the amount of file activity. (So, yes, as the number of files goes to infinity, the working limit would go down.)

deeuu
Explorer | Level 4
Go to solution

Hi @Greg-DB,

So, after about 270,000 files/folders, I received an Internal Server Error (with `limit` set to 50), and can't seem to get going again with the cursor I stored prior to the collapse.

I guess I have to conclude that cursors aren't reliable for traversing folders with many files and sub-folders.

I'm not even sure its worth re-designing my app to use cursors for checking the state of each sub-directory, so I'll have to go with your #2 each time.

Greg-DB
Dropbox Staff
Go to solution

Thanks for trying that, and my apologies for the trouble. I'll follow up here when I have any updates on this issue.

NathanA
New member | Level 2
Go to solution

Hello, any updates on this issue ? The issue is not solved, we still face this issue

kylea
Dropbox Staff
Go to solution

In addition to the techniques mentioned in this thread, I would also suggest traversing with include_mounted_folders=false.

Mounted folders refer to folder shares or team folders. With that option, the mount point (shared folder id) is still returned in the output, but not the share's content.  You could then traverse the share independently with a different cursor.

 

This is particularly helpful for large team folders or scenarios with a lot of large shares.

We have updated our reference guides with best practices since this thread started, check them out here.

I don't have a specific update on the 504 error the original poster mentioned - are you seeing the 504 code, or something else?  Including a little more detail on the error response you're seeing may help.

Need more support?