问题
I'm having a self hosted SignalR 2.2.0 server and using OWIN for the configuration.
[assembly: OwinStartup(typeof(Server.Communication.StartUp))]
namespace Server.Communication
{
public class StartUp
{
public void Configuration(IAppBuilder app)
{
app.Map("/Communication", map =>
{
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration { EnableDetailedErrors = true};
map.RunSignalR(hubConfiguration);
});
}
}
}
Im starting the server via
WebApp.Start($"http://{ip}:{port}");
And in my Hub
I've overridden the method
public override Task OnDisconnected(bool stopCalled)
Everything works fine and the OnDisconnected
method is called if I let my client crash via windows task explorer to simulate a crash. But the OnDisconnected
method is called a bit late. There are at least 30 seconds till the method is called. I want to set this time to 10 seconds.
I tried setting KeepAlive
and ConnectionTimeout
before i call the WebApp.Start
method but it did not change anything.
GlobalHost.Configuration.ConnectionTimeout = new TimeSpan(0, 0, 10);
GlobalHost.Configuration.KeepAlive = new TimeSpan(0, 0, 2);
来源:https://stackoverflow.com/questions/44389293/signalr-ondisconnected-is-called-too-late