RetryHandler does not retry in case of 429 error

Aaditya Rane 51 Reputation points
2021-02-26T15:37:59.557+00:00

Issue

When graph endpoint for adding tabs POST: /tabs gives throttling (429) error. When RetryHandler calls retryRequest it checks for isBuffered where it requires header Transfer-Encoding as Chunked, in order to send True and to set shouldRetry flag as True.
Issue Class : com.microsoft.graph.httpcore.RetryHandler (microsoft-graph SDK version 2.7.1)

Observations

Some times header "Transfer-Encoding = chunked" is missing in the response headers. Causing it to return False. As a result it sets shouldRetry flag as False and it never retry again.

Response Headers :
[
Cache-Control : private,
client-request-id : 5a064a73-9106-40ec-8dff-4069c5752de4,
Content-Length : 885,
Content-Type : application/json,
Date : Fri, 26 Feb 2021 14:03:23 GMT,
request-id : 64638ad8-1f98-49d1-9185-238341d4938e,
Retry-After : 60,
Strict-Transport-Security : max-age=31536000,
x-ms-ags-diagnostic :
{"ServerInfo": {"DataCenter":"SouthIndia","Slice":"SliceC","Ring":"3", "ScaleUnit":"001","RoleInstance":"AGSFE_IN_7" }}
]

Response Body :
{
"error": {
"code": "TooManyRequests",
"message": "Too many requests from Identifier:9155ce04-4eae-42ae-905e-ac219c282f72+786c9214-bb88-448d-9a43-3afeb1518b52+786c9214-bb88-448d-9a43-3afeb1518b52 under category:throttle.teams.ags.api_complex_level_10.tenant_normal.app_normal.operation_write_sustained. Please try again later.",
"innerError": {
"date": "2021-02-26T14:03:23",
"request-id": "64638ad8-1f98-49d1-9185-238341d4938e",
"client-request-id": "5a064a73-9106-40ec-8dff-4069c5752de4",
"status": 429,
"code": "429",
"message": "Too many requests from Identifier:9155ce04-4eae-42ae-905e-ac219c282f72+786c9214-bb88-448d-9a43-3afeb1518b52+786c9214-bb88-448d-9a43-3afeb1518b52 under category:throttle.teams.ags.api_complex_level_10.tenant_normal.app_normal.operation_write_sustained. Please try again later."
}
}
}

Steps to reproduce

  1. Throttle the /tabs end point, by sending multiple tab addition requests for microsoft teams channels.
  2. Use microsoft graph SDK for java to add tab in channel.

    Question

  3. Why sometimes "Transfer-Encoding = chunked" header is missing?
  4. Is there any workaround to this problem, so that I can use microsoft graph sdk ?
Microsoft Teams Development
Microsoft Security Microsoft Graph
{count} votes

2 answers

Sort by: Most helpful
  1. Jagadeesh-MSFT 331 Reputation points
    2021-04-01T12:19:33.973+00:00

    Hi AadityaRane-1988, We have tested the retry handler code using parallel loop by taking threshold limit = 200, didn't face any issue while creating the tab in this scenario. Could you please try with below code.

    int i, n = 200;  
    Parallel.For(0, n, i =>  
    {  
    var teamsTab = new TeamsTab  
    {  
    DisplayName = "My Tab" + i,  
    Configuration = new TeamsTabConfiguration  
    {  
    EntityId = "2DCA2E6C7A10415CAF6B8AB66121435",  
    ContentUrl = _configuration["BaseUri"] + "/TestTab" + i,  
    WebsiteUrl = _configuration["BaseUri"] + "/TestTab" + i  
    },  
    AdditionalData = new Dictionary<string, object>()  
    {  
    { "******@odata.bind", "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/" + teamsAppId }  
    }  
    };  
      
     var result = graphClient.Teams[teamId].Channels[channelId].Tabs  
    .Request()  
    .AddAsync(teamsTab);  
    });  
    

    83732-image.png

    0 comments No comments

  2. Aaditya Rane 51 Reputation points
    2022-01-02T07:44:49.237+00:00

    The issue was got fixed in msgraph-sdk-java-core 1.0.9

    https://github.com/microsoftgraph/msgraph-sdk-java-core/issues/160

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.