4

I've got an AWS Lambda function I've written in Java (well, it's actually written in Clojure) and it appears to get invoked 3 times every time I run it.

My function runs successfully and well within the timeout (which is set to the max of 5 minutes). It returns a string which I can see output when I test the function in the console.

I've seen some stuff online about having to call some Context success / done function but can't see that in the Java SDK (seems to be for Node only?).

Am I missing something?

This does not occur when I click test in the console (it only runs once) but does happen when triggered via a CloudWatch Trigger or running via the AWS SDK.

Thanks,

Donovan

Update: apologies, this does not happen when running via the trigger, only via the SDK and CLI, so perhaps there is some timeout in the call I am making.

1 Answer 1

10

For future reference for anyone else, the issue was the SDK and CLI hitting the read timeout of one minute and then retrying the request. I manually set this to 5 minutes to match my AWS Lambda timeout.

This can be done in the CLI by adding --cli-read-timeout int where int is your desired timeout (or simply --cli-read-timeout 0 which disables the timeout altogether).

In the Java SDK it can be done by calling setSocketTimeout(int socketTimeout) on the ClientConfiguration object

In Clojure using Amazonica, add :client-config {:socket-timeout xxx} to your credentials map.

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

2 Comments

I solved this with invokeRequest.setSdkRequestTimeout(180001); invokeRequest.setSdkClientExecutionTimeout(180001);
I was hoping the SDK would be smart enough to assume the timeout of the service it was connected to, so for lambda, if my timeout is 5 minutes, the SDK should adapt. Unfortunately not the case...lost many hours on this, but super thankful for this answer.

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.