Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 15605 [details]
A demo app which illustrates the inconsistent and incorrect HttpClient timeout behaviour
There seems to be inconsistent behaviour with the timeout when using the HttpClient class.
The scenario arose for us when sending a Web API request is sent to a IP address which does not exist/reachable via the mobile network. Wifi is turned off
I have included a zip file containing an app to demonstrate this. (You will probably have to change the IP when to attempt to repeat the issue in your test environment)
1. If you alter the code to send the last request only, then the 15 second time-out is honoured
2. If you alter the code to send both the first and last request then , then on the first attempt, the timeout is not honoured (it takes over a minute, but if you repeat the action it is honoured the second time.
3. If you alter the code to send all three requests , then the timeout is sometimes not honoured for a couple of repeated requests. I have also seen the last request not timing out, the first and second attempts timeout.
The task which initiates the request, seems to be irrelevant as the same behaviour is exhibited regardless of whether Task.Run or Task.Factory.StartNew is used
This behaviour seems inconsistent and wrong. Can you investigate, and provide a fix.
I am running this on an iPhone 6 runinng iOS version 9.2.1 (13D15)
This has been built on visual studio 2012 update 5, with the following installed
Xamarin 220.127.116.11 (odd817c)
Xamarin.Android 18.104.22.168 (a94a03b)
Xamarin.iOS 22.214.171.124 (3a25bf1)
My mac is running the following software
=== Xamarin Studio ===
Version 5.10.3 (build 27)
Installation UUID: c0a4c8dc-0061-4b22-a3ad-b4e6bc68b1db
Mono 4.2.3 (explicit/832de4b)
GTK+ 2.24.23 (Raleigh theme)
Package version: 402030004
=== Xamarin.Profiler ===
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Apple Developer Tools ===
Xcode 7.2 (9548)
=== Xamarin.Mac ===
Version: 126.96.36.199 (Starter Edition)
=== Xamarin.Android ===
Version: 188.8.131.52 (Business Edition)
Android SDK: /Users/McCoolM/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
2.3 (API level 10)
4.0.3 (API level 15)
4.4 (API level 19)
5.0 (API level 21)
SDK Tools Version: 24.2.0
SDK Platform Tools Version: 22.0.0
SDK Build Tools Version: 22.0.1
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
Android Designer EPL code available here:
=== Xamarin Android Player ===
=== Xamarin.iOS ===
Version: 184.108.40.206 (Business Edition)
Build date: 2016-03-21 20:13:04-0400
=== Build Information ===
Release ID: 510030027
Git revision: 8dc6bca63f5cd93719a093973e74de6999864193
Build date: 2016-03-17 17:13:33-04
Xamarin addins: 45239909442742bdee83a0c0f77eecb8a08bedfa
Build lane: monodevelop-lion-cycle6-c6sr2
=== Operating System ===
Mac OS X 10.10.5
Darwin W013208-MAC 14.5.0 Darwin Kernel Version 14.5.0
Wed Jul 29 02:26:53 PDT 2015
I need some help in reproducing this. Using your sample with IP address which does not exist in my local network I get
2016-05-10 21:44:36.618 TimeoutDemoTouch[59257:2416276] mvx:Diagnostic: 25.69 Starting test...
2016-05-10 21:44:42.992 TimeoutDemoTouch[59257:2416614] mvx:Diagnostic: 32.06 Completed first request- Exception occurred [Error: ConnectFailure (Network is unreachable)]
2016-05-10 21:44:42.992 TimeoutDemoTouch[59257:2416613] mvx:Diagnostic: 32.06 Completed last request- Exception occurred [Error: ConnectFailure (Network is unreachable)]
2016-05-10 21:44:42.992 TimeoutDemoTouch[59257:2416612] mvx:Diagnostic: 32.06 Completed second request- Exception occurred [Error: ConnectFailure (Network is unreachable)]
2016-05-10 21:44:42.992 TimeoutDemoTouch[59257:2416613] mvx:Diagnostic: 32.06 Test completed
Which looks ok to me as it's less than 15 seconds timeout.
The scenario we have is that our servers are on a private network, therefore we cannot access it across the mobile network. We can only access it via wifi. The IP address you are attempting to access must be reachable via the wifi network.
So the scenario is start the app, turn off wifi (mobile still turned on), then run the test.
I don't know if the lack of mobile connectivity aspect of it is significant.
I am still trying to repro this as I don't have same network setup.
Does this happen on device only or also on simulator?
Does this happen when you disable wifi before running the app?
If your server is on private network perhaps you could share the IP with me privately so I get same response from your firewall as you do when using public network.
I cannot provide access to our network.
I have been testing this on an iPhone 6 and a 5S.
Have you changed the code to send more than one request. A single request always works. You have to change the code to simulate the error.
What is the issue you are having replicating it?
I cannot replicate the case where timeout is ignored.
I am testing on simulator (don't have a device with GSM/3G/LTE/etc network) but whatever I tried once the timeout is hit the connection terminates.
One more thing you could try is to use native http handlers, that's new feature available in latest release. See https://developer.xamarin.com/releases/ios/xamarin.ios_9/xamarin.ios_9.8/#Selecting_the_Default_Handler
I think you need to get an iPhone with mobile network coverage to get to the bottom of this problem. There is another user on the forum experiencing the same issue. I need this to work on Android as well so I do not want an iOS specific solution.
This is not iOS specific solution, we have support for native handlers on Android as well
How do you know this will work, when you cannot replicate the fault I have reported? I think you have to replicate the scenario. Speak to the other person on the forum as he is having the exact same issue as me.
I am suggestion workaround which you can use before I somehow manage to reproduce the issue
Michel, do you continue to experience the issue?
Yes I am still experiencing the issue, event when using the native http client handler within Xamarin
@Alex I'll take over this bug.
Just to clarify, playing with the sample code I have the following results:
mvx:Diagnostic: 17.43 Completed last request
mvx:Diagnostic: 17.43 Completed first request
mvx:Diagnostic: 17.43 Completed second request
mvx:Diagnostic: 17.43 Test completed
mvx:Diagnostic: 17.18 Completed first request
mvx:Diagnostic: 17.18 Completed second request
mvx:Diagnostic: 17.18 Completed last request
mvx:Diagnostic: 17.18 Test completed
mvx:Diagnostic:199.43 Completed last request
mvx:Diagnostic:199.43 Completed second request
mvx:Diagnostic:199.43 Test completed
mvx:Diagnostic:199.43 Completed first request
So, AFAIK I can reproduce the issue with the managed version of the HttpClient. You mentioned that you do see the issue with the NSUrlSession and CFNetwork HttpClients, is this correct? Do my results look ok?
I'm not quite sure what these timings represent. The issue is how long it takes, so I would have to know when you started the request to know whether you are experiencing the same issue. Is it honouring the timeout set? or is it using the default timeout?
Can you clarify your last update?
@Michel my comment was that I was able to replicate the bug with at least the managed version of the HttpClient.
@Marek the way I replicated the issue was as simple as disabling my WiFi to force the timeout which is not honoured. I'll move this to BCL and reopen it.
Yes, I managed to replicate this with the Android and IOS managed version
@Michel I'm sure Marek will take a look, we will keep you posted.
I can reproduce the issue on device if I disable WiFi before launching the app
Sounds related to bugs #46792 and #45761
*** This bug has been marked as a duplicate of bug 46792 ***
Has this bug been fixed. If so what version of Xamarin is it in?
The latest alphas should have it for sure