-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception System.InvalidOperationException in HttpListener.EndGetContext #107025
Comments
Tagging subscribers to this area: @dotnet/ncl |
Neither Using a |
DisconnectResults is used in 5 places. 2 of them had already the 'lock ((DisconnectResults as ICollection).SyncRoot)' pattern so therefor I opted to add locking to the other 3 places. Without fixing this bug HttpListener is unstable and cannot be used in a production environment. |
Even with the fix, it's still hard to be considered stable. |
We have 2 application that are using HttpListener one is 10+ old and the other 5+. Changing them to ASP.NET is a lot of work. HttpListener is originally a C# wrapper around http.sys (windows kernel drive, iis core). We are using it >10 years with Framework without a glitch. Because it is uses http.sys it has a lot of advantages like Integrated Windows Authentication, Port sharing and easy to use in a windows service. |
I don't see the fix v8.0.11 or V9.0.0. What do I need to do t get this fix also in v8 and v9? |
The fix was merged after 9.0 snapping, and was not backported yet. You need to request a backport here. Usually you would be asked for reasons like usage, difficulty of workaround etc. @dotnet/ncl |
The only workaround is build dotnet rumtime from source with the patch :-( Backport is extremely easy just a sherry pick of the commit. |
I don't see any response? |
@dotnet/ncl for backport request. |
How? Because of the '/' I can not tag '@dotnet/ncl' |
Internal teams are only visible to organization members. It's end-of-year holiday season now so the response may be not timely. |
Thanks @huoyaoyuan for help here! Given it is a regression in migration without reasonable workaround, I don't mind backporting it. |
Backporting to 9 has been initiated in #110695 |
We have 2 NT services that we recently update from Framework to .NET 8. We use HttpListener for admin access to the services. Mostly for status overviews.
ASP.NET is more a framework than a simple (API) webserver. I have read that Kestrel can be used without ASP.NET in .NET 8. But it is harder in .NET 9 because of a reference from Kestrel to ASP.NET. I don’t know if Microsoft.AspNetCore.Server.HttpSys can be used without ASP.NET. If you do not handle and log every unexpected exception, chances are you will miss these errors. As a result, application crashes or instabilities. I fear that the majority ignores these types of problems and only a small minority is willing and able to search for the cause and report the problem. .NET 9 is release 1 month a go. That is to new for use. When 9.0.1/2 is released we will probable update to .NET 9. |
Description
After updating the application from Framework to .Net 8 we occasionally get the following exceptions:
After further investigation in the System.Net.HttpListener sourecode I found that the Dictionary DisconnectResults is not always used in a thread safe manner. It is missing lock around the access of DisconnectResults
Reproduction Steps
It is hard to reproduce. It happens randomly
Expected behavior
No exception
Actual behavior
Exceptions and possible internal corruption of HttpListener
Regression?
No response
Known Workarounds
I have fixed version of HttpListener (see patch). If this fix is stable for 1 week I will submit a pull request.
HttpListener-fix-Operations-that-change-non-concurre.patch
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: