question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Owin.OpenIdConnect deadlock at cold start with IIS

See original GitHub issue

We 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

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Tratchercommented, Aug 7, 2018

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

0reactions
Tratchercommented, Nov 22, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found