aws / aws-sdk-java

The official AWS SDK for Java 1.x (In Maintenance Mode, End-of-Life on 12/31/2025). 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

Unsupported or unrecognized SSL message(short issue description) #3071

Closed keenuser closed 10 months ago

keenuser commented 11 months ago

Describe the bug

I am using AWS Java SDK (aws-java-sdk-api-gateway-1.12.268) for fetching stages from an AWS API. The code works fine for most of the APIs, except it failed 2-3 times consecutively for a particular API with following exception:

com.amazonaws.SdkClientException: Unable to execute HTTP request: Unsupported or unrecognized SSL message at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1219) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1165) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:814) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:781) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:755) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:715) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:697) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:561) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:541) ~[Execute.zip:?] at com.amazonaws.services.apigateway.AmazonApiGatewayClient.doInvoke(AmazonApiGatewayClient.java:8246) ~[Execute.zip:?] at com.amazonaws.services.apigateway.AmazonApiGatewayClient.invoke(AmazonApiGatewayClient.java:8213) ~[Execute.zip:?] at com.amazonaws.services.apigateway.AmazonApiGatewayClient.invoke(AmazonApiGatewayClient.java:8202) ~[Execute.zip:?] at com.amazonaws.services.apigateway.AmazonApiGatewayClient.executeGetStages(AmazonApiGatewayClient.java:5310) ~[Execute.zip:?] at com.amazonaws.services.apigateway.AmazonApiGatewayClient.getStages(AmazonApiGatewayClient.java:5279) ~[Execute.zip:?]

I talked to AWS support for API service and he checked from CloudFront etc. that stage was available at the time a request was made to API endpoint. So, it's not a problem with service. I suspect it's an intermittent issue (same code work fine for other APIs, in same/other accounts as well).

What could be the reason behind this problem? Is this categorized as retriable error?

Expected Behavior

The AWS Java SDK should consistently work while fetching API properties like stages etc.

Current Behavior

Getting following exception while fetching stages from an AWS API using java SDK (aws-java-sdk-api-gateway-1.12.268):

com.amazonaws.SdkClientException: Unable to execute HTTP request: Unsupported or unrecognized SSL message at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1219) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1165) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:814) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:781) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:755) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:715) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:697) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:561) ~[Execute.zip:?] at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:541) ~[Execute.zip:?] at com.amazonaws.services.apigateway.AmazonApiGatewayClient.doInvoke(AmazonApiGatewayClient.java:8246) ~[Execute.zip:?] at com.amazonaws.services.apigateway.AmazonApiGatewayClient.invoke(AmazonApiGatewayClient.java:8213) ~[Execute.zip:?] at com.amazonaws.services.apigateway.AmazonApiGatewayClient.invoke(AmazonApiGatewayClient.java:8202) ~[Execute.zip:?] at com.amazonaws.services.apigateway.AmazonApiGatewayClient.executeGetStages(AmazonApiGatewayClient.java:5310) ~[Execute.zip:?] at com.amazonaws.services.apigateway.AmazonApiGatewayClient.getStages(AmazonApiGatewayClient.java:5279) ~[Execute.zip:?]

Reproduction Steps

The sample code is attached: GetStage.java.txt

Possible Solution

  1. Update AWS SDK

Additional Information/Context

No response

AWS Java SDK version used

aws-java-sdk-api-gateway-1.12.268

JDK version used

JDK 17

Operating System and version

EC2 with Windows Server 2019

debora-ito commented 10 months ago

"Unsupported or unrecognized SSL message" indicates that the wrong protocol was used to make the connection, for example if you try to connect with SSL but you specify a port that is not SSL.

I see in the GetStage class that you're using a proxy in the ApiGateway client, I would double-check your proxy settings. You can also check the SSL handshake logs for more clues.

keenuser commented 10 months ago

The issue got resolved after rectifying the proxy configuration. Thanks for the pointer.