xamarin.forms httpclient lte too slow

Viewed 821

in my Crossplatform App I work with httpClient and NativeMessageHandler. I call an webservice through httpclient. When i call the webservice with WLAN ON it works perfectly, with no WLAN, so LTE on iPhone it works perfectly, too. But if I have LTE activated on Android, i get an Timeout in the following line, if I not set the Timeout value. But If I set Timeout, than the Post Need more than a few minutes:

client = new HttpClient(new NativeMessageHandler());
client.BaseAddress = new Uri(App.hostserveradress);
client.Timeout = TimeSpan.FromMinutes(20);
var contentReset = new StringContent(mobileJSON, Encoding.UTF8, "application/json");
var responseReset = await client.PostAsync("GetResetFotos", contentReset); **// ERROR**
var resultReset = await responseReset.Content.ReadAsStringAsync();

UPDATE:

Error from Try Catch block:

System.OperationCanceledException: The operation was canceled.
  at ModernHttpClient.NativeMessageHandler+<SendAsync>c__async0.MoveNext () [0x00422] in <51795dd1dbb344bdacae7208f448a6b3>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0001a] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
  at System.Net.Http.HttpClient+<SendAsyncWorker>d__49.MoveNext () [0x000ca] in <7736395a6c71409691a34accfc621095>:0 

If I added the Timeout, the Post get data back, but that is too slow for LTE. It takes a few minutes before receiving data. This is, what I get back from PostAsync:

{StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: ModernHttpClient.ProgressStreamContent, Headers:
{
Cache-Control: max-age=0, private
Date: 16.11.2017 10:34:35 +00:00
OkHttp-Received-Millis: 1510828472777
OkHttp-Selected-Protocol: http/1.1
OkHttp-Sent-Millis: 1510828472613
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Content-Length: 330
Content-Type: application/json; charset=utf-8
OkHttp-Received-Millis: 1510828472777
OkHttp-Selected-Protocol: http/1.1
OkHttp-Sent-Millis: 1510828472613
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
}}

What is my mistake ?

0 Answers
Related