我有两个完全不同的SignalR应用程序,但集线器名称相同。每个应用程序都部署到相同的两台服务器中(具有负载平衡)。我的架构如下所示
缓存应用程序:netscaler1-> server1,server2集线器名称:SignalRHub
交易应用程序:netscaler2-> server1,server2集线器名称:SignalRHub
缓存
namespace SignalR.Server.Cache
{
class Program
{
static void Main(string[] args)
{
var url = ConfigurationManager.AppSettings["cacheurl"];
using (WebApp.Start(url))
{
Console.ReadLine();
}
}
}
public class Startup
{
public void Configuration(IAppBuilder app)
{
HubConfiguration conf = new HubConfiguration();
GlobalHost.DependencyResolver.UseRedis("sameIp", 6379, "*******", "Cache");
app.UseCors(CorsOptions.AllowAll);
app.MapSignalR(conf);
}
}
}
namespace SignalR.Server.Cache
{
public class SignalRHub : Hub
{
public void SendCache(string cache)
{
Clients.All.OnMessage(cache);
}
}
}
交易
namespace SignalR.Server.Trade
{
class Program
{
static void Main(string[] args)
{
var url = ConfigurationManager.AppSettings["tradeurl"];
using (WebApp.Start(url))
{
Console.ReadLine();
}
}
}
public class Startup
{
public void Configuration(IAppBuilder app)
{
HubConfiguration conf = new HubConfiguration();
GlobalHost.DependencyResolver.UseRedis("sameIp", 6379, "*******", "Trade");
app.UseCors(CorsOptions.AllowAll);
app.MapSignalR(conf);
}
}
}
namespace SignalR.Server.Trade
{
public class SignalRHub : Hub
{
public void SendMessage(string message)
{
Clients.All.OnMessage(message);
}
}
}
我的问题:)