首页 > 解决方案 > 有时使用发现端点时,由于 app_offline.htm 导致 IIS 中的 IdentityServer4 被回收

问题描述

根据 Windows 应用程序日志,由于 app_offline.htm 托管在 IIS 中的我的 IdentityServer 似乎被回收了。它似乎有时会在请求发现端点时发生,但我无法推断出它何时发生或不发生的任何明显模式。

事件描述为:

Application 'C:\Users\IP21Admin\Desktop\sts\' was recycled after detecting app_offline.htm.

IdentityServer 日志中的最后几个日志条目是:

[2021-01-14 17:01:32 DBG] IdentityServer4.Hosting.EndpointRouter
Request path /.well-known/openid-configuration/jwks matched to endpoint type Discovery

[2021-01-14 17:01:32 DBG] IdentityServer4.Hosting.EndpointRouter
Endpoint enabled: Discovery, successfully created handler: IdentityServer4.Endpoints.DiscoveryKeyEndpoint

[2021-01-14 17:01:32 INF] IdentityServer4.Hosting.IdentityServerMiddleware
Invoking IdentityServer endpoint: IdentityServer4.Endpoints.DiscoveryKeyEndpoint for /.well-known/openid-configuration/jwks

[2021-01-14 17:01:32 DBG] IdentityServer4.Endpoints.DiscoveryKeyEndpoint
Start key discovery request

我在这里发现了一个类似的问题,有人在他的 ASPNET 核心存储库中发布了一个问题: https ://github.com/dotnet/aspnetcore/issues/21528

我尝试使用进程监视器来查找 app_offline.htm 的来源,但每个条目都是 w2wp.exe 操作“CreateFile”,结果为“NAME NOT FOUND”。 过程监视器输出

我已经尝试手动放入我自己的 app_offline.htm 并且进程监视器将提供完全不同的操作,这让我怀疑之前实际上没有创建 app_offline.htm。也许 Windows 应用程序事件具有误导性,并且发生了某种崩溃?

有人对可能出现的问题有任何建议吗?

编辑:因此,进一步研究后,IIS 中的 IdentityServer4 实例似乎在从令牌端点成功发出授权代码令牌后被回收。我连接了远程调试,发现当应用程序被回收时,IIS Worker 的 CPU 使用率为 100%,并且应用程序的进程内存保持不变;不知道这是否有用的信息。

问题的症状是当我的客户端 GUI 应用程序的 OidcClient 在获取授权码令牌后继续从 UserInfo 端点获取 UserInfo 时;在 UserInfo 之前,由于“服务器已关闭”,它尝试加载发现文档失败。

也许 TokenEndpoint 会导致中间件卡住或导致回收?我假设服务器无法响应 DiscoveryEndpoint 请求,因为 TokenEndpoint 请求中(或之后)的某些东西导致服务器应用程序在它可以响应 DiscoveryEndpoint 请求之前被回收。

通过今天的尝试,日志现在结束于:

[2021-01-15 13:01:23 DBG] IdentityServer4.Endpoints.TokenEndpoint
Token request success.

[2021-01-15 13:01:23 VRB] IdentityServer4.Hosting.IdentityServerMiddleware
Invoking result: IdentityServer4.Endpoints.Results.TokenResult

标签: iisidentityserver4.net-5asp.net5

解决方案


原来的问题是,如果目录中的任何文件发生更改,IIS 会自动回收应用程序。我在请求期间写入的文件夹中有一些日志文件和 SQLite 文件。


推荐阅读