sendgrid-csharp icon indicating copy to clipboard operation
sendgrid-csharp copied to clipboard

Multiple httpClients created when using multiple sub- accounts in sendgrid

Open nitinmuteja opened this issue 7 years ago • 3 comments

Issue Summary

When using multiple sendgrid subaccounts in web services, you might need to create a sendgrid object per web request. Sendgrid client does not utilize the same HTTP client and keeps on creating them per object. Since the application URL is the same, we could limit the HTTP client per URL by using a static instance. In this scenario, the sendgrid client creates throttling in applications.

Steps to Reproduce

  1. Create an asp.net web api.
  2. Create a sendgrid client per web request with different credentials each time.
  3. The application will throttle.

The client dll should create a single instance of HTTP client and this would work in the above scenario. In our application, there are hundreds of sendgrid subaccounts and even caching hundreds of Http clients is also not a feasible solution.

Technical details:

  • sendgrid-csharp Version: master (v9.10.0)
  • Platform (ASP.NET webapi)
  • .NET Version: 4.5.2

nitinmuteja avatar Mar 02 '19 11:03 nitinmuteja

Hello @nitinmuteja,

Thank you for taking the time to highlight this limitation of our SDK. I like your suggestion and have added it our backlog and opened it up to the community for a PR.

With Best Regards,

Elmer

thinkingserious avatar Mar 04 '19 18:03 thinkingserious

#839 combined with #904 fixes this, your proposed usage will be fully supported once those PRs are merged.

aevitas avatar Jul 04 '19 15:07 aevitas

Since there has been no activity on this issue since March 1, 2020, we are closing this issue. Please feel free to reopen or create a new issue if you still require assistance. Thank you!

thinkingserious avatar Mar 10 '21 01:03 thinkingserious