aws / aws-sdk-java

The official AWS SDK for Java 1.x. The AWS SDK for Java 2.x is available here: https://github.com/aws/aws-sdk-java-v2/
https://aws.amazon.com/sdkforjava
Apache License 2.0
4.13k stars 2.83k forks source link

AWSIotClient: unable to unmarshall exception #2126

Closed steven-aerts closed 4 years ago

steven-aerts commented 5 years ago

Hi,

last Tuesday, a lambda which calls both register- as updateCertificate gave some errors we have not seen before:

com.amazonaws.AmazonServiceException: Unable to unmarshall exception response with the unmarshallers provided (Service: AWSIot; Status Code: 503; Error Code: null; Request ID: 175bc636-c11f-454e-ae67-2a49c3985f17)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1712 )
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1367 )
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1113 )
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:770 )
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:744 )
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:726 )
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:686 )
    at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:668 )
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:532 )
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:512 )
    at com.amazonaws.services.iot.AWSIotClient.doInvoke(AWSIotClient.java:10871 )
    at com.amazonaws.services.iot.AWSIotClient.invoke(AWSIotClient.java:10838 )
    at com.amazonaws.services.iot.AWSIotClient.invoke(AWSIotClient.java:10827 )
    at com.amazonaws.services.iot.AWSIotClient.executeRegisterCertificate(AWSIotClient.java:8532 )
    at com.amazonaws.services.iot.AWSIotClient.registerCertificate(AWSIotClient.java:8504 )

Looking in the source code of the AWS Java SDK and googling around on the internet tells us that the AWSIotClient is not able to unmarshal the error returned by the AWS IoT API.

Is this correct/expected behaviour? How are we expected to handle these kind of exceptions? We would expect something more descriptive most likely of the AWSIotException type then AmazonServiceException. We also have the impression that the SDK does not retry this kind of effects.

AWS SDK version used 1.11.560.

Thanks,

Steven

debora-ito commented 5 years ago

Hi @steven-aerts based on the status code 503 - Service Unavailable - this is probably an issue on the service side. Are you seeing these errors consistently or were they transient?

The "Unable to unmarshall exception" message is being shown because the error code is missing from the response (Error Code: null), I will contact the IoT Team and ask about it.

steven-aerts commented 5 years ago

Hi @debora-ito the errors were transient (happened during 2 seconds on all calls to the update- and createCertificate endpoints).

The reason we opened this ticket is that we think the SDK couild react better as:

debora-ito commented 4 years ago

Picking this up after a very long pause, sorry about that @steven-aerts.

5xx errors are hard to reproduce, so I cannot confirm if it's being retried or not. Are you still seeing the issue, even if intermittently?

steven-aerts commented 4 years ago

Hi @debora-ito ,

we have seen this still a few times. But we are retrying. Our main concern at the time was that the SDK is not throwing an AWSIotException nor is it retrying.

Steven

debora-ito commented 4 years ago

So, besides the IoT team not sending the error code in the 503 exception, is there anything else pending from the SDK team?

steven-aerts commented 4 years ago

We would expect the error to be handled differently by the SDK.

Instead of throwing a non-documented AmazonServiceException, throw a generic AWSIotException or even better retry the request (as it is unknown and 5xx).

Steven

debora-ito commented 4 years ago

You said in the previous comment the the error was being retried, I'm confused.

github-actions[bot] commented 4 years ago

It looks like this issue hasn’t been active in longer than a week. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please add a comment to prevent automatic closure, or if the issue is already closed please feel free to reopen it.