Bug 5945 - Response timeout on HttpWebRequest with chunked encoding & https
Summary: Response timeout on HttpWebRequest with chunked encoding & https
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.2
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Martin Baulig
Depends on:
Reported: 2012-07-02 11:11 UTC by Robin
Modified: 2013-12-05 18:36 UTC (History)
3 users (show)

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

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 Developer Community or GitHub 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:

Description Robin 2012-07-02 11:11:52 UTC
We're sometimes getting a timeout on a HttpWebRequest response. Some data is received, but not all, resulting in an exception in WebConnectionStream.Read()
The request is over SSL and the response is using chunked transfer encoding. Bypassing one of these 2 (i.e. chunked over http or non-chunked over https) solves the problem for this specific instance. As we only have this problem with a very few requests, there is no way to be certain that this solves the actual problem or only circumvents our only reproducible case.
However, I might have found a cause in WebConnection.BeginRead() and was wondering if anyone can confirm this:

Here is a (simplified) part of WebConnection.BeginRead():
1. if (!chunkedRead || (!chunkStream.DataAvailable && chunkStream.WantMore)) {
2. result = nstream.BeginRead (buffer, offset, size, cb, state);
3. cb = null;
4. }
6. if (chunkedRead) {
7. WebAsyncResult wr = new WebAsyncResult (cb, state, buffer, offset, size);
8. wr.InnerAsyncResult = result;
9. ...
10. return wr;
11. }

When chunkStream has only read a part of a chunk, then the 2nd part of line 1 will be true. However, line 2 directly reads from the HttpsClientStream to the buffer. And so, bypassing data which is still in the chunkedStream.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-07-02 12:16:50 UTC
Gonzalo, this looks related to bug #3876
Comment 2 Martin Baulig 2013-06-26 07:15:11 UTC
Are you still having this problem?  This looks like a duplicate of #5904, which has recently been fixed.
Comment 3 PJ 2013-11-19 17:05:44 UTC
This bug has been in the NEEDINFO state with no changes for the last 90 days. Can we put this back into the NEW or CONFIRMED state, or are we still awaiting response?

If there is no change in the status of this bug over the next two weeks, this bug will be marked as NORESPONSE.
Comment 4 PJ 2013-12-05 18:36:11 UTC
This bug has not been changed from the NEEDINFO state since my previous comment, marking as RESOLVED NORESPONSE.

Please feel free to REOPEN this bug at any time if you are still experiencing the issue. Please add the requested information and set the bug back to the NEW (or CONFIRMED) state.