question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

azure.communication.email.EmailClient send method not throwing error if response status code is 429

See original GitHub issue
  • Package Name: azure-communication-email
  • Package Version: 1.0.0b1
  • Operating System: Linux
  • Python Version: 3.8

Describe the bug When calling send method of EmailClient and rate limiting (Response status 429) has been reached, script hangs and doesn’t throw an error.

To Reproduce Steps to reproduce the behavior:

  1. Create a little script to call the send method. e.g.
from azure.communication.email import EmailClient, EmailContent, EmailAddress, EmailMessage, EmailRecipients

connection_string = "..."
client = EmailClient.from_connection_string(connection_string);

content = EmailContent(
    subject="This is the subject",
    plain_text="This is the body",
    html= "<html><h1>This is the body</h1></html>",
)

address = EmailAddress(email="...")

message = EmailMessage(
    sender="...",
    content=content,
    recipients=EmailRecipients(to=[address])
)

response = client.send(message)
  1. Repeat it more than 25 times in a hour (Communication service rate limit)
  2. Execute it a 26th time
  3. … Process hangs

Expected behavior Throw exception so can be caught and processed accordingly

Screenshots Below an example of a Azure Function that receives a 429 immediately, but times out after 5 minutes because no exception has been raised.

Untitled

Additional context In our specific case this function is triggered by a Servicebus message. If I had the possibility to catch the exception and the Retry-After value I could potentially re-schedule the message. I have noticed that the library offers a cls parameter that could be used to pass also the Retry-After and not only x-ms-request-id.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
annatischcommented, Sep 26, 2022

@xiangyan99 - I’m not sure this should be marked as addressed. We should not have to resort to changing the retry policy for the correct behaviour - I think the service team needs to address this.

0reactions
navba-MSFTcommented, Oct 28, 2022

Adding Service team to look into this.

@acsdevx-msft Could you please look into this once you get a chance ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Communication Services Common Error Codes
HTTP Status Codes ; 422 Unprocessable Entity, The body of the request couldn't be validated. Is it valid JSON? ; 429 Too Many...
Read more >
azure-communication-email 1.0.0b1 - PyPI
The Azure Communication Email package is used to do following: Send emails to multiple types of recipients; Query the status of a sent...
Read more >
Azure.Communication.Email 1.0.0-beta.1 - NuGet
This is a prerelease version of Azure.Communication.Email. ... To send an email message, call the Send or SendAsync function from the EmailClient ....
Read more >
Handling the “HTTP 429 – Too Many Requests” error when ...
The HTTP 429 - Too Many Requests response status code indicates the user has sent too many requests in a given amount of...
Read more >
MobileIron Core 11.0.0.0 Device Management Guide
Device users then complete the registration process by responding to registration prompts. If Core detects that the MDM profile has not yet ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found