Bug 44027 - Chunked HTTP PUT times out
Summary: Chunked HTTP PUT times out
Status: VERIFIED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Net.Http ()
Version: 4.4.2 (C7SR1)
Hardware: Macintosh Mac OS
: --- major
Target Milestone: 15.4
Assignee: Martin Baulig
URL:
Depends on:
Blocks:
 
Reported: 2016-09-06 16:58 UTC by lzhi
Modified: 2017-09-07 13:06 UTC (History)
5 users (show)

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


Attachments
wireshark trace of the request (230.23 KB, text/plain)
2017-07-17 18:36 UTC, Mikayla Hutchinson [MSFT]
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:
VERIFIED FIXED

Description lzhi 2016-09-06 16:58:46 UTC
issue: https://github.com/NuGet/Home/issues/3251

NuGet Push doesn't work on Mac because HttpClient doesn't send payload to server.

I created a TestApp (https://github.com/zhili1208/monoPushIssue/)which only call HttpClient API for pushing package, it still failed on customer's machine.

Since there is no nuget logic in my test app, we think the issue might be a mono bug.
Comment 1 Sam 2016-09-27 14:24:36 UTC
Also seeing this on my machine, version info: https://gist.github.com/SamuelDebruyn/6e807c6bc1aeb077a01c9b36ffe26366
Comment 2 Mikayla Hutchinson [MSFT] 2017-07-12 22:08:50 UTC
This is still broken using Mono 5.4.0.73 and NuGet 4.3 which ships with it.

mikayla@neptune:~/code/MonoDevelop.AddinMaker$ nuget push MonoDevelop.Addins.Tasks/bin/Release/MonoDevelop.Addins.0.3.18.nupkg
Pushing MonoDevelop.Addins.0.3.18.nupkg to 'https://www.nuget.org/api/v2/package'...
  PUT https://www.nuget.org/api/v2/package/
An error was encountered when fetching 'PUT https://www.nuget.org/api/v2/package/'. The request will now be retried.
An error occurred while sending the request
  Error getting response stream (ReadDone1): ReceiveFailure
  Unable to read data from the transport connection: Connection reset by peer.
  Connection reset by peer
  PUT https://www.nuget.org/api/v2/package/
An error was encountered when fetching 'PUT https://www.nuget.org/api/v2/package/'. The request will now be retried.
An error occurred while sending the request
  Error getting response stream (ReadDone1): ReceiveFailure
  Unable to read data from the transport connection: Connection reset by peer.
  Connection reset by peer
  PUT https://www.nuget.org/api/v2/package/
A task was canceled.
  Pushing took too long. You can change the default timeout of 300 seconds by using the -Timeout <seconds> option with the push command.
Comment 3 Mikayla Hutchinson [MSFT] 2017-07-13 18:42:14 UTC
Quick note to anyone repro'ing this, you now need to add another header:

request.Headers.Add("X-NuGet-Client-Version", "4.3.0");
Comment 4 Mikayla Hutchinson [MSFT] 2017-07-14 18:12:50 UTC
If I run the sample under Xamarin.Mac, which uses NSUrlSession to handle HttpClient, the sample works. The problem is specific to HttpWebRequest.
Comment 5 Mikayla Hutchinson [MSFT] 2017-07-14 18:51:22 UTC
Here is a test case that isolates it to HttpWebRequest:

https://gist.github.com/mhutch/3ca189807c95167856638b35621cc715
Comment 6 Mikayla Hutchinson [MSFT] 2017-07-17 18:36:19 UTC
Created attachment 23606 [details]
wireshark trace of the request

It exhibits the timeout even when using HTTP, which causes the server to return HTTP 400.

On receipt of an error like this, the chunked request should abort. However, it continues sending regardless.

It's possible to work around this by disabling chunking.
Comment 7 Mikayla Hutchinson [MSFT] 2017-07-17 18:37:38 UTC
Note that just fixing the abort won't fix the underlying error. It also times out when using HTTPS with a valid API key and package.
Comment 8 Mikayla Hutchinson [MSFT] 2017-07-17 18:38:33 UTC
See also https://bugzilla.xamarin.com/show_bug.cgi?id=52579
Comment 9 Martin Baulig 2017-07-17 22:58:49 UTC
This should fix the 'nuget push' issue (when using nuget.exe)
https://github.com/mono/mono/pull/5226

Mikayla's test case is a little bit of a special snowflake.  It explicitly sets the content length, requests chunked encoding and doesn't close the request stream.

I have fixed this in my work branch for the new web stack.  Back-porting into master might be a little bit tricky.
Comment 10 Martin Baulig 2017-07-17 23:00:22 UTC
Tricky because there is some magic in the code which assumes that the content length is only set when we're not using chunked encoding.  I've cleaned that up in the new web stack, but we need to be careful when back-porting.
Comment 12 Martin Baulig 2017-07-18 22:01:48 UTC
Fixed.