尝试连接Redis(ElastiCache)时,在线程“ ClientThread 1” org.redisson.client.RedisConnectionException中获取异常

时间:2018-08-13 14:55:24

标签: java amazon-web-services redis

我已经在AWS上创建了Redis(ElastiCache),并且尝试使用以下代码进行连接:-

Config config = new Config();       
config.useClusterServers().addNodeAddress("redis://XXXXXX.cache.amazonaws.com:6379");
RedissonClient redisson = Redisson.create(config);

当我在包含上述代码的实例上运行jar时,出现以下错误:-

    Exception in thread "ClientThread 1" org.redisson.client.RedisConnectionException: Unable to connect to Redis server: /127.0.0.1:6379
        at org.redisson.connection.pool.ConnectionPool$2$1.operationComplete(ConnectionPool.java:137)
        at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:507)
        at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:481)
        at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:420)
        at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:122)
        at org.redisson.misc.RedissonPromise.tryFailure(RedissonPromise.java:83)
        at org.redisson.connection.pool.ConnectionPool.promiseFailure(ConnectionPool.java:306)
        at org.redisson.connection.pool.ConnectionPool.access$400(ConnectionPool.java:53)
        at org.redisson.connection.pool.ConnectionPool$4.operationComplete(ConnectionPool.java:276)
        at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:507)
        at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:500)
        at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:479)
        at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:420)
        at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:122)
        at org.redisson.misc.RedissonPromise.tryFailure(RedissonPromise.java:83)
        at org.redisson.client.RedisClient$2$1$2.run(RedisClient.java:225)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
        at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138)
        at java.lang.Thread.run(Thread.java:745)
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /127.0.0.1:6379
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
        at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:323)
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:633)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
        ... 3 more
Caused by: java.net.ConnectException: Connection refused
        ... 11 more

注意:-我可以使用Redis-cli从实例成功连接到Redis(ElastiCache)。

0 个答案:

没有答案