Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cognito | Delay in Receiving LimitExceededException #2011

Closed
Raoufaaali opened this issue Apr 27, 2022 · 8 comments
Closed

Cognito | Delay in Receiving LimitExceededException #2011

Raoufaaali opened this issue Apr 27, 2022 · 8 comments
Labels
bug This issue is a bug. module/sdk-generated p2 This is a standard priority issue queued

Comments

@Raoufaaali
Copy link

Describe the bug

Delay in Receiving LimitExceededException for ResendConfirmationCode using the AWS SDK for .NET

The AWS SDK for .NET has the following bug related to Cognito

When calling ResendConfirmationCode using the SDK more than the allowed limit (5 calls per/ hour per/user), the call takes way too long to respond with a LimitExceededException.
This behavior seems to be isolated to the AWS SDK for .NET.
In comparison, the ResendConfirmationCode return LimitExceedException in less than 1 second when called via the cli.

The same issue is observed with the ConfirmForgotPassword

Expected Behavior

Receiving LimitExceededException should be taking around 1 second

Current Behavior

Receiving LimitExceededException is taking around 30 seconds

Reproduction Steps

  1. Configure Cognito user pool and SNS to send SMS for account confirmation
  2. Sign a user up in Cognito, set the phone_number attribute
  3. Observe that a code is sent to the user device
  4. Don’t confirm the user.
  5. Instead, call ResendConfirmationCode and observe the immediate response. Repeat this for 5 time until LimitExceededException is received.
  6. Observe the time taken to receive LimitExceededException is taking longer than 30 seconds

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

AWSSDK.CognitoIdentityProvider 3.3.103.3 and current latest stable AWSSDK.CognitoIdenitityProvider 3.7.2.14

Targeted .NET Platform

.NET Framework 4.5

Operating System and version

Windows 10, Windows 11, WindowsServer 2016 Core

@Raoufaaali Raoufaaali added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 27, 2022
@ashishdhingra
Copy link
Contributor

Hi @Raoufaaali,

Good morning.

Thanks for posting the issue. When the request is invoked via SDK's service client, it goes through the internal SDK pipeline which has predefined steps to resolve credentials, configure logging, marshall request, send the Http request to the service, receive response, unmarshall the response (including any error response), etc. All these steps take time, specially resolving credentials (refer Credential and profile resolution for credential search order).

Could you please share the following:

  • How are the credentials are configured?
  • If you are reusing the same AmazonCognitoIdentityProviderClient.
  • Turn on verbose logging and share the detailed logs. Since you are using .NET Framework 4.5, the blog post Logging with the AWS SDK for .NET might be helpful.

I'm not sure if AWS CLI caches the current client (AWS SDK for .NET also caches Http clients based on service client config) which could explain it returning in just 1 sec.

Thanks,
Ashish

@ashishdhingra ashishdhingra added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Apr 27, 2022
@Raoufaaali
Copy link
Author

Hi @ashishdhingra
Thanks for your response.

I have enabled the Logging and Metrics and I can see that the delay is caused by retrying the call 4 times even though it failed with LimitExceededException the 1st time

To answer your questions, the credentials are passed to AmazonCognitoIdentityProviderClient and we are reusing the same instance for all subsequent calls.

Logs:

Amazon Information: 0 : Request metrics: AsyncCall = False; ServiceName = Amazon.CognitoIdentityProvider; ServiceEndpoint = https://cognito-idp.us-west-2.amazonaws.com/; MethodName = ResendConfirmationCodeRequest; RequestSize = 64; StatusCode = OK; BytesProcessed = 108; AWSRequestID = 275dabc2-898e-4f07-963c-f9219b14aa8c; CredentialsRequestTime = 00:00:00.0015375; RequestSigningTime = 00:00:00.0002230; HttpRequestTime = 00:00:00.3741830; ResponseUnmarshallTime = 00:00:00.0146025; ResponseProcessingTime = 00:00:00.0194592; ClientExecuteTime = 00:00:00.4156971; 
Amazon Information: 1 : Request metrics: AsyncCall = False; ServiceName = Amazon.CognitoIdentityProvider; ServiceEndpoint = https://cognito-idp.us-west-2.amazonaws.com/; MethodName = ResendConfirmationCodeRequest; RequestSize = 64; StatusCode = OK; BytesProcessed = 108; AWSRequestID = 6c796a05-953f-4b07-9a2a-592a8f977013; CredentialsRequestTime = 00:00:00.0000009; RequestSigningTime = 00:00:00.0000014; HttpRequestTime = 00:00:00.3690071; ResponseUnmarshallTime = 00:00:00.0012819; ResponseProcessingTime = 00:00:00.0013353; ClientExecuteTime = 00:00:00.3706455; 
Amazon Information: 2 : Request metrics: AsyncCall = False; ServiceName = Amazon.CognitoIdentityProvider; ServiceEndpoint = https://cognito-idp.us-west-2.amazonaws.com/; MethodName = ResendConfirmationCodeRequest; RequestSize = 64; StatusCode = OK; BytesProcessed = 108; AWSRequestID = 8a6059c6-16d8-45cb-9e7e-cd8d3bee8742; CredentialsRequestTime = 00:00:00.0000007; RequestSigningTime = 00:00:00.0000005; HttpRequestTime = 00:00:00.1981135; ResponseUnmarshallTime = 00:00:00.0009877; ResponseProcessingTime = 00:00:00.0010003; ClientExecuteTime = 00:00:00.1993046; 
Amazon Information: 3 : Request metrics: AsyncCall = False; ServiceName = Amazon.CognitoIdentityProvider; ServiceEndpoint = https://cognito-idp.us-west-2.amazonaws.com/; MethodName = ResendConfirmationCodeRequest; RequestSize = 64; StatusCode = OK; BytesProcessed = 108; AWSRequestID = d3a1d020-4f22-4b0d-836c-ddf3f348dd44; CredentialsRequestTime = 00:00:00.0000007; RequestSigningTime = 00:00:00.0000006; HttpRequestTime = 00:00:00.1920820; ResponseUnmarshallTime = 00:00:00.0010490; ResponseProcessingTime = 00:00:00.0010670; ClientExecuteTime = 00:00:00.1933081; 
Amazon Error: 4 : An exception of type HttpErrorResponseException was handled in ErrorHandler., Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   --- End of inner exception stack trace ---
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext)
Amazon Information: 5 : LimitExceededException making request ResendConfirmationCodeRequest to https://cognito-idp.us-west-2.amazonaws.com/. Attempting retry 1 of 4.
Amazon Error: 6 : An exception of type HttpErrorResponseException was handled in ErrorHandler., Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   --- End of inner exception stack trace ---
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext)
Amazon Information: 7 : LimitExceededException making request ResendConfirmationCodeRequest to https://cognito-idp.us-west-2.amazonaws.com/. Attempting retry 2 of 4.
Amazon Error: 8 : An exception of type HttpErrorResponseException was handled in ErrorHandler., Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   --- End of inner exception stack trace ---
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext)
Amazon Information: 9 : LimitExceededException making request ResendConfirmationCodeRequest to https://cognito-idp.us-west-2.amazonaws.com/. Attempting retry 3 of 4.
Amazon Error: 10 : An exception of type HttpErrorResponseException was handled in ErrorHandler., Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   --- End of inner exception stack trace ---
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext)
Amazon Information: 11 : LimitExceededException making request ResendConfirmationCodeRequest to https://cognito-idp.us-west-2.amazonaws.com/. Attempting retry 4 of 4.
Amazon Error: 12 : An exception of type HttpErrorResponseException was handled in ErrorHandler., Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   --- End of inner exception stack trace ---
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext)
Amazon Error: 13 : LimitExceededException making request ResendConfirmationCodeRequest to https://cognito-idp.us-west-2.amazonaws.com/. Attempt 5., Amazon.CognitoIdentityProvider.Model.LimitExceededException: Attempt limit exceeded, please try after some time. ---> Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   --- End of inner exception stack trace ---
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext)
   --- End of inner exception stack trace ---
   at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException(IExecutionContext executionContext, HttpErrorResponseException exception)
   at Amazon.Runtime.Internal.ErrorHandler.ProcessException(IExecutionContext executionContext, Exception exception)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.CallbackHandler.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.RetryHandler.InvokeSync(IExecutionContext executionContext)
Amazon Information: 14 : Request metrics: AsyncCall = False; ServiceName = Amazon.CognitoIdentityProvider, Amazon.CognitoIdentityProvider, Amazon.CognitoIdentityProvider, Amazon.CognitoIdentityProvider, Amazon.CognitoIdentityProvider; ServiceEndpoint = https://cognito-idp.us-west-2.amazonaws.com/, https://cognito-idp.us-west-2.amazonaws.com/, https://cognito-idp.us-west-2.amazonaws.com/, https://cognito-idp.us-west-2.amazonaws.com/, https://cognito-idp.us-west-2.amazonaws.com/; MethodName = ResendConfirmationCodeRequest, ResendConfirmationCodeRequest, ResendConfirmationCodeRequest, ResendConfirmationCodeRequest, ResendConfirmationCodeRequest; RequestSize = 64, 64, 64, 64, 64; Exception = Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.\r\n   at System.Net.HttpWebRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   --- End of inner exception stack trace ---\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext), Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.\r\n   at System.Net.HttpWebRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   --- End of inner exception stack trace ---\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext), Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.\r\n   at System.Net.HttpWebRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   --- End of inner exception stack trace ---\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext), Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.\r\n   at System.Net.HttpWebRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   --- End of inner exception stack trace ---\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext), Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.\r\n   at System.Net.HttpWebRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   --- End of inner exception stack trace ---\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext); StatusCode = BadRequest, BadRequest, BadRequest, BadRequest, BadRequest; AWSRequestID = b47dc0e0-91fe-436c-90bb-2dc06aa5861f, 931741e4-09f5-4672-a260-6c415a7158d3, 7415f699-0789-4d78-bf90-51a2bfffe25b, d63f42aa-ae0d-4ccd-ae4f-08b9b5464034, 3ec10c92-5f73-4e21-86a6-ef203d9ccfdc; AWSErrorCode = LimitExceededException, LimitExceededException, LimitExceededException, LimitExceededException, LimitExceededException; CredentialsRequestTime = 00:00:00.0000007; CredentialsRequestTime = 00:00:00.0000024; CredentialsRequestTime = 00:00:00.0000082; CredentialsRequestTime = 00:00:00.0000017; CredentialsRequestTime = 00:00:00.0000019; RequestSigningTime = 00:00:00.0000004; HttpRequestTime = 00:00:00.0558184; HttpRequestTime = 00:00:00.0524684; HttpRequestTime = 00:00:00.0596686; HttpRequestTime = 00:00:00.0529226; HttpRequestTime = 00:00:00.0529888; RetryPauseTime = 00:00:00.4099084; RetryPauseTime = 00:00:01.6027024; RetryPauseTime = 00:00:06.4096267; RetryPauseTime = 00:00:25.6144596; ClientExecuteTime = 00:00:34.3914681; AttemptCount = 4; 
Amazon Error: 15 : An exception of type HttpErrorResponseException was handled in ErrorHandler., Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   --- End of inner exception stack trace ---
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext)
Amazon Information: 16 : LimitExceededException making request ResendConfirmationCodeRequest to https://cognito-idp.us-west-2.amazonaws.com/. Attempting retry 1 of 4.
Amazon Error: 17 : An exception of type HttpErrorResponseException was handled in ErrorHandler., Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   --- End of inner exception stack trace ---
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext)
Amazon Information: 18 : LimitExceededException making request ResendConfirmationCodeRequest to https://cognito-idp.us-west-2.amazonaws.com/. Attempting retry 2 of 4.
Amazon Error: 19 : An exception of type HttpErrorResponseException was handled in ErrorHandler., Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   --- End of inner exception stack trace ---
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext)
Amazon Information: 20 : LimitExceededException making request ResendConfirmationCodeRequest to https://cognito-idp.us-west-2.amazonaws.com/. Attempting retry 3 of 4.
Amazon Error: 21 : An exception of type HttpErrorResponseException was handled in ErrorHandler., Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   --- End of inner exception stack trace ---
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext)
Amazon Information: 22 : LimitExceededException making request ResendConfirmationCodeRequest to https://cognito-idp.us-west-2.amazonaws.com/. Attempting retry 4 of 4.
Amazon Error: 23 : An exception of type HttpErrorResponseException was handled in ErrorHandler., Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   --- End of inner exception stack trace ---
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext)
Amazon Error: 24 : LimitExceededException making request ResendConfirmationCodeRequest to https://cognito-idp.us-west-2.amazonaws.com/. Attempt 5., Amazon.CognitoIdentityProvider.Model.LimitExceededException: Attempt limit exceeded, please try after some time. ---> Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   --- End of inner exception stack trace ---
   at Amazon.Runtime.Internal.HttpRequest.GetResponse()
   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext)
   --- End of inner exception stack trace ---
   at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException(IExecutionContext executionContext, HttpErrorResponseException exception)
   at Amazon.Runtime.Internal.ErrorHandler.ProcessException(IExecutionContext executionContext, Exception exception)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.CallbackHandler.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.RetryHandler.InvokeSync(IExecutionContext executionContext)
Amazon Information: 25 : Request metrics: AsyncCall = False; ServiceName = Amazon.CognitoIdentityProvider, Amazon.CognitoIdentityProvider, Amazon.CognitoIdentityProvider, Amazon.CognitoIdentityProvider, Amazon.CognitoIdentityProvider; ServiceEndpoint = https://cognito-idp.us-west-2.amazonaws.com/, https://cognito-idp.us-west-2.amazonaws.com/, https://cognito-idp.us-west-2.amazonaws.com/, https://cognito-idp.us-west-2.amazonaws.com/, https://cognito-idp.us-west-2.amazonaws.com/; MethodName = ResendConfirmationCodeRequest, ResendConfirmationCodeRequest, ResendConfirmationCodeRequest, ResendConfirmationCodeRequest, ResendConfirmationCodeRequest; RequestSize = 64, 64, 64, 64, 64; Exception = Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.\r\n   at System.Net.HttpWebRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   --- End of inner exception stack trace ---\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext), Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.\r\n   at System.Net.HttpWebRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   --- End of inner exception stack trace ---\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext), Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.\r\n   at System.Net.HttpWebRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   --- End of inner exception stack trace ---\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext), Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.\r\n   at System.Net.HttpWebRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   --- End of inner exception stack trace ---\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext), Amazon.Runtime.Internal.HttpErrorResponseException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.\r\n   at System.Net.HttpWebRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   --- End of inner exception stack trace ---\r\n   at Amazon.Runtime.Internal.HttpRequest.GetResponse()\r\n   at Amazon.Runtime.Internal.HttpHandler`1.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.Unmarshaller.InvokeSync(IExecutionContext executionContext)\r\n   at Amazon.Runtime.Internal.ErrorHandler.InvokeSync(IExecutionContext executionContext); StatusCode = BadRequest, BadRequest, BadRequest, BadRequest, BadRequest; AWSRequestID = c66a52e9-fee3-4ecc-9436-34e0090377e1, dcb04623-9c7b-4d5d-b576-72f555144d91, a3ce045e-6809-4d5e-8e3c-5192257ea8a3, 3b1aa4a9-e15b-4628-aede-20d223d47859, bd0afd46-528d-48ff-865b-3ac2886898f7; AWSErrorCode = LimitExceededException, LimitExceededException, LimitExceededException, LimitExceededException, LimitExceededException; CredentialsRequestTime = 00:00:00.0000015; CredentialsRequestTime = 00:00:00.0000015; CredentialsRequestTime = 00:00:00.0000036; CredentialsRequestTime = 00:00:00.0000022; CredentialsRequestTime = 00:00:00.0000017; RequestSigningTime = 00:00:00.0000008; HttpRequestTime = 00:00:00.0555153; HttpRequestTime = 00:00:00.0518730; HttpRequestTime = 00:00:00.0552595; HttpRequestTime = 00:00:00.0523159; HttpRequestTime = 00:00:00.0500740; RetryPauseTime = 00:00:00.4148543; RetryPauseTime = 00:00:01.6012891; RetryPauseTime = 00:00:06.4067993; RetryPauseTime = 00:00:25.6138230; ClientExecuteTime = 00:00:34.3631190; AttemptCount = 4; 

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Apr 28, 2022
@ashishdhingra
Copy link
Contributor

ashishdhingra commented Apr 28, 2022

@Raoufaaali That might answer your question on why it doesn't fail/return error immediately. Retry mechanism is built to handle intermittent errors from service in the SDK. Refer Retries and timeouts for information on configurable retries and timeouts in AWS SDK for .NET.

I'm unsure about the default values for AWS CLI.

This needs review with the team if we should bypass retry for LimitExceededException, however, the above documentation clearly states The AWS SDK for .NET can retry requests that fail due to server-side throttling or dropped connections.

@ashishdhingra
Copy link
Contributor

Need to check with AWS CLI on how retries for such exceptions are handled.

@Raoufaaali As a workaround you could set maximum retries to 0 in service client config and see if it works.

@ashishdhingra ashishdhingra added the B label May 6, 2022
@IgorPietraszko
Copy link

We have ran into the same issue.

We've been testing Cognito based authentication and password maintenance scenarios and while we know that there is a quota of 5 ChangePassword calls per hour, per user (https://docs.aws.amazon.com/cognito/latest/developerguide/limits.html), we've been trying to catch the response (max tries) and react to it. But it seems like the retry is kicking in before that and it takes a long time in dev environment or outright times out in lambda.

According to the above referenced article (https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/retries-timeouts.html) we could configure retries when creating a client service. I was wondering if we could provide a modified AmazonCognitoIdentityConfig when calling services.TryAddAWSService<IAmazonCognitoIdentityProvider>();?

services.TryAddAWSService<IAmazonCognitoIdentityProvider>(new AmazonCognitoIdentityConfig{ MaxErrorRetry = 2 });

@Raoufaaali
Copy link
Author

Raoufaaali commented May 11, 2022

As a workaround you could set maximum retries to 0 in service client config and see if it works.

@ashishdhingra Setting the retries to 0 fixes the problem in that the LimitExceededExeption is returned sooner. The downside of this workaround is that; now we lose the benefit of the retry mechanism for legit dropped connections..etc.

An ideal fix, IMO, would be if the SDK didn't retry if the service returned 400 BadRequest due to LimitExceededException

@ashishdhingra ashishdhingra added p2 This is a standard priority issue queued and removed B labels Nov 3, 2022
@bhoradc
Copy link

bhoradc commented Oct 18, 2024

Hi @Raoufaaali,

After consulting with our team, we understand that the LimitExceededException is treated as a throttling error according to the specifications provided to the SDK teams. As per these specifications, all throttling errors are subject to retries, and the retry mechanism is consistently implemented across all AWS SDKs.

For your specific use case, as recommended earlier, you can try initializing the client with the service config MaxErrorRetry set to 0. This setting could be applied only for the specific operation where you encounter the LimitExceededException. By doing so, you will disable the retry mechanism for that particular operation, allowing you to receive the LimitExceededException without the additional delay caused by retries in the SDK.

Based on this explanation, I will be closing this request. Please let us know if you have further queries. Thanks.

Regards,
Chaitanya

@bhoradc bhoradc closed this as completed Oct 18, 2024
Copy link

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. module/sdk-generated p2 This is a standard priority issue queued
Projects
None yet
Development

No branches or pull requests

4 participants