Owin.OpenIdConnect deadlock at cold start with IIS
See original GitHub issueWe have some project, running on IIS. After cold start, sometimes we have deadlock, caused by method:
private static void OnSendingHeaderCallback(object state)
{
AuthenticationHandler handler = (AuthenticationHandler)state;
handler.ApplyResponseAsync().Wait();
}
We can’t do OpenIdConnect redirect and application freezes. Fixed only by iisreset
DotTrace show this
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
OWIN IIS host deadlock
I've opted-in to use OWIN IIS host for some concrete project and I got stuck in a deadlock when I want to send...
Read more >The OWIN OpenID Connect Middleware
The function of Startup is to initialize the OWIN pipeline by having its Configure method automatically invoked at initialization.
Read more >Untitled
OpenIdConnect deadlock at cold start with IIS #220 - GitHub Name already in use - GitHub SpletMicrosoft.Owin.Security.ActiveDirectory.WsFedMetadataRetriever.
Read more >OWIN Startup Class Detection
This tutorial shows how to configure which OWIN startup class is loaded. For more information on OWIN, see An Overview of Project Katana....
Read more >OWIN Middleware in the IIS integrated pipeline
This article shows how to run OWIN middleware Components (OMCs) in the IIS integrated pipeline, and how to set the pipeline event an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Related: https://github.com/aspnet/AspNetKatana/issues/51
For this to hang ApplyResponseAsync must actually go async. Most of the time it will complete sync, but at startup it needs to fetch the metadata document. https://github.com/aspnet/AspNetKatana/blob/e2b18ec84ceab7ffa29d80d89429c9988ab40144/src/Microsoft.Owin.Security.OpenIdConnect/OpenidConnectAuthenticationHandler.cs#L138
Possible workaround: Initialize and invoke OpenIdConnectOptions.ConfigurationManager at Startup to fetch the metadata before the first request (or load the metadata statically). See https://github.com/aspnet/AspNetKatana/blob/e2b18ec84ceab7ffa29d80d89429c9988ab40144/src/Microsoft.Owin.Security.OpenIdConnect/OpenIdConnectAuthenticationMiddleware.cs#L70-L102
Reading that closer, there’s no way for _config to become null after the constructor. If RetrieveMetadata threw in the constructor the entire object never would have been created.