We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
pear0533
2 years agoExplorer | Level 3
Dropbox API Hangs During Large File Download
Hey there! I am currently maintaining a mod launcher software that utilizes the Dropbox .NET C# API to allow users to download mod files.
Unfortunately, large files (usually 2-5GB in size) do n...
pear0533
Explorer | Level 3
There is nothing particularly wrong with the network connections that these users who are experiencing issues have. Plenty of them actually have relatively fast internet, so this shouldn't be an issue. Here are some user reports that I have received to give you an idea of what users themselves are seeing on their sides:
1. "[mod] downloads just stops for no apparent reason PS4 version [a mod available in the launcher is stuck] @54% and XBOX [another mod stuck] @60% connection [to the internet/Dropbox] is stable but shows 0kb send/0kb received after that point [in task manager, presumably]. with occasional spikes"
2. "My internet maybe isn't fast, but it's definitely [not] slow either. I've been stuck on 35% [while downloading a mod] for over an hour [now]."
3. "hello, i have good internet but the mod launcher [mod] download is slow and it stays stuck at 43% or 44%, i tried cancelling and redownloading but it keeps stopping at that point."
It seems most of these reports are happening at around the hour mark. Furthermore, I am not making several concurrent calls to the API to retrieve download blobs, I am making a single API call before a mod download even starts, and then reading the resulting stream returned by the call in a loop.
If the server is causing timeouts, is there any way to delay this from happening so that downloads can finish completely? As I said before, single/multiple range requests do not seem to work, and the downloads are much slower using range requests than with the API.
What is even weirder is the fact that downloads using the API for these users who are reporting download stalls are abnormally slow, regardless of whether the user has a poor or strong internet connection. This is what is most concerning, as this would indicate it is actually an issue with the way Dropbox is handling particular network configurations either through the mainline servers or the API network logic itself.
Greg-DB
2 years agoDropbox Staff
If these are failing at about an hour, it does sound like it is due to the server timeout. There isn't an option to delay or prevent that.
Also "downloads are much slower using range requests than with the API" is a bit unclear as range requests are themselves do use the same API. Specifically, the DownloadAsync method calls the /2/files/download API endpoint, just like you would if you make requests directly to /2/files/download without using the SDK, whether or not you set a range. Range requests just include an additional header to request a specific portion of the file.
In any case, the connection speed to the Dropbox API servers depends on a number of different factors that can change over time or by location, such as the routing between the user's ISP and our servers, and may be slower than the ISP's rated speeds. Sometimes resetting or retrying the connection gets the client a different route and better speeds, but that is outside of our control. Some ISPs also throttle sustained connections so if you see an initial high connection speed followed by lower speeds, that could be the reason.
So, the best recommendation I can offer is to use range requests to continue downloading the rest of the data if a connection fails, and repeat as needed for up to one hour per connection.
- pear05332 years agoExplorer | Level 3
Would you be able to provide a rough code sample to illustrate how this might be put into practice using the API? I've used range requests before, however I want to be certain that I am using them correctly in production code for the purposes of my launcher software.
- Greg-DB2 years agoDropbox Staff
I see the agent in the support ticket you referred to supplied this example:
HttpClient client = new HttpClient(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://content.dropboxapi.com/2/files/download"); request.Headers.Add("Authorization", "Bearer " + accessToken); request.Headers.Add("Dropbox-API-Arg", "{\"path\":\"/test.txt\"}"); // in real code, use a JSON library to build this request.Headers.Add("Range", "bytes=0-10"); // this requests the first 11 bytes of the file HttpResponseMessage response = await client.SendAsync(request); Stream stream = response.Content.ReadAsStream(); // read from stream as desired
That looks correct; the only additional thing you need to do to a /2/files/download call to request a specific range is add the "Range" header like that.
- Здравко2 years agoLegendary | Level 20
Greg-DB wrote:...
... request.Headers.Add("Range", "bytes=0-10"); // this requests the first 11 bytes of the file
......
Hi pear0533,
You don't actually need a range starting from zero. You can start with regular API call and if that breaks for some reason then go forward with range(s).
Let's say you have to download a file and start downloading it in regular way. At some moment transfer breaks, let say, at position 50 byte. Since headers are available, you know that the file is, let say, 200 bytes. So, you have downloaded 50 bytes already and there are some more to read. The easiest way is to set range to something like:
request.Headers.Add("Range", "bytes=50-");
I.e. you're starting from byte 51 and onward. Now, let's say you got another 70 bytes successfully. Together with the first 50 bytes they form successfully downloaded block of 120 bytes. You can continue with:
request.Headers.Add("Range", "bytes=120-");
I.e. you're starting again, but from byte 121 and onward. There is a big chance your download to complete successful. 😉 If not, continue the same logic further.
Hope this gives direction.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 12 months agoIf 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!