edit-icon download-icon

Errors and troubleshooting

Last Updated: Mar 20, 2018

The following are some common errors you may experience when using Alibaba Cloud Java SDK. Potential causes and resolutions are shown for these commonly experienced errors.

SDK.CanNotResolveEndpoint

Error message: Can not resolve endpoint, please check the user guide

Cause:

The SDK cannot automatically obtain the endpoint of the called product in the specified region.

Resolution:

  1. Obtain the service endpoint of the product in the corresponding API documentation.

  2. Run the following codes to set the endpoint:

    1. request.Domain = "<endpoint>"

SDK.JsonUnmarshalError

Error message: Failed to unmarshal response, but you can get the data via response.GetHttpStatusCode() and response.GetHttpContentString()

Cause:

SDK response deserialization fails. In most cases, it is because the response structure received by the SDK does not conform to ApiMeta. For example, the fields do not match, the format is incorrect, and so on.

Resolution:

Ignore SDK deserialization failure and obtain the response attributes by extracting the original http response.

Note: Alibaba Go SDK has dependency on JMESPath. Therefore, when the response content is in the JSON format, you can directly use JMESPath to parse the response.

  1. response, err := client.CreateInstance(request)
  2. if err != nil {
  3. // Handle exceptions
  4. if clientErr, isClientErr := err.(*errors.ClientError); isClientErr {
  5. if clientErr.ErrorCode() == errors.JsonUnmarshalErrorCode {
  6. // You can respectively obtain the data in the original response through our encapsulate methods.
  7. // The http status code in the response, type: int
  8. statusCode := response.GetHttpStatus()
  9. // The http head in the response, type: map[string][]string
  10. responseHeader := response.GetHttpHeaders()
  11. // The body content in the response, type: []byte
  12. responseBytes := response.GetHttpContentBytes()
  13. // The body content in the response, type: string, equivalent to `string(response.GetHttpContentBytes())`
  14. responseContent := response.GetHttpContentString()
  15. // You can also directly obtain the original response, type: net/http.Response
  16. httpResponse := response.GetOriginHttpResponse()
  17. }
  18. }
  19. }

SDK.TimeoutError

Error message: The request timed out 4 times(3 for retry), perhaps we should have the threshold raised a little?

Cause:

The request times out and all retry attempts fail.

Resolution

  • In scenarios such as cross-region calls or low network quality, we recommend that you increase the timeout or the maximum number of retries.

  • If the problem persists and the network quality is confirmed to be good, we recommend that you open a ticket.

SDK.AsyncFunctionNotEnabled

Error message: Async function is not enabled in client, please invoke ‘client.EnableAsync()’ function

Cause:

The asynchronous calls are not enabled.

Resolution:

Enable asynchronous calls. For more information, see Synchronous call.

SDK.ServerError: InvalidProtocol.NeedSsl

rror message: Your request is denied as lack of ssl protect.Recommend:https://error-center.aliyun.com/status/search?Keyword=InvalidProtocol.NeedSsl&source=PopGw

Cause

The API accepts only HTTPS requests so HTTP requests are rejected.

Resolution

Add the following codes before sending the request:

  1. request.Scheme = requests.HTTPS
Thank you! We've received your feedback.