Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.
Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.
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.
I am using Xamarin.iOS 6.3.7.164 and facing a very strange behaviour with timing out requests sent with HttpClient(): The following code tries to get a result from an url that does not exist respectively isn't available (simulating a server outage): private async void Connect() { var httpClient = new System.Net.Http.HttpClient { BaseAddress = new Uri("http://192.168.179.33/fooapi/"), Timeout = TimeSpan.FromSeconds(3) }; Console.WriteLine("Timeout is set to: " + httpClient.Timeout); Console.WriteLine("Start: " + DateTime.Now); var start = DateTime.Now; try { await httpClient.GetAsync("foo"); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Finished: " + DateTime.Now); Console.WriteLine("Duration: " + (DateTime.Now - start).TotalSeconds); } I expected to see a result after 3 seconds, or at least after 15 seconds (http://msdn.microsoft.com/en-us/library/system.net.http.httpclient.timeout.aspx). But what I get is a task running for 75 seconds: 2013-07-12 00:06:21.134 XamariniOSHttpClientConnectionTimeout[50422:c07] Timeout is set to: 00:00:03 2013-07-12 00:06:21.146 XamariniOSHttpClientConnectionTimeout[50422:c07] Start: 12.07.2013 00:06:21 2013-07-12 00:07:36.613 XamariniOSHttpClientConnectionTimeout[50422:c07] Error: Error: ConnectFailure (Connection timed out) 2013-07-12 00:07:36.614 XamariniOSHttpClientConnectionTimeout[50422:c07] Finished: 12.07.2013 00:07:36 2013-07-12 00:07:36.617 XamariniOSHttpClientConnectionTimeout[50422:c07] Duration: 75,468696 It is reproduceable on multiple machines. See a failing test attached.
Fixed in master & 3-2 branch
*** Bug 13331 has been marked as a duplicate of this bug. ***
(In reply to comment #2) > *** Bug 13331 has been marked as a duplicate of this bug. *** I tried this test case. It works for that url in the test case. However, when I replace the url with the image url in Bug 13331, the timeout does not work. Here the the code and output: async Task Connect() { HttpResponseMessage response = null; var httpClient = new System.Net.Http.HttpClient { BaseAddress = new Uri("http://photojournal.jpl.nasa.gov/jpeg/PIA15416.jpg"), Timeout = TimeSpan.FromSeconds(3) }; Console.WriteLine("Timeout is set to: " + httpClient.Timeout); Console.WriteLine("Start: " + DateTime.Now); var start = DateTime.Now; try { response = await httpClient.GetAsync(""); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Finished: " + DateTime.Now); Console.WriteLine("Duration: " + (DateTime.Now - start).TotalSeconds); } Output: 2013-07-22 15:20:12.672 GetAsyncTestcase[50981:c07] Timeout is set to: 00:00:03 2013-07-22 15:20:12.686 GetAsyncTestcase[50981:c07] Start: 7/22/2013 3:20:12 PM 2013-07-22 15:20:19.948 GetAsyncTestcase[50981:c07] Finished: 7/22/2013 3:20:19 PM 2013-07-22 15:20:19.950 GetAsyncTestcase[50981:c07] Duration: 7.261929
Works as expected for me
I am sorry to say that, but that bug occurs again in the same way as described here. Interestingly not by calling DeleteAsync() but by calling the other methods (PostAsync() for example). Could you please check that again. I am currently on 6.4.5.0.
I'm experiencing the exact same. I've tested all *Async() methods: GetAsync/PostAsync/PutAsync/DeleteAsync/SendAsync, and all of them are ignoring the timeout setting. I've set the timeout to 3 seconds and included a sleep of 10secs in my php script. All requests times are at least 10 secs, so the 3 secs is ignored. I've tried connecting to a DNS name and an IPaddress, both act the same.
forgot to add my version info. I'm using an Android project. Xamarin Studio: Version 4.0.12 (build 3) Xamarin.Android: Version: 4.8.1 (Indie Edition)
OK, it was not really working but it should be fixed in master now. It should make into next round of alphas.
What version should this fix be in?
This will for sure be in 7.0.4, possibly in the 7.0.3 which is currently in alpha.
The bug is back again (currently using the Beta channel). The timeout seemed to be ignored again. The only timeout setting that worked for me was 600ms (and less), 700ms and above was totally ignored. Xamarin Studio: version 4.2.4 (build32) Xamarin.iOS: Version: 7.2.0.2
Confirmed, I am seeing this, too (7.2.0.2). And I think it has never (!) been fixed.
Works as expected with 7.2.1 Timeout is set to: 00:00:03 Start: 3/21/2014 9:59:57 PM Error: The Task was canceled Finished: 3/21/2014 10:00:00 PM Duration: 3.122437
I'm afraid I'm seeing this exact problem also - timeout is ignored and 75 seconds is used instead. Xamarin Studio 5.0 b878 Xamarin.iOS 7.2.3.39
I see 75 seconds, too. Particularly, when I am testing on a device that is configured to connect through a proxy on WIFI, but I am attempting connection through LTE network. We discovered this during testing of offline features, and since we test through a proxy on a wifi, if we turn off wifi on the device, it can no longer connection to our server, but the phone has a valid connection through the cell network. In other words, our test server is only reachable through the wifi. Here's a valid test scenario: Configure app to connect to proxy that is not reachable outside of your internal network (but can be reached on your wifi) Then turn off your wifi and attempt to connect through the proxy. HttpClient will take a little over 75 seconds to throw a WebException.
I'm using: Xamarin Studio Version 5.5.3 (build 6) Xamarin.iOS Version: 8.4.0.16
I see this behavior as well with Xamarin Forms 1.2.3.6257 on Android
It would be great if Xamarin staff could at least respond to this ticket!
Original test case retested with Xamarin.iOS 8.2 and Xamarin.Android 4.17 and both work as expected. Provide actual test case which is failing or detailed steps how to reproduce it. If different setup is involved than this ticket it's better to fill different bug report.
I was able to replicate Jonathan's issue which I have submitted as a separate bug. https://bugzilla.xamarin.com/show_bug.cgi?id=24704
It's not solved yet. I'm having this issue with Xamarin.Forms 1.2.3.6257 on Android.
Ditto this issue still exists today, taking 75 secs to timeout rather than the 5 I have set it to.
Still exists, magic 75 secs to timeout. Note XS 5.7 Android 4.4 (19) ModernHTTPClient -> OkHTTP XForms 1.3.2.6316
Still exists... And causing lots of trouble. Why is this being ignored by Xamarin?
It's actually fixed in mono. That's where the bug actually exists. See this bug: https://bugzilla.xamarin.com/show_bug.cgi?id=24704
When is this mono fix going to make it into Xamarin? I still experience the 75 sec timeout on Xamarin Forms 1.4.0.6341, although I set the timeout to 8 sec. In most cases the 8 sec is respected, but when the timeout is at the socket level, it's 75 sec: 2015-01-29 10:19:59.742 skillstore[958:185552] 7 ERROR Skillstore.AppLogic.Rest.Request: ExecuteAsync - WebException from POST http://192.168.1.192:9000/api/v1/auth/token, retry count = 1: System.Net.WebException: Error: ConnectFailure (Connection timed out) ---> System.Net.Sockets.SocketException: Connection timed out at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x000f1] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.6.0.51/src/mono/mcs/class/System/System.Net.Sockets/Socket_2_1.cs:1257 at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x001c2] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.6.0.51/src/mono/mcs/class/System/System.Net/WebConnection.cs:213 I am NOT using a proxy.
Hellow, please take a look at this: https://forums.xamarin.com/discussion/52007/ios-device-crash-with-system-net-httpclient-operation-was-closed-was-canceled-a-task-was-canceled?new=1
This bug still exists and its a blocker to our progress. I'm really getting frustrated.
We had the same problem with a library we were using. The library was trying to provide Async support. We're not using Async so we made this change. We changed this return request.EndGetRequestStream(request.BeginGetRequestStream(null, null)); to return request.GetRequestStream(); And it started working. But we also found this comment in HttpWebRequest.Timeout Property https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.timeout%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396 The Timeout property has no effect on asynchronous requests made with the BeginGetResponse or BeginGetRequestStream method
This bug still exists! Xamarin 4.0.4.4 (a9c7826) Xamarin.Android 6.0.4.0 (ee215fc)