无法从控制台应用程序连接到Redis

时间:2019-12-13 09:16:31

标签: redis

我在可通过SSH隧道连接的单独环境中拥有Redis服务器。通过提供适当的服务器地址和密码,我可以使用Redis桌面管理器访问Redis服务器,但无法从控制台应用程序连接它。下面是我使用的代码

ConnectionMultiplexer _connection = 
ConnectionMultiplexer.Connect("some_address,password=redis,abortConnect=false");
IDatabase _cache = _connection.GetDatabase(); 
_cache.StringSet("TestKey", "TestValue");

尝试在Redis数据库中插入字符串值时出现以下错误。

StackExchange.Redis.RedisConnectionException
  HResult=0x80131500
  Message=No connection is available to service this operation: SET CHeckingTest; UnableToConnect on some_address:6379/Interactive, Initializing/NotStarted, last: NONE, origin: BeginConnectAsync, outstanding: 0, last-read: 5s ago, last-write: 5s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 0s ago, v: 2.0.601.3402; IOCP: (Busy=0,Free=1000,Min=4,Max=1000), WORKER: (Busy=0,Free=2047,Min=4,Max=2047), Local-CPU: n/a
  Source=StackExchange.Redis
  StackTrace:
   at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) in C:\projects\stackexchange-redis\src\StackExchange.Redis\ConnectionMultiplexer.cs:line 2237
   at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) in C:\projects\stackexchange-redis\src\StackExchange.Redis\RedisBase.cs:line 54
   at StackExchange.Redis.RedisDatabase.StringSet(RedisKey key, RedisValue value, Nullable`1 expiry, When when, CommandFlags flags) in C:\projects\stackexchange-redis\src\StackExchange.Redis\RedisDatabase.cs:line 2407
   at Redis_sample.Program.Main(String[] args) in C:\Users\Anish George\Desktop\Redis\CacheComponent\Redis_sample\Program.cs:line 66

Inner Exception 1:
RedisConnectionException: UnableToConnect on some_address:6379/Interactive, Initializing/NotStarted, last: NONE, origin: BeginConnectAsync, outstanding: 0, last-read: 5s ago, last-write: 5s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 0s ago, v: 2.0.601.3402

我应该给哪个密码?我有一个用于SSH隧道的密码和一个用于Redis服务器的密码,端口号也不同。如何通过控制台应用程序连接ot Redis?

1 个答案:

答案 0 :(得分:0)

您使用的端口6379通常用于不安全的流量,它可能在您的服务器上被阻止。尝试改用端口6380。