Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 811
Melvin Avatar asked Oct 22 '25 14:10

Melvin


1 Answers

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

like image 130
Rites Avatar answered Oct 24 '25 07:10

Rites



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!