简体   繁体   English

从 Java 使用 LocalStack 时获取 AmazonKinesisException 状态代码:502

[英]Getting an AmazonKinesisException Status Code: 502 when using LocalStack from Java

I'm writing integration tests using LocalStack to mock out my calls to Kinesis.我正在使用 LocalStack 编写集成测试来模拟我对 Kinesis 的调用。 I've created a Kinesis client, but when I try to put records on Kinesis I get an error:我创建了一个 Kinesis 客户端,但是当我尝试在 Kinesis 上放置记录时出现错误:

com.amazonaws.services.kinesis.model.AmazonKinesisException: null (Service: AmazonKinesis; Status Code: 502; Error Code: null; Request ID: null)

I've tried disabling CBOR and cert checking with the following:我尝试使用以下方法禁用 CBOR 和证书检查:

System.setProperty(SDKGlobalConfiguration.DISABLE_CERT_CHECKING_SYSTEM_PROPERTY, "false");

System.setProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true"); System.setProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");

I build the client this way:我以这种方式构建客户端:

.withEndpointConfiguration(localstack.getEndpointConfiguration(LocalStackContainer.Service.KINESIS))
.withCredentials(localstack.getDefaultCredentialsProvider())
.build()

I get a 502 every time.我每次都收到502。 Everything works fine for S3, it's just the Kinesis service that's giving me trouble. S3 一切正常,只是 Kinesis 服务给我带来了麻烦。 Has anyone seen anything like this?有没有人见过这样的事情?

I had a similar issue while connecting Kinesis over localstack locally.我在本地通过 localstack 连接 Kinesis 时遇到了类似的问题。 I was using the v2 SDK java library.我正在使用 v2 SDK java 库。

Root cause根本原因

By default, kinesalite doesn't support CBOR and should be disabled to make it run.默认情况下,kinesalite 不支持 CBOR,应该禁用它以使其运行。 Internet is flooded with flags to disable CBOR but none of them worked for me.互联网上充斥着禁用 CBOR 的标志,但没有一个对我有用。

You have to do two things:你必须做两件事:

  1. Set environment var AWS_CBOR_DISABLE=true to tell localstack to stop using设置环境AWS_CBOR_DISABLE=true以告诉localstack停止使用
  2. Set environment var aws.cborEnabled=false to tell AWS SDK to stop using it.设置环境aws.cborEnabled=false以告诉AWS 开发工具包停止使用它。

In my case, I was stuck with the SDK flag which is referred in software.amazon.awssdk.core.SdkSystemSetting就我而言,我坚持使用software.amazon.awssdk.core.SdkSystemSetting引用的 SDK 标志

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 localstack 运行 SQS 测试时出现 502 - 502 when running SQS test using localstack 从 Docker 连接到本地主机(Java 应用程序使用 mocking AWS 的 localstack) - Connecting to localhost from Docker (Java Application using localstack for mocking AWS) 获取 java.io.IOException:服务器返回 HTTP 响应代码:URL 的 400:使用返回 400 状态代码的 url 时 - Getting java.io.IOException: Server returned HTTP response code: 400 for URL: when using a url which return 400 status code Java代码,用于使用套接字连接获取多个IP,端口的状态 - Java code for getting the status of multiple IP,Port using socket connection 为什么我的Java服务器代码在尝试从Stripe接收Webhook时抛出502错误? - Why is my Java server code throwing a 502 error when attempting to receive a webhook from stripe? “DynamoDbException:请求了一个未知的操作。” 使用 LocalStack docker 容器、Java testcontainers 时的问题 - “DynamoDbException: An unknown operation was requested.” problem when using LocalStack docker container, Java testcontainers 获取 Java 代码的声纳问题“返回值包含操作状态代码时不应被忽略” - Sonar Issue "Return values should not be ignored when they contain the operation status code" getting for Java code Java Lambda 中的 Reddison 客户端不工作(使用 samLocal 和 localstack) - Not working Reddison client in Java Lambda(using samLocal and localstack) 从Volley获取标题和状态代码? - Getting headers and status-code from Volley? 如何尝试从Java客户端使用Sharepoint的Rest API,但获取状态码403禁止 - HowTrying to consume Rest api of Sharepoint from java client but getting status code 403 Forbidden
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM