Redshift connection error

0

Getting `below error message while connecting to redshift(publicly accessible) via Lambda function

Response { "errorMessage": "2022-04-06T05:33:16.775Z cb4cdf56-fbd7-4a2e-a2fd-1ec52f5a2a93 Task timed out after 60.06 seconds" }`

asked 2 years ago223 views
1 Answer
0

Hi,

Lambda functions have many potential reasons for a "Task timed out" error, especially when configured to run in a VPC. Even though a Lambda function's maximum invocation timeout limit is 15 minutes, other AWS services may have different timeout limits.

By looking at the function's maximum value for the "Duration" metric at the time of the error, you can see that at least one invocation had a duration that reached the function's configured timeout value. When an invocation times out, an error metric will be recorded, but a Task timed out error message appears in the failed invocation's CloudWatch logs, not an Error message. To determine why your function was timing out, you will need to examine the Cloudwatch logs of the timed out invocations.

When your invocations generate requests to a downstream resource/API, make sure the libraries used by your function's code are configured to fail fast and retry. While AWS SDK's will automatically retry failed/timed out network requests, note that the default settings are usually higher than the ideal setting for the average Lambda function. For example, most Lambda functions are designed to run within a few seconds, but the default timeout value for a network request in AWS's Boto3 Python SDK is 60 seconds/attempt, and in Java, the default is 10 seconds/attempt . If you are still using the default settings, please modify those settings to a value that will allow your function to retry quickly.

If your function is creating new connections inside each invocation, note that re-using connections across invocations is a Lambda best practice. Connection re-use is possible because Lambda will use a single environment to run many invocations. This allows you to create network connections in the init section of your code, which can be used in the handler code for all invocations that run in that environment . Be aware that Lambda purges idle connections over time; when your function is re-using connections, attempting to reuse a purged connection will result in a connection error. To maintain a persistent connection from Lambda, use the keep-alive directive associated with your runtime.

References :-

https://aws.amazon.com/premiumsupport/knowledge-center/lambda-function-retry-timeout-sdk/ https://aws.amazon.com/premiumsupport/knowledge-center/lambda-vpc-troubleshoot-timeout/

Thank you !

AWS
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions