オンプレミスOrchestratorのIdentity ServerでUiPath.IdentityServer.Web.Middleware.ExceptionHandlingMiddleware One or more errors occurredが発生する

Question/Problem
オンプレミスOrchestrator v24.10の Identityが以下のエラーコードで断続的に失敗します:

UiPath.IdentityServer.Web.Middleware.ExceptionHandlingMiddleware One or more errors occurred. (A task was canceled.) TaskCanceledException A task was canceled.

HTTP500エラーのためにOrchestrator管理画面にアクセスできなくなりますが、IIS再起動で一時的に解消します。

Error
UiPath.IdentityServer.Web.Middleware.ExceptionHandlingMiddleware One or more errors occurred. (A task was canceled.) TaskCanceledException A task was canceled.

Root Cause
起動時にアプリがデータベースへ同期的にアクセスしており、その処理がスレッドをブロックしてデッドロック(スレッド枯渇)を引き起こしています。
その結果、初期化処理が完了せずタイムアウトして TaskCanceledException が発生しています。

Resolution
SAML を appsettings ファイルで設定することで、デッドロックを引き起こしているデータベース呼び出しをバイパスできるようになります。

■設定手順
1.Identity のインストールフォルダ(C:\Program Files (x86)\UiPath\Orchestrator\Identity)に移動します

2.Identity フォルダ内に以下のコードを使用して Saml2Web.config ファイルを作成します

<configuration>
   <configSections>
   <section name="sustainsys.saml2" type="Sustainsys.Saml2.Configuration.SustainsysSaml2Section, Sustainsys.Saml2" />
   </configSections>
   <sustainsys.saml2
  entityId="https://localhost:44351/identity/"
  returnUrl="http://localhost:6234/Account/ExternalLoginCallback" >
     <identityProviders></identityProviders>
   </sustainsys.saml2>
</configuration>

3.現在の appsettings.Production.json ファイルのバックアップを取り、Appsettings セクションの直前に以下の行を追加します(下記のスクリーンショットを参照):

"Authentication": {
  "Saml2": {
    "ConfigFile": "Saml2Web.config"
  }
},

image-20260130-063053.png

4.管理者権限コマンドプロンプトにて iisreset コマンドを実行し、IISを再起動して設定変更を適用します。

■切り戻し手順
万が一動作不良があった場合には次の手順で切り戻しを行います。

1.バックアップした appsettings.Production.json を C:\Program Files (x86)\UiPath\Orchestrator\Identity に上書きコピーします。

2.C:\Program Files (x86)\UiPath\Orchestrator\Identity\Saml2Web.config を削除します。

3.管理者権限コマンドプロンプトにて iisreset コマンドを実行し、IISを再起動します。