我只是想验证我的设置。它似乎有效,但我想和你们一起验证我的设置。
我在我的网站上托管了 SignalR。在我的 Startup.cs 我做:
public class Startup
{
public void Configuration(IAppBuilder app)
{
GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(110); //may be no longer needed because I've set KeepAlive?
GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(30);
GlobalHost.Configuration.KeepAlive = TimeSpan.FromSeconds(10);
// following setting is get from https://greenfinch.ie/2015/07/09/azure-licks-using-redis-cache-signalr/
var redisConnection = ConfigurationManager.ConnectionStrings["RedisCache"].ConnectionString;
// set up SignalR to use Redis, and specify an event key that will be used to identify the application in the cache
GlobalHost.DependencyResolver.UseRedis(new RedisScaleoutConfiguration(redisConnection, "MyEventKey"));
app.MapSignalR();
}
}
现在,我在我的其他 Web 服务中像这样使用它:
HubConnection hubConn = new HubConnection(url);
...
...
...
hubConn.CreateHubProxy("NotifyHub").On<string>("Notify", (msg) => PushToQueue(msg));
hubConn.Start();
这看起来对吗?这是否意味着 SignalR 连接超时为 10 秒(因为 KeepAlive 设置为 10 秒)?
这是我的使用图(假设网站和网络服务器有大量流量,Azure 需要为网站和网络服务器启动另一台计算机)
url: www.blablabla.com url: services.anotherweb.com
-------- ----------- ---------------
| User | --> Modify Data --> | Website | --> Trigger Web Service --> | Web Service |
-------- ----------- | ---------------
| ^
| |
| --------------------
| |
------|---------------------
| |
| |
| v
url: www.blablabla.com | url: services.anotherweb.com
-------- ----------- | ---------------
| User | --> Modify Data --> | Website | --> Trigger Web Service --> | Web Service |
-------- ----------- ---------------
对不起这个愚蠢的问题。今天刚刚发现了 redis,想用 SignalR 扩展我的网站。