Bug 25755 - HttpClient.Timeout does not throw ArgumentOutOfRangeException when setting Timeout property to 0
Summary: HttpClient.Timeout does not throw ArgumentOutOfRangeException when setting Ti...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Net.Http (show other bugs)
Version: master
Hardware: PC Windows
: Normal normal
Target Milestone: Future Release
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2015-01-06 16:33 UTC by nader
Modified: 2017-09-29 21:53 UTC (History)
10 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Simple application demonstrating the bug (85.21 KB, application/octet-stream)
2015-01-09 14:12 UTC, nader
Details
Xamarin Log (5.34 KB, application/zip)
2015-01-09 14:19 UTC, nader
Details


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.

Related Links:
Status:
RESOLVED FIXED

Description nader 2015-01-06 16:33:29 UTC
I have run the following code snippet as a Xamarin PCL code that targets .NET4.5, Android, Windows phone 8.1(profile 111).

System.Net.Http.HttpClient v0 =  new System.Net.Http.HttpClient();
System.TimeSpan v2 = new System.TimeSpan(0, 0, 0);
((System.Net.Http.HttpClient)v0).Timeout = (System.TimeSpan)v2 ;

The expected result after executing the 3rd line should be an ArgumentOutOfRangeException since the timeout property is being set to 0 (based on MSDN documentation http://msdn.microsoft.com/en-us/library/system.net.http.httpclient.timeout%28v=vs.110%29.aspx). This expected behavior occurs when the program is run for Windows phone 8.1 and .NET4.5.

However, when this code snippet is ran for Android, No exception is thrown. Which is not the expected behavior and differs from the Windows phone 8.1 and .NET4.5 versions.

I've ran this on Visual Studio 2013 with the following Xamarin version:
Xamarin.Android
Version: 4.16.0 (Business Edition)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39

The test was conducted on an Android 4.0.3 emulator
Comment 1 Sadik Ali 2015-01-09 07:11:47 UTC
I have checked this issue but I am unable to reproduce this issue.

To reproduce this behavior I have created a portable library project and added the following code in PCL project

>System.Net.Http.HttpClient v0 =  new System.Net.Http.HttpClient();
>System.TimeSpan v2 = new System.TimeSpan(0, 0, 0);
>((System.Net.Http.HttpClient)v0).Timeout = (System.TimeSpan)v2 ;

I have also added a android project to the same solution and call the PCL code from android project. I observed that I am not getting any error/exception. Application is working fine.

I have also tried the same with Xamarin.Forms app and forms application is also working fine.

Could you please provide sample application,build info and logs (IDE + debug)? So that we can reproduce this behavior at our end.

You can get build info from here:
Microsoft Visual Studio => Help => About Microsoft Visual studio => Copy Info

You can get IDE logs from here:
Microsoft Visual Studio => Help => Zip Xamarin Logs (attach the zipped logs)

Environment Info:

Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Professional

LightSwitch for Visual Studio 2013   06177-004-0444002-02320
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013   06177-004-0444002-02320
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06177-004-0444002-02320
Microsoft Visual Basic 2013

Visual C# 2013   06177-004-0444002-02320
Microsoft Visual C# 2013

Visual C++ 2013   06177-004-0444002-02320
Microsoft Visual C++ 2013

Visual F# 2013   06177-004-0444002-02320
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06177-004-0444002-02320
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06177-004-0444002-02320
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools   12.4.51016.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Websites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.21010.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.3
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Azure Mobile Services Tools   1.3
Microsoft Azure Mobile Services Tools

NuGet Package Manager   2.8.50926.663
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU   12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PowerShell Tools   1.3
Provides file classification services using PowerShell

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   12.0.41012.0
Microsoft SQL Server Data Tools

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   3.8.150.0 (10cfd178d55287f09c85f5a1e604dfe20889a40f)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   4.20.0.28 (ba9bbbdd44cfdc4bf485e8885bd2ad24fba525f7)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   8.4.0.0 (840a925103a0bf4a856507f13d5eaee3c1579c2f)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 2 nader 2015-01-09 14:12:41 UTC
Created attachment 9306 [details]
Simple application demonstrating the bug

The attached solution includes 3 projects. 
1) PCL code project with the bug code.
2) Android project calling the PCL code
3) Windows phone project calling the PCL code
Comment 3 nader 2015-01-09 14:19:52 UTC
Created attachment 9307 [details]
Xamarin Log
Comment 4 Michael 2016-01-20 12:16:45 UTC
I am having a timeout issue with Profile 111 building an iOS app. No matter what value I set the timeout to be it does not honour it and uses the default timeout. What is the current state of this bug? Is it getting worked on?
Comment 5 Timothy Risi 2017-09-26 17:51:42 UTC
It throws the ArgumentOutOfRangeException for values less than 0, but "works" for 0.  Per https://msdn.microsoft.com/en-us/library/system.net.http.httpclient.timeout(v=vs.110).aspx, the exception should be thrown for values less than or equal to 0, not just less than 0.
Comment 6 Marek Safar 2017-09-29 21:53:26 UTC
Fixed in master