Change Global Settings Config in SignalR Core

天大地大妈咪最大 提交于 2019-12-01 05:26:56

There's a Transports property in SignalROptions
You can setup the SignalR middleware like this :

services.AddSignalR(options => {
                options.Hubs.EnableDetailedErrors = true;
                var transports = options.Transports;
                transports.DisconnectTimeout = TimeSpan.FromSeconds(30);
                transports.KeepAlive = TimeSpan.FromSeconds(10);
                transports.TransportConnectTimeout = TimeSpan.FromSeconds(110);
            });

UPDATE alpha2-final

Transport options can be configured throught MapHub:

app.UseSignalR(configure =>
{
    configure.MapHub<Hub>("hub", options => 
    {
        options.Transports = TransportType.All;
        options.LongPolling.PollTimeout = TimeSpan.FromSeconds(10);
        options.WebSockets.CloseTimeout = TimeSpan.FromSeconds(10);
    });
})

and on client side:

let logger: ILogger;
let transportType: TransportType;
const hubConnetion = new HubConnection(
  new HttpConnection(
      url,
      { 
        transport: transportType,
        logging: logger
      }));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!