Exceptions in HttpClient

I am seeing a lot of Exceptions in HttpClient, both on iOS and on Android.
The easiest way to reproduce them is by doing more than one postAsync at the same time.
It will almost all the time trigger a ProtocolViolationException about an invalid content-length.

Doing more async-calls than the limit in ServicePointManager.DefaultConnectionLimit is also a recipe for Exceptions:
System.InvalidOperationException: Cannot re-call start of asynchronous method while a previous call is still in progress.
and
System.Threading.Tasks.TaskCanceledException: The Task was canceled

From my understanding HttpClient should be able to handle multiple requests at the same time. I read everywhere that is is advisable to have one HttpClient in your project (at least one per webserver/service).

Test-project: https://github.com/TeunVR/HttpClientCrash
Am i using the HttpClient correctly in this testproject?

There was already a bug filed for this, i added a comment with the project to reproduce it.
See also https://bugzilla.xamarin.com/show_bug.cgi?id=23957

Posts

  • This is really blocking my project and is giving Xamarin a bit of beta feeling. When we were in testing phase everything seemed to be working ok, new version of Xamarin and these "random" issues showing up when i'm going to production with a tight deadline.

  • EgorBoEgorBo BYXamarin Team ✭✭✭

    Same for me, I really didn't expect that PostAsync may throw TaskCancelledException

  • PramodPatilPramodPatil USMember ✭✭

    Facing same issue..... any one know the solution????

Sign In or Register to comment.