MVC5 hangs on MapSignalR when reconnecting after AppPool cycles

后端 未结 3 457
情书的邮戳
情书的邮戳 2021-01-04 04:44

I have the following code in my Startup.SignalR.cs:

using Microsoft.AspNet.SignalR;
using Owin;
using System;
using System.Collections.Generic;
using System.         


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-04 05:37

    I found the solution here: github.com/SignalR/SignalR/issues/3414 Snip sample:

    public void Configuration(IAppBuilder app)
    {
        var task = Task.Run(() => app.MapSignalR());
        task.Wait(300);
        //try again if it fails just to be sure ;)
        if (task.IsCanceled) Task.Run(() => app.MapSignalR()).Wait(300);
    }
    

提交回复
热议问题