StackExchange.Redis.RedisConnectionException
StackExchange.Redis.RedisConnectionException
我正在尝试将 Redis 用作将 JWT 列入黑名单的缓存,以实现使用 JWT 进行注销。
我已经在我的 windows 10 机器和 运行 "redis-server.exe"
上下载了 redis,它说:
[6112] 28 Nov 16:28:51.791 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.504 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 6112
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[6112] 28 Nov 16:28:51.798 # Server started, Redis version 3.0.504
[6112] 28 Nov 16:28:51.799 * DB loaded from disk: 0.001 seconds
[6112] 28 Nov 16:28:51.800 * The server is now ready to accept connections on port 6379
Redis 3.0.504 (00000000/0) 64 bit
Running in standalone mode
The server is now ready to accept connections on port 6379
这表明它工作正常。
我正在使用 .NetCore 3.1,并且安装了 Microsoft.Extensions.Caching.Redis
v2.2.0 Nuget 包。
在我的 startup.cs
我添加了
services.AddDistributedRedisCache(r =>
{
r.Configuration = Configuration["Redis:ConnectionString"];
});
在我的 appsettings.json
我有
"Redis": {
"ConnectionString": "localhsot"
}
但在我发送的任何请求中,我都收到以下异常:
StackExchange.Redis.RedisConnectionException: It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. SocketFailure on PING
at StackExchange.Redis.ConnectionMultiplexer.ConnectAsync(String configuration, TextWriter log) in c:\code\StackExchange.Redis\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 801
at Microsoft.Extensions.Caching.Redis.RedisCache.ConnectAsync(CancellationToken token)
at Microsoft.Extensions.Caching.Redis.RedisCache.GetAndRefreshAsync(String key, Boolean getData, CancellationToken token)
at Microsoft.Extensions.Caching.Redis.RedisCache.GetAsync(String key, CancellationToken token)
at Microsoft.Extensions.Caching.Distributed.DistributedCacheExtensions.GetStringAsync(IDistributedCache cache, String key, CancellationToken token)
我做错了什么?为什么我会得到这个例外??
顺便说一句,我在 cancelling JWTs
上关注本教程
我不敢相信我会这么说,但事实证明,导致这个让我发疯的异常的问题是在连接字符串中。
我输入的不是 "localhost"
,而是 "localhsot"
。一旦我修复它,一切都按预期工作。
我正在尝试将 Redis 用作将 JWT 列入黑名单的缓存,以实现使用 JWT 进行注销。
我已经在我的 windows 10 机器和 运行 "redis-server.exe"
上下载了 redis,它说:
[6112] 28 Nov 16:28:51.791 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.504 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 6112
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[6112] 28 Nov 16:28:51.798 # Server started, Redis version 3.0.504
[6112] 28 Nov 16:28:51.799 * DB loaded from disk: 0.001 seconds
[6112] 28 Nov 16:28:51.800 * The server is now ready to accept connections on port 6379
Redis 3.0.504 (00000000/0) 64 bit
Running in standalone mode
The server is now ready to accept connections on port 6379
这表明它工作正常。
我正在使用 .NetCore 3.1,并且安装了 Microsoft.Extensions.Caching.Redis
v2.2.0 Nuget 包。
在我的 startup.cs
我添加了
services.AddDistributedRedisCache(r =>
{
r.Configuration = Configuration["Redis:ConnectionString"];
});
在我的 appsettings.json
我有
"Redis": {
"ConnectionString": "localhsot"
}
但在我发送的任何请求中,我都收到以下异常:
StackExchange.Redis.RedisConnectionException: It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. SocketFailure on PING
at StackExchange.Redis.ConnectionMultiplexer.ConnectAsync(String configuration, TextWriter log) in c:\code\StackExchange.Redis\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 801
at Microsoft.Extensions.Caching.Redis.RedisCache.ConnectAsync(CancellationToken token)
at Microsoft.Extensions.Caching.Redis.RedisCache.GetAndRefreshAsync(String key, Boolean getData, CancellationToken token)
at Microsoft.Extensions.Caching.Redis.RedisCache.GetAsync(String key, CancellationToken token)
at Microsoft.Extensions.Caching.Distributed.DistributedCacheExtensions.GetStringAsync(IDistributedCache cache, String key, CancellationToken token)
我做错了什么?为什么我会得到这个例外?? 顺便说一句,我在 cancelling JWTs
上关注本教程我不敢相信我会这么说,但事实证明,导致这个让我发疯的异常的问题是在连接字符串中。
我输入的不是 "localhost"
,而是 "localhsot"
。一旦我修复它,一切都按预期工作。