0

See here: AWS Documentation

The connection timeout is the amount of time (in milliseconds) that the HTTP connection will wait to establish a connection before giving up. The default is 50,000 ms. To set this value yourself, use the ClientConfiguration.setConnectionTimeout method.

I am trying to set the value myself, using:

ClientConfiguration configuration = new ClientConfiguration();
configuration.setConnectionTimeout(1900000);
configuration.setSocketTimeout(1900000);

Problem is, I am trying to update this value FROM WITHIN an AWS Lambda Java function. If I am calling an external lambda function, I can configure this before I make the call. This is what all of the documentation is showing examples of.

Is there a way I can add an environment variable or programmatically update the current AWS Lambda Java function connection and socket timeout from within itself?

Further clarification:

There is not a "client" invoking this lambda function. It is intended to be scheduled on the hour, triggered by the event type "CloudWatch Events - Schedule." The lambda itself places a request for one GET call that can take anywhere from 65 seconds to 140 seconds to run. The overall lambda time is currently extended to 5 minutes. The lambda's GET call fails right at the 50 second mark. The provided AWS documentation above references a default 50 second limit, with 3 retry attempts, both of which supposedly can be modified. However, I have been unable to modify the connection or socket timeout programmatically from the lambda's own code, or any parameter on the lambda itself. There has to be a way to configure this properly.

To an external service, over HTTPS. I fed it proxy settings and I verified the connection was correct and that it was the right call. In Postman, it takes 65+ seconds for any input or limit.

Please advise.

7
  • 2
    I think we need to clarify your scenario. Let's say I am running the client and you are providing the lambda function... are you wanting your lambda function to modify my client's timeout waiting for it to finish? If so, that is impossible for several different reasons... so you might want to explain what problem you are actually trying to solve (rather than how you are currently wanting to solve it), and perhaps we can find a solution or at least clarify why this isn't possible. Otherwise, if you are looking for a different scenario, please clarify. Commented Feb 24, 2018 at 18:51
  • There is not a "client" invoking this lambda function. It is intended to be scheduled on the hour, triggered by the event type "CloudWatch Events - Schedule." The lambda itself places a request for one GET call that can take anywhere from 65 seconds to 140 seconds to run. The overall lambda time is currently extended to 5 minutes. The lambda's GET call fails right at the 50 second mark. Commented Feb 26, 2018 at 5:35
  • The provided AWS documentation above references a default 50 second limit, with 3 retry attempts, both of which supposedly can be modified. However, I have been unable to modify the connection or socket timeout programmatically from the lambda's own code, or any parameter on the lambda itself. There has to be a way to configure this properly. I added this section to the post body to help others understand at first read. Commented Feb 26, 2018 at 5:36
  • Okay, so... CloudWatch Lambda invocations are asynchronous, so it's not the caller's timeout that's giving you issues (which I initially thought you were trying to modify, and which wouldn't make sense, because the caller's connection is to the Lambda API, not to your function directly -- the caller here is CloudWatch). The 50 seconds discussed here is the timeout when you make requests with the SDK from your (Lambda) code. Are you making your long-running GET request to an AWS service, or to an external service? Commented Feb 26, 2018 at 5:51
  • To an external service, over HTTPS. I fed it proxy settings and I verified the connection was correct and that it was the right call. In Postman, it takes 65+ seconds for any input or limit. Commented Feb 26, 2018 at 16:55

1 Answer 1

1

I found the issue. It turns out the lambda was successful from the AWS console. It was only failing in Eclipse. The AWS Toolkit containing the AWS SDK gave this error:

com.amazonaws.SdkClientException: Unable to execute HTTP request: Read timed out

I made the code and AWS console changes described above, and it did not work. What it was a setting in the AWS Toolkit > Preferences as shown here:

AWS Toolkit Preferences

Timeout configurations

The above Timeouts were both set to 20000s, limiting the HTTPS calls I was making as described above. I updated this value comically high to test it, now it resolves in about 93s. The same call in that time period from Postman is also 93s.

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

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.