有没有办法检测signaR集线器是否无法连接到给定的背板(SQL或REDIS)。例如,给定连接字符串错误或无法访问背板服务器?
这是我的简化启动类:
public class Startup
{
public void Configuration(IAppBuilder app)
{
var backplaneType = ConfigurationManager.AppSettings["SignalR.BackplaneType"];
if (backplaneType == "SQL")
{
var connectionString = ConfigurationManager.ConnectionStrings["SignalR.SQL"].ConnectionString;
var sqlScaleoutConfig = new SqlScaleoutConfiguration(connectionString);
GlobalHost.DependencyResolver.UseSqlServer(sqlScaleoutConfig);
}
else if(backplaneType == "Redis")
{
var connectionString = ConfigurationManager.ConnectionStrings["SignalR.Redis"].ConnectionString;
var config = new RedisScaleoutConfiguration(connectionString, "SomeKey");
GlobalHost.DependencyResolver.UseRedis(config);
}
app.MapSignalR();
}
}
这样我们就可以记录任何错误,并在我们的APM软件中记录它。