redis.clients.jedis.exceptions.JedisConnectionException:java.net.ConnectException超时错误

时间:2017-04-05 23:02:45

标签: java amazon-web-services amazon-ec2 redis jedis

我正在尝试连接到驻留在远程AWS实例中的redis数据库,但是当我尝试使用jedis.hgetAll(key)时,我得到了带有超时的JedisConnectionException。我能够检索jedis对象。 以下是代码:

public static void main(String[] args){
  String key = "flower";
  Jedis jedis = new Jedis("54.191.60.144", 6379);
  Map<String, String> retrieveMap = jedis.hgetAll(key);
}

我能够显示如下的jedis对象:redis.clients.jedis.Jedis@14fc0eaa

以下是错误:

redis.clients.jedis.exceptions.JedisConnectionException:java.net.ConnectException: Connection timed out (Connection timed out)
    at redis.clients.jedis.Connection.connect(Connection.java:124)
    at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:54)
    at redis.clients.jedis.Connection.sendCommand(Connection.java:77)
    at redis.clients.jedis.BinaryClient.hgetAll(BinaryClient.java:247)
    at redis.clients.jedis.Client.hgetAll(Client.java:189)
    at redis.clients.jedis.Jedis.hgetAll(Jedis.java:860)
    at com.main.programs.AverageRedisRetrieval.main(AverageRedisRetrieval.java:44)

如果有人能够向我提出决议,我将感激不尽。我能够使用localhost redis连接使代码工作。

0 个答案:

没有答案