0

I'm not sure what's causing this to not work. Everytime the code hits the initialization of the client, it stop working Is using Redisson not viable in a Lambda setup?

Main code for initializing redisson client:

public boolean itemExistInCache(String item) {
    Config config = new Config();
    config.useSingleServer().setAddress("127.0.0.1:6379");

    // this one is not working
    RedissonClient redissonClient = Redisson.create(config);
}

Setup

  • The Lambda containing the code above is triggered everytime there is a message registered in the SQS. The SQS message is subscribed to an SNS Topic.

  • SNS + SQS setup is created/initialized with localstack

  • Lambda runs with aws sam local (pip3 install --user aws-sam-cli)

What I've tried and working so far

  • using Jedis jedis = new Jedis() //using the same redis "localhost: 6379"
gzz
  • 655
  • 5
  • 18

1 Answers1

1

If you intend on running this code in a 'real' lambda (vs sam-local) you will need to run the lambda within a VPC, in which case it will have no external networking unless you setup a NAT or similar in your VPC.
If in sam-local your using 127.0.0.1 -- are you sure your 'lambda' running in sam-local is not in a network cgroup (such as running in docker - if in docker its likely that 'localhost' is not where redis lives ) ? This question/problem is almost certainly an issue about network connectivity and port mapping within sam-local. You can validate this by trying something other then reddison to try to connect to the endpoint to see if it connects at all -- a URL.openStream() should at least connect enough to give an error. (redis is not HTTP so it wont 'work' but it will connect vs hang -- hangs are almost always related to IP or Port isolation)

DALDEI
  • 3,722
  • 13
  • 9