Bug 24852 - ObjectDisposedException at System.Net.WebConnection.EndWrite when using Basic auth
Summary: ObjectDisposedException at System.Net.WebConnection.EndWrite when using Basic...
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web (show other bugs)
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-11-26 09:38 UTC by Tomek Romaniuk
Modified: 2014-11-26 09:40 UTC (History)
1 user (show)

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


Attachments
simple server with Basic auth (904 bytes, text/plain)
2014-11-26 09:38 UTC, Tomek Romaniuk
Details
steps to reproduce (2.57 KB, text/plain)
2014-11-26 09:40 UTC, Tomek Romaniuk
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 for Bug 24852 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Tomek Romaniuk 2014-11-26 09:38:08 UTC
Created attachment 8879 [details]
simple server with Basic auth

Overview:
Using HttpWebRequest to POST some data to a server from many threads with Basic authentication ends with System.ObjectDisposedException at System.Net.WebConnection.EndWrite.

Environment:
OS: Ubuntu 14.04, x64
Mono: 3.10.0 (tarball Wed Nov  5 12:50:04 UTC 2014)

Full stack trace:
System.AggregateException: One or more errors occurred ---> System.ObjectDisposedException: The object was used after being disposed.
  at System.Net.WebConnection.EndWrite (System.Net.HttpWebRequest request, Boolean throwOnError, IAsyncResult result) [0x00000] in <filename unknown>:0
  at System.Net.WebConnectionStream+<WriteRequestAsync>c__AnonStorey2.<>m__1 (IAsyncResult r) [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter`1[System.Net.WebResponse].GetResult () [0x00000] in <filename unknown>:0
  at SimpleServerClient.Program+<PostAsync>c__async0.MoveNext () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.Wait (Int32 millisecondsTimeout, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0
  at System.Threading.Tasks.Task.Wait () [0x00000] in <filename unknown>:0
  at SimpleServerClient.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
 --> (Inner exception 0) System.ObjectDisposedException: The object was used after being disposed.
  at System.Net.WebConnection.EndWrite (System.Net.HttpWebRequest request, Boolean throwOnError, IAsyncResult result) [0x00000] in <filename unknown>:0
  at System.Net.WebConnectionStream+<WriteRequestAsync>c__AnonStorey2.<>m__1 (IAsyncResult r) [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
  at System.Runtime.CompilerServices.TaskAwaiter`1[System.Net.WebResponse].GetResult () [0x00000] in <filename unknown>:0
  at SimpleServerClient.Program+<PostAsync>c__async0.MoveNext () [0x00000] in <filename unknown>:0


Steps to reproduce:
- Run simple_server.py (see attachments) or any HTTP server with Basic auth
- Run Client.cs (see attachments) to POST some data from many threads

Observations:
- Exception happens ~ 1 on 10 requests and only when using more then one thread so I suspect is related with concurrency.
- Can't be reproduced after setting request.PreAuthenticate = true;
- Can't be reproduced after disabling Basic authentication
Comment 1 Tomek Romaniuk 2014-11-26 09:40:48 UTC
Created attachment 8880 [details]
steps to reproduce