简体   繁体   English

连接被拒绝 - 用于 ASP.Net Core 2.1 中的数据保护密钥的 Redis

[英]Connection Refused - Redis for Data Protection Keys in ASP.Net Core 2.1

I'm going through this article from Microsoft: https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/implementation/key-storage-providers?view=aspnetcore-2.1我正在阅读 Microsoft 的这篇文章: https : //docs.microsoft.com/en-us/aspnet/core/security/data-protection/implementation/key-storage-providers?view=aspnetcore-2.1

I am trying to do the following:我正在尝试执行以下操作:

    services.AddDataProtection()
        .PersistKeysToRedis(ConnectionMultiplexer.Connect("localhost"));

Error Stack:错误堆栈:

app    | Unhandled Exception: System.AggregateException: One or more errors occurred. (Connection refused) ---> System.Net.Sockets.SocketException: Connection refused
app    |    at System.Net.Sockets.Socket.BeginConnectEx(EndPoint remoteEP, Boolean flowContext, AsyncCallback callback, Object state)
app    |    at System.Net.Sockets.Socket.UnsafeBeginConnect(EndPoint remoteEP, AsyncCallback callback, Object state, Boolean flowContext)
app    |    at System.Net.Sockets.Socket.PostOneBeginConnect(MultipleAddressConnectAsyncResult context)
app    | --- End of stack trace from previous location where exception was thrown ---
app    |    at System.Net.Sockets.Socket.DoMultipleAddressConnectCallback(Object result, MultipleAddressConnectAsyncResult context)
app    |    at System.Net.Sockets.Socket.DoDnsCallback(IAsyncResult result, MultipleAddressConnectAsyncResult context)
app    |    at System.Net.Sockets.Socket.BeginConnect(String host, Int32 port, AsyncCallback requestCallback, Object state)
app    |    at System.Net.Sockets.Socket.ConnectAsync(String host, Int32 port)
app    |    at System.Net.Sockets.SocketTaskExtensions.ConnectAsync(Socket socket, String host, Int32 port)
app    |    at StackExchange.Redis.SocketManager.BeginConnect(EndPoint endpoint, ISocketCallback callback, ConnectionMultiplexer multiplexer, TextWriter log) in c:\code\StackExchange.Redis\StackExchange.Redis\StackExchange\Redis\SocketManager.cs:line 194

I am using Docker:我正在使用 Docker:

redis:
    image: redis:alpine
    container_name: redis
    ports:
      - "6379:6379"

Any ideas?有任何想法吗?

You need to reference the container and port您需要引用容器和端口

services.AddDataProtection()
        .PersistKeysToRedis(ConnectionMultiplexer.Connect("redis:6379"));

I also added abortConnect=false" to configuration我还在配置中添加了 abortConnect=false"

REDIS_CONNECTION_STRING = "redis:6379,abortConnect=false"


var redis = ConnectionMultiplexer.Connect(Environment.GetEnvironmentVariable("REDIS_CONNECTION_STRING"));
services.AddDataProtection().PersistKeysToRedis(redis, "DataProtection-Keys");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.NET Core OpenIdConnectServer数据保护密钥位置 - ASP.NET Core OpenIdConnectServer data protection keys location ASP.NET Core 2.1 中的数据保护仅适用于一台机器 - Data protection in ASP.NET Core 2.1 only works on one machine ASP.Net Core 2.1上的Azure移动后端连接问题 - Azure Mobile Backend connection issue on ASP.Net Core 2.1 Plesk Linux ASP.NET Core ERR_CONNECTION_REFUSED - Plesk Linux ASP.NET Core ERR_CONNECTION_REFUSED 是否可以禁用 ASP.NET Core 中的数据保护加密? - Is it possible to disable the data protection encryption in ASP.NET Core? 群集环境中的ASP.Net核心数据保护API - ASP.Net Core Data Protection API in a Clustered Environment 更改 ASP.NET 中的证书指纹 Core Data Protection API - Changing the Certificate Thumbprint in ASP.NET Core Data Protection API ASP.NET core 2.2 web api 记录与数据保护密钥相关的警告:我们应该如何处理这个问题? - ASP.NET core 2.2 web api logs warnings related to data protection keys: how should we handle this issue? 生成数据注释不适用于 asp.net core 2.1 中的 xml - Produces data annotation not working for xml in asp.net core 2.1 将 asp.net MachineKey 迁移到 asp.net 核心数据保护 - Migrating asp.net MachineKey to asp.net Core Data Protection
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM