带有ResthighlevelClient的春季本地人未连接到AWS OpenSearch
我在“ Amazon Linux 2 上”上的“ 自定义运行时”上配置了lambda并运行。 graalvm 是我们应用程序使用的运行时。
当Lambda试图与OpenSearch建立联系时,它总是会导致“ Java.net.sockettemeoutexception:60,000毫秒的连接http-ttp-Instr-to-to-0 [active] [active] 。
以下是我们的应用中使用的一些关键点:
- lambda和openSearch均在同一VPC
- 安全组中配置为允许所有入站和出站流量(目前)
- 我们使用Elasticsearch的“ ResthighLevelClient”库来使 连接
- 与OpenSearch Lambda的权限
具有完整的OpenSearch访问权限。 以下是ResthighLevelClient配置:
public class OpenSearchConfig extends AbstractElasticsearchConfiguration {
@Value("${aws.es.endpoint:defaultEndpoint}")
private String endpoint;
@Override
public RestHighLevelClient elasticsearchClient() {
return new RestHighLevelClient(RestClient.builder(HttpHost.create(endpoint)));
}
}
note :当我们使用'Java 11(Corretto)作为运行时,lambda到OpenSearch连接的工作正常。由于我们在Lambda面临着冷启动问题,因此我们计划使用Graalvm(由Spring Anitial支持),以更快地启动,最终进入此障碍。将插座连接超时增加到任何限制也无济于事。
任何建议都非常感谢。提前致谢。
I have a Lambda configured and running on "Custom runtime on Amazon Linux 2". GraalVM is the runtime used for our application.
When Lambda tries to make a connection with OpenSearch, it always results in "java.net.SocketTimeoutException: 60,000 milliseconds timeout on connection http-outgoing-0 [ACTIVE]".
Below are some key points used in our app:
- Both Lambda and OpenSearch are in same VPC
- Security groups are configured to allow all inbound and outbound traffic (for now)
- We use Elasticsearch's 'RestHighLevelClient' library to make a connection with OpenSearch
- Lambda's permissions has full OpenSearch Access.
Below is RestHighLevelClient Configuration:
public class OpenSearchConfig extends AbstractElasticsearchConfiguration {
@Value("${aws.es.endpoint:defaultEndpoint}")
private String endpoint;
@Override
public RestHighLevelClient elasticsearchClient() {
return new RestHighLevelClient(RestClient.builder(HttpHost.create(endpoint)));
}
}
Note: The Lambda to OpenSearch connection was working fine when we used 'Java 11 (Corretto)' as Runtime. Since we were facing cold start issues in Lambda, we planned to use GraalVM (supported by Spring Native) for faster start up and ended up in this road block. Increasing the socket connection timeout to any limit is not helping either.
Any suggestions is much appreciated. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来 Spring 的魔力与 GraalVM 不太兼容。我修改了如下配置,效果很好。
上面我已将 RestHighLevelClient 显式标记为 bean 并创建了 ElasticsearchOperations 实例,如下所示:
希望这对某人有帮助。
It seems Spring's magic isn't much compatible with GraalVM. I have modified the configurations as below and it worked fine.
Above I have marked RestHighLevelClient as a bean explicitly and created the ElasticsearchOperations instance as below:
Hope this helps someone.