【问题标题】:Java CompletionException: software.amazon.awssdk.core.exception.SdkClientException: Acquire operation took longer than the configured maximum timeJava CompletionException:software.amazon.awssdk.core.exception.SdkClientException:获取操作花费的时间超过配置的最长时间
【发布时间】:2023-02-07 21:40:54
【问题描述】:

尝试调用 aws lambda 函数但出现以下错误:

java.util.concurrent.CompletionException: software.amazon.awssdk.core.exception.SdkClientException: Unable to execute HTTP request: Acquire operation took longer than the configured maximum time. This indicates that a request cannot get a connection from the pool within the specified maximum time. This can be due to high request rate.
Consider taking any of the following actions to mitigate the issue: increase max connections, increase acquire timeout, or slowing the request rate.

在调用 lambda 函数的 aws sdk v2 java 中使用 awsasyncclient

LambdaAsyncClient client = LambdaAsyncClient.builder().region(region_lambda).build();

如何增加最大连接数或增加空闲时间?这里可以做什么?

【问题讨论】:

  • 请提供足够的代码,以便其他人可以更好地理解或重现问题。

标签: java amazon-web-services aws-lambda


【解决方案1】:

您需要通过从 LambdaAsyncClient 调用 httpClient 来创建自定义 HTTP。然后您所要做的就是添加您的自定义设置,如连接超时获取(您还可以添加其他自定义设置以增加吞吐量,例如最大并发数、最大连接数)。

在这里查看:Interface NettyNioAsyncHttpClient.Builder

做这个

NettyNioAsyncHttpClient.Builder customHttp = NettyNioAsyncHttpClient.builder()
.connectionAcquisitionTimeout(Duration.ofMillies(20000);

LambdaAsyncClient lambdaAsyncClient = LambdaAsyncClient.builder()
.region(region_lambda)
.httpClientBuilder(customHttp)
.build();

如果这不能解决问题,请检查您是否没有使 lambda 超载 客户在这么短的时间内有多个请求

另外,导入 netty-nio-client 依赖

implementation "software.amazon.awssdk:netty-nio-client" 

【讨论】:

    猜你喜欢
    • 2016-04-22
    • 2016-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多