We Want to Hear From You! What Do You Want to See on the Community? Tell us here!
Forum Discussion
Mark R.5
9 years agoHelpful | Level 5
Dropbox API V2 .NET SDK TaskCancelledException
This is running the .NET SDK within a Xamarin wrapper, on Android Lollipop (the code should be identical to the standard .NET SDK). I have only seen this error on one specific device and even then it is sporadic.
The problem is that on occasion, some API calls which access the server (e.g. GetCurrentAccountAsync) fail eventually (after 90 secs) with the exception:
System.Threading.Tasks.TaskCanceledException: A task was canceled. at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00031] in <f03edc016c014bac8ee539e393953ea8>:0 at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess (System.Threading.Tasks.Task task) [0x0001c] in <f03edc016c014bac8ee539e393953ea8>:0 at Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00009] in <f03edc016c014bac8ee539e393953ea8>:0 at Microsoft.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <f03edc016c014bac8ee539e393953ea8>:0 at Dropbox.Api.DropboxRequestHandler+SendRpcRequestAsync>d__4`3[TRequest,TResponse,TError].MoveNext () [0x000ba] in <a1bcd0b30e2f4dc8afce94d298e18a52>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <72212be3f8434fcc8ed07369601537c5>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0001a] in <72212be3f8434fcc8ed07369601537c5>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <72212be3f8434fcc8ed07369601537c5>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <72212be3f8434fcc8ed07369601537c5>:0 at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <72212be3f8434fcc8ed07369601537c5>:0 at App.Managers.DropboxManager+<getChanges>d__110.MoveNext () [0x0015b] in <9a4ca823eb0f4b35be14b14b7ed01adb>:0
I am not sure what is triggering this cancellation, but it is not coming from my code. Any ideas or pointers?
4 Replies
- Greg-DB9 years ago
Dropbox Community Moderator
I believe this TaskCanceledException should indicate a timeout on the network connection for the API call. It sounds like that is what's happening, since you mentioned it takes around 90 seconds to fail. Is there anything on the network connection that might be interfering when this happens? (E.g., proxy, firewall, etc.)
Anyway, that being the case, you may want to catch this and retry the call when it occurs. - Mark R.59 years agoHelpful | Level 5
Hi. There was nothing interfering as far as I am aware. Web browsing was working while the Dropbox timeout was occuring so there was a working internet connection at the time. It may not have been the strongest connection though.
On a related note, I was wanting to follow the code through to see what was going on:
https://github.com/dropbox/dropbox-sdk-dotnet
However I cannot find some of the source code in there. For example I can't see the code for any of the 'Files' methods such as DownloadAsync. Am I missing something?
- Greg-DB9 years ago
Dropbox Community Moderator
The SDK is actually generated based on the API spec, so each method isn't implemented individually. For example, here's the implementation for any "download-style" request (such as DownloadAsync, or GetThumbnailAsync).
- Mark R.59 years agoHelpful | Level 5
Ok, maybe I should read up on that a bit more. The abstraction just makes it a little harder to work out what is going on. Maybe the generated code could be put into github as well.
To get back to the original issue, one thing I observed is that some methods would work and others would not. For example, I have a ListFolderLongpollAsync method running in a loop to listen for changes. This method was working and returning when changes occurred. However as soon as it then went on to do a ListFolderContinueAsync to get the actual changes the timeout was occurring. This loop was then repeated consistently, with the ListFolderLongpollAsync working, but the ListFolderContinueAsync failing.
I will try and investigate further to see if I can find a trigger.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,036 PostsLatest Activity: 3 days ago
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 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!