Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

amazon kinesis - 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. I've created a Kinesis client, but when I try to put records on Kinesis I get an error:

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:

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

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. Everything works fine for S3, it's just the Kinesis service that's giving me trouble. Has anyone seen anything like this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had a similar issue while connecting Kinesis over localstack locally. I was using the v2 SDK java library.

Root cause

By default, kinesalite doesn't support CBOR and should be disabled to make it run. Internet is flooded with flags to disable CBOR but none of them worked for me.

You have to do two things:

  1. Set environment var AWS_CBOR_DISABLE=true to tell localstack to stop using
  2. Set environment var aws.cborEnabled=false to tell AWS SDK to stop using it.

In my case, I was stuck with the SDK flag which is referred in software.amazon.awssdk.core.SdkSystemSetting


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...