SignalR Scaleout with Redis - 无SSL支持

时间:2015-01-06 16:24:42

标签: c# asp.net azure signalr

我已将nuget软件包 Microsoft.AspNet.SignalR.Redis 添加到我的项目中,以允许我按照以下说明使用redis缓存背板扩展我的signalR应用程序:

http://www.asp.net/signalr/overview/performance/scaleout-with-redis

我在Azure上设置了一个redis缓存服务器,使用与端口6379的非安全连接,一切正常。

我现在想要启用SSL以增加安全性,但似乎没有使用nuget插件支持SSL连接:

如果我尝试使用安全端口6380,nuget包似乎不支持SSL连接。

示例:

GlobalHost.DependencyResolver.UseRedis("redis-server.cloudapp.net", 6380,
"Password/Key", "ChatApp")

这些不是启用SSL的开关

以下是连接的完整代码:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {

        // Configuration for scale out using Redis:
        var redisEnabled = Convert.ToBoolean(WebConfigurationManager.AppSettings["RedisScaleOut_Enable"]);
        if (redisEnabled)
        {
            var redisHost = WebConfigurationManager.AppSettings["RedisScaleOut_Host"];
            var redisPort = Convert.ToInt16(WebConfigurationManager.AppSettings["RedisScaleOut_Port"]);
            var redisPassword = WebConfigurationManager.AppSettings["RedisScaleOut_Password"];
            var redisAppName = WebConfigurationManager.AppSettings["RedisScaleOut_AppName"];

            GlobalHost.DependencyResolver.UseRedis(redisHost, redisPort, redisPassword, redisAppName);
        }

        // Branch the pipeline here for requests that start with "/signalr"
        app.Map("/signalr", map =>
        {
            // Setup the CORS middleware to run before SignalR.
            // By default this will allow all origins. You can 
            // configure the set of origins and/or http verbs by
            // providing a cors options with a different policy.
            map.UseCors(CorsOptions.AllowAll);

            var hubConfiguration = new HubConfiguration
            {
                // You can enable JSONP by uncommenting line below.
                // JSONP requests are insecure but some older browsers (and some
                // versions of IE) require JSONP to work cross domain
                EnableJSONP = true
            };

            // Run the SignalR pipeline. We're not using MapSignalR
            // since this branch already runs under the "/signalr"
            // path.
            map.RunSignalR(hubConfiguration);
        });

    }
}

2 个答案:

答案 0 :(得分:1)

SignalR Redis背板目前正在使用Booksleeve,我可以看到here他们使用裸套接字连接到Redis。我不认识Redis,但我认为通信不是基于HTTP而只是TCP,所以你不能直接使用SSL。

答案 1 :(得分:1)

最新版本的SignalR(目前为2.2.1)允许使用SSL,如下所示:

var connectionString = "myredis.redis.cache.windows.net:6380,password=myPassword,ssl=True,abortConnect=False";

GlobalHost.DependencyResolver.UseRedis(new RedisScaleoutConfiguration(connectionString, "YourServer"));

感谢Michael Parshin的回答:https://stackoverflow.com/a/29591328/648738