1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| services.AddSignalR(hubOptions => { hubOptions.EnableDetailedErrors = true; hubOptions.ClientTimeoutInterval= TimeSpan.FromMinutes(2); hubOptions.KeepAliveInterval = TimeSpan.FromMinutes(1); }) .AddMessagePackProtocol() .AddStackExchangeRedis(options => { options.Configuration.ChannelPrefix = signalRRedisOpt.Prefix; options.ConnectionFactory = async writer => { var config = new ConfigurationOptions { AbortOnConnectFail = false, ServiceName = signalRRedisOpt.ServiceName, AllowAdmin = true, DefaultDatabase = signalRRedisOpt.DefaultDb, Password = signalRRedisOpt.Password }; signalRRedisOpt.EndPoints.ForEach(o => config.EndPoints.Add(o)); var connection = await ConnectionMultiplexer.ConnectAsync(config, writer); connection.ConnectionFailed += (_, e) => { "Connection to Redis failed.".LogError(); };
if (!connection.IsConnected) { "Did not connect to Redis.".LogError(); } return connection; }; });
|