2

I am making a lambda function for validations tokens in AWS Api Gateway. However, I need to connect with the redis with security, but ever fails with this config:

var client = require('redis').createClient({
      host : 'redis-dev.amazonaws.com',
      port : 6379,
      no_ready_check: true,
      auth_pass: 'mypassword#c$blx!Na'                                                                                                                                                    
});

Error:

{ "errorMessage": "2018-06-08T17:55:38.344Z 23a4f9da-6b45-11e8-abe5-6119b1378dff Task timed out after 5.01 seconds"}

Any can help me?

3
  • Is the Redis server in the same VPC as the Lambda function? Is the security group assigned to the Redis server configured to allow connections from the Lambda function? Commented Jun 8, 2018 at 19:36
  • security is with 0.0.0.0/0 allow all, external applications like spring, are able to connect, but in case of spring for example, in properties there are spring.redis.ssl=true and spring.redis.password="3455" Commented Jun 8, 2018 at 20:02
  • A timeout sounds like a network issue, not an authentication issue. You didn't fully answer my question, are the Lambda function and the Redis server in the same VPC? Commented Jun 8, 2018 at 20:34

2 Answers 2

1

The error message looks like lambda is running in a subnet/vpc which doesn’t have outbound access to the redis server. Try one of 2 options to find the root cause

1- try running the code from your local machine and check if you can connect to redis server.

2- remove vpc setting in the lambda to execute lambda outside vpc .

Sign up to request clarification or add additional context in comments.

Comments

1

As said by others VPC can be the issue, but there is another thing coming to mind.

Is this timeout a redis connection timeout or Lambda timeout ? Because, redis connections keeps the nodejs loop busy. And Lambda is by default waits for everything to clear up.

If so, try setting context.callbackWaitsForEmtpyEventLoop = false at the function handler. Or before the callback kill the redis connection.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.