-
Notifications
You must be signed in to change notification settings - Fork 585
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
Async broken in library, causing deadlocks and responses not returning in non-console apps #235
Comments
I am also facing same issue. Its working fine with console app. but when integrated with MVC application, its not returning response. |
@thinkingserious yes, the email was sent successfully. |
@thinkingserious Yes, Email are being sent successfully, but after posting mail, its not returning response. |
same here... |
@thinkingserious Any estimation on when this bug will be fixed?? |
Hello Everyone, @hunglee @trinathm @ChrisRacki @joantorres @jahmai @walmon First, thanks for your feedback and patience. I've done some digging and I can't reproduce in the console app (as mentioned, it seems to work there) so here is what I'm thinking (I would love to get some feedback): The API call happens here which calls this function. So perhaps this call Thoughts? I still have more digging to do, as I don't have an environment where I see this error reproduced (if anyone can help with that, I would be greatly appreciative). |
I can reliably reproduce this in a Web API project. Here is my method: [Route("sendEmail"), HttpPost, AllowAnonymous]
public virtual async Task<IHttpActionResult> SendEmail()
{
var apiKey = "my api key";
var from = new Email("from@example.com");
var subject = "Subject";
var to = new Email("to@example.com");
var textContent = new Content("text/plain", "Content");
var mail = new Mail(from, subject, to, textContent);
dynamic sendGridClient = new SendGridAPIClient(apiKey);
// All three of these calls never return. The email message is sent, however.
dynamic response = sendGridClient.client.mail.send.post(requestBody: mail.Get());
dynamic response = await sendGridClient.client.mail.send.post(requestBody: mail.Get());
dynamic response = await (sendGridClient.client.mail.send.post(requestBody: mail.Get())).ConfigureAwait(false);
// This line is never executed.
return this.Ok();
} I cannot use the client library at all until this is resolved. I'll be making "raw" HTTP requests instead using |
Thanks @matthewbcline! What does the code look like that calls Seems like we need to have |
@thinkingserious I had a sneaking suspicion that the solution would involve |
Agreed, I will try that fix and report back. Thanks! |
@thinkingserious I was experimenting with the ConfigureAwait(false) earlier today and had no joy. Thankfully I checked this thread and tried adding it to the exact spots in the code you mentioned and it worked for me. Thanks! |
@alanhouck thanks for confirming!!! I will push out an update and I'd like to swag out everyone on this thread. Please send your T-shirt size and mailing address to dx@sendgrid.com :) |
This issue is fixed in version 7.0.2: https://github.com/sendgrid/sendgrid-csharp/releases/tag/v7.0.2 |
@thinkingserious This worked! |
Now, which one is the correct call? dynamic response = sendGridClient.client.mail.send.post(requestBody: mail.Get()); |
@PranKe01 whether or not you include the await keyword depends on your desired behavior, please see: https://msdn.microsoft.com/en-us/library/hh156528.aspx |
When using dynamic response = await sendGridApi.client.mail.send.post(requestBody: mail.Get()); instead of dynamic response = sendGridApi.client.mail.send.post(requestBody: mail.Get()); I get an exception. |
@PranKe01 what is the exception you are receiving? |
An exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in System.Web.Mvc.dll but was not handled in user code Additional information: SendGrid.CSharp.HTTP.Client.Response enthält keine Definition für GetAwaiter. |
@PranKe01 do you mind creating a new ticket for that specific issue? If I don't hear back I'll go ahead and create it. |
@thinkingserious Thx |
Hi @tawani, Did you try the solution offered regarding your lists? |
Which solution? None works. |
The last one sent by our support team regarding certain emails on your lists, I believe it was sent on Saturday. What do you mean by manually resetting emails? Do you mean resending? Do you mind sending more of your source code so that we may try to reproduce? |
If you prefer not to post it here, please send to dx@sendgrid.com. |
I have tried everything you sent. No email is delivered.
The only email that gets delivered is the one sent to "tawani@gmail.com"
(my own email address). Emails don't get delivered or even displayed on my
Sendgrid dashboard.
Please advice!
T
…On Wed, May 17, 2017 at 5:20 PM, Elmer Thomas ***@***.***> wrote:
If you prefer not to post it here, please send to ***@***.***
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#235 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOWpTpFOoGDr3qJfzZ8HOoDpwy90xrpks5r62SfgaJpZM4I2Cd2>
.
|
Hi @tawani, Do you mind sending more of your source code so that we may try to reproduce? If you prefer not to post it here, please send to dx@sendgrid.com. Thanks! |
Here you go:
public async Task SendAsync(Common.Emailing.Email email)
{
var client = new SendGridClient(ApiKey);
var msg = new SendGridMessage()
{
From = new EmailAddress("no-reply@curistech.com", "CurisTech Team"),
Subject = email.Subject,
PlainTextContent =
StripHtml(email.CreateMailMessage().Body.Replace("<br>",
"\r\n").Replace("<br/>", "\r\n")),
HtmlContent = email.CreateMailMessage().Body
};
msg.AddTo(new EmailAddress(email.To));
msg.SetFooterSetting(
true,
"CurisTech © 2016",
"<strong>CurisTech © 2016</strong>");
msg.SetClickTracking(true, true);
var response = await client.SendEmailAsync(msg);
//return response;
}
…On Thu, May 18, 2017 at 9:31 AM, Elmer Thomas ***@***.***> wrote:
Hi @tawani <https://github.com/tawani>,
Do you mind sending more of your source code so that we may try to
reproduce?
If you prefer not to post it here, please send to ***@***.***
Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#235 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOWpbB2BCfxDj3HW5GRXH_a8jQaEWVcks5r7EghgaJpZM4I2Cd2>
.
|
Hi @tawani, How are you calling |
public void Send(Common.Emailing.Email email)
{
SendAsync(email).Wait();
}
…On Thu, May 18, 2017 at 12:38 PM, Elmer Thomas ***@***.***> wrote:
Hi @tawani <https://github.com/tawani>,
How are you calling SendAsync?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#235 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOWpXLk_WdnThLrCQKNqyUOuFsC5dbvks5r7HP8gaJpZM4I2Cd2>
.
|
Please try:
SendAsync(email).Result;
Response result = response;
var statusCode = result.StatusCode.ToString(); // log this value appropriately so that you can read the result
Also, when you say "The only email that gets delivered is the one sent to "tawani@gmail.com". Do you mean that when you try your code with that email it works fine, but when you try again with any other email it does not work? Could you try sending to dx@sendgrid.com? |
I used "tawani@gmail.com" and a bunch of other emails on a test Console
app. And only "tawani@gmail.com" was delivered.
See screenshot below - Only console apps get logged by Sendgrid:
…On Thu, May 18, 2017 at 12:50 PM, Elmer Thomas ***@***.***> wrote:
Please try:
1. Uncomment return response
2. Replace SendAsync(email).Wait(); with
SendAsync(email).Result;Response result = response;var statusCode = result.StatusCode.ToString(); // log this value appropriately so that you can read the result
1. Replace public async Task SendAsync(Common.Emailing.Email email)
with public static async Task<Response> SendAsync(Common.Emailing.Email
email)
Also, when you say "The only email that gets delivered is the one sent to "
***@***.***". Do you mean that when you try your code with that
email it works fine, but when you try again with any other email it does
not work? Could you try sending to ***@***.***?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#235 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOWpeIpHIK8eKh8_rXF6d6Z4YTkwvBzks5r7HbEgaJpZM4I2Cd2>
.
|
No result is ever returned.
The process just sits there waiting forever.
Please advice!
T
…On Thu, May 18, 2017 at 12:58 PM, Tawani Anyangwe ***@***.***> wrote:
I used ***@***.***" and a bunch of other emails on a test Console
app. And only ***@***.***" was delivered.
See screenshot below - Only console apps get logged by Sendgrid:
On Thu, May 18, 2017 at 12:50 PM, Elmer Thomas ***@***.***>
wrote:
> Please try:
>
> 1. Uncomment return response
> 2. Replace SendAsync(email).Wait(); with
>
> SendAsync(email).Result;Response result = response;var statusCode = result.StatusCode.ToString(); // log this value appropriately so that you can read the result
>
>
> 1. Replace public async Task SendAsync(Common.Emailing.Email email)
> with public static async Task<Response> SendAsync(Common.Emailing.Email
> email)
>
> Also, when you say "The only email that gets delivered is the one sent to
> ***@***.***". Do you mean that when you try your code with that
> email it works fine, but when you try again with any other email it does
> not work? Could you try sending to ***@***.***?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#235 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAOWpeIpHIK8eKh8_rXF6d6Z4YTkwvBzks5r7HbEgaJpZM4I2Cd2>
> .
>
|
Hi @tawani, Did you try making the 3 changes I suggested? Can you please walk me through step by step what happens when you have the result of "The process just sits there waiting forever"? For example:
|
It never gets to the break point.
The code stops immediately after calling send email async (ie at var
response)
var response = await client.SendEmailAsync(msg);
return response;
…On Thu, May 18, 2017 at 1:19 PM, Elmer Thomas ***@***.***> wrote:
Hi @tawani <https://github.com/tawani>,
Did you try making the 3 changes I suggested?
Can you please walk me through step by step what happens when you have the
result of "The process just sits there waiting forever"?
For example:
1. Using Visual Studio version X.X I create a XXXXX project
2. I use the following code:
[Sample Code]
3. When I run the code and set a breakpoint at some point after the await
client.SendEmailAsync(msg);, the breakpoint is never reached.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#235 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOWpRlp0HYFDy6AcowU5Xm3coJdTYU5ks5r7H2ZgaJpZM4I2Cd2>
.
|
VS 2015
…On Thu, May 18, 2017 at 1:23 PM, Tawani Anyangwe ***@***.***> wrote:
It never gets to the break point.
The code stops immediately after calling send email async (ie at var
response)
var response = await client.SendEmailAsync(msg);
return response;
On Thu, May 18, 2017 at 1:19 PM, Elmer Thomas ***@***.***>
wrote:
> Hi @tawani <https://github.com/tawani>,
>
> Did you try making the 3 changes I suggested?
>
> Can you please walk me through step by step what happens when you have
> the result of "The process just sits there waiting forever"?
>
> For example:
>
> 1. Using Visual Studio version X.X I create a XXXXX project
> 2. I use the following code:
> [Sample Code]
> 3. When I run the code and set a breakpoint at some point after the await
> client.SendEmailAsync(msg);, the breakpoint is never reached.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#235 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAOWpRlp0HYFDy6AcowU5Xm3coJdTYU5ks5r7H2ZgaJpZM4I2Cd2>
> .
>
|
Did you try making the 3 changes I suggested? |
Just before you call |
Yes. Didn't you see my screen shot?
…On Thu, May 18, 2017 at 1:27 PM, Elmer Thomas ***@***.***> wrote:
Did you try making the 3 changes I suggested?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#235 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOWpSUSaCskH7puiZ9Uq7rORgBbx7wgks5r7H9lgaJpZM4I2Cd2>
.
|
Attached.
Thanks!
T
{"from":{"name":"CurisTech
Team","email":"no-reply@curistech.com"},"personalizations":[{"to":[{}]}],"content":[{"type":"text/plain","value":"CusrisTech.com\r\nReset
Password\r\n\r\nDear Ali Baba,\r\n\r\nPlease reset your password by
clicking this link: Reset Password\r\n\r\n\r\n\r\n\r\n If you have any
questions on the order, please contact
CusrisTech.com.\r\n\r\n\r\nRegards,\r\n\r\nSupport
Team"},{"type":"text/html","value":"\u003ch4
style=\u0022color:gray;\u0022\u003eCusrisTech.com\u003c/h4\u003e\r\n\u003ch1\u003eReset
Password\u003c/h1\u003e\r\n\r\nDear Ali Baba,\r\n\r\n\u003cp\u003ePlease
reset your password by clicking this link: \u003ca href=\u0022
http://localhost:34861/cmd/reset?token=zTi0noZWQpck8KIWstjuFDgbRlv8bLJINoM0F7hpxjpaj2Ik3weFZ2mg+Q3sbIdTImrIB1PTskc=\u0022\u003eReset
Password\u003c/a\u003e\r\n\r\n\r\n\r\n\u003cp\u003e\r\n If you have any
questions on the order, please contact \u003ca href=\u0022
http://localhost:34861/\u0022\u003eCusrisTech.com\u003c/a\u003e.\r\n\u003c/p\u003e\r\n\r\nRegards,\r\n\u003cbr
/\u003e\u003cbr /\u003e\r\nSupport
Team"}],"mail_settings":{"footer":{"enable":true,"text":"\u003cstrong\u003eCurisTech
\u0026copy; 2016\u003c/strong\u003e","html":"CurisTech \u0026copy;
2016"}},"tracking_settings":{"click_tracking":{"enable":true,"enable_text":true}}}
On Thu, May 18, 2017 at 1:27 PM, Elmer Thomas ***@***.***> wrote:
Just before you call var response = await client.SendEmailAsync(msg);,
can you tell me the output of msg.Serialize()?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#235 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOWpTIVcXapV6fBfSGk4DXij6YMArr_ks5r7H-UgaJpZM4I2Cd2>
.
{"from":{"name":"CurisTech Team","email":"no-reply@curistech.com"},"personalizations":[{"to":[{}]}],"content":[{"type":"text/plain","value":"CusrisTech.com\r\nReset Password\r\n\r\nDear Ali Baba,\r\n\r\nPlease reset your password by clicking this link: Reset Password\r\n\r\n\r\n\r\n\r\n If you have any questions on the order, please contact CusrisTech.com.\r\n\r\n\r\nRegards,\r\n\r\nSupport Team"},{"type":"text/html","value":"\u003ch4 style=\u0022color:gray;\u0022\u003eCusrisTech.com\u003c/h4\u003e\r\n\u003ch1\u003eReset Password\u003c/h1\u003e\r\n\r\nDear Ali Baba,\r\n\r\n\u003cp\u003ePlease reset your password by clicking this link: \u003ca href=\u0022http://localhost:34861/cmd/reset?token=zTi0noZWQpck8KIWstjuFDgbRlv8bLJINoM0F7hpxjpaj2Ik3weFZ2mg+Q3sbIdTImrIB1PTskc=\u0022\u003eReset Password\u003c/a\u003e\r\n\r\n\r\n\r\n\u003cp\u003e\r\n If you have any questions on the order, please contact \u003ca href=\u0022http://localhost:34861/\u0022\u003eCusrisTech.com\u003c/a\u003e.\r\n\u003c/p\u003e\r\n\r\nRegards,\r\n\u003cbr /\u003e\u003cbr /\u003e\r\nSupport Team"}],"mail_settings":{"footer":{"enable":true,"text":"\u003cstrong\u003eCurisTech \u0026copy; 2016\u003c/strong\u003e","html":"CurisTech \u0026copy; 2016"}},"tracking_settings":{"click_tracking":{"enable":true,"enable_text":true}}}
|
Your screen shot is not showing up here on GitHub. Perhaps you can upload it somewhere and provide the link. Take a look at your personalization block: "personalizations": [
{
"to": [
{
}
]
}
], Your email is not getting added. Can you take a look at Thanks! |
It seems our previous "Email" component is not adding the to email.
Verifying it.
Thanks!
…On Thu, May 18, 2017 at 1:35 PM, Elmer Thomas ***@***.***> wrote:
Your screen shot is not showing up here on GitHub. Perhaps you can upload
it somewhere and provide the link.
Take a look at your personalization block:
"personalizations": [
{
"to": [
{
}
]
}
],
Your email is not getting added.
Can you take a look at msg.AddTo(new EmailAddress(email.To));,
specifically, please verify the value of email.To. And for a quick test,
you can manually add an email address there.
Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#235 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOWpf2Rk6Jjh-9__qcuQc63FFHSQc4nks5r7IFzgaJpZM4I2Cd2>
.
|
Sounds good, please let us know how it goes. Thanks! |
Our previous component was the SMTP MailMessage which contained the
"to/from/subject" information. That is why our Conole app was working but
not the web app.
I have updated the code and attached is the latest message.
It seems to have been processed but we still haven't gotten a response yet.
Thanks!
On Thu, May 18, 2017 at 1:47 PM, Elmer Thomas ***@***.***> wrote:
Sounds good, please let us know how it goes. Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#235 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOWpWbm_88y_81Da8tGf7tC-0i4eMv9ks5r7IQpgaJpZM4I2Cd2>
.
{"from":{"name":"CurisTech Team","email":"no-reply@curistech.com"},"subject":"Email Confirmation","personalizations":[{"to":[{"name":"","email":"admin@whichman.com"}]}],"content":[{"type":"text/plain","value":"CusrisTech.com\r\nReset Password\r\n\r\nDear Ali Baba,\r\n\r\nPlease reset your password by clicking this link: Reset Password\r\n\r\n\r\n\r\n\r\n If you have any questions on the order, please contact CusrisTech.com.\r\n\r\n\r\nRegards,\r\n\r\nSupport Team"},{"type":"text/html","value":"\u003ch4 style=\u0022color:gray;\u0022\u003eCusrisTech.com\u003c/h4\u003e\r\n\u003ch1\u003eReset Password\u003c/h1\u003e\r\n\r\nDear Ali Baba,\r\n\r\n\u003cp\u003ePlease reset your password by clicking this link: \u003ca href=\u0022http://localhost:34861/cmd/reset?token=zTi0noZWQpck8KIWstjuFDgbRlv8bLJINoM0F7hpxjpaj2Ik3weFZ3cniTbMRXE2y8KTGXza5qg=\u0022\u003eReset Password\u003c/a\u003e\r\n\r\n\r\n\r\n\u003cp\u003e\r\n If you have any questions on the order, please contact \u003ca href=\u0022http://localhost:34861/\u0022\u003eCusrisTech.com\u003c/a\u003e.\r\n\u003c/p\u003e\r\n\r\nRegards,\r\n\u003cbr /\u003e\u003cbr /\u003e\r\nSupport Team"}],"mail_settings":{"footer":{"enable":true,"text":"\u003cstrong\u003eCurisTech \u0026copy; 2016\u003c/strong\u003e","html":"CurisTech \u0026copy; 2016"}},"tracking_settings":{"click_tracking":{"enable":true,"enable_text":true}}}
|
The emails are now going throw but the response still doesn't return.
For some reason also, my valid emails are getting dropped (see screen shot
attachment).
Any idea why?
Thanks!
T
…On Thu, May 18, 2017 at 1:58 PM, Tawani Anyangwe ***@***.***> wrote:
Our previous component was the SMTP MailMessage which contained the
"to/from/subject" information. That is why our Conole app was working but
not the web app.
I have updated the code and attached is the latest message.
It seems to have been processed but we still haven't gotten a response yet.
Thanks!
On Thu, May 18, 2017 at 1:47 PM, Elmer Thomas ***@***.***>
wrote:
> Sounds good, please let us know how it goes. Thanks!
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#235 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAOWpWbm_88y_81Da8tGf7tC-0i4eMv9ks5r7IQpgaJpZM4I2Cd2>
> .
>
|
I'm still not seeing any attachment. GitHub must scrub them from emails. |
Sendgrid is still not returning a response even though the email is now
actually being sent.
Please advice!
…On Thu, May 18, 2017 at 2:19 PM, Elmer Thomas ***@***.***> wrote:
@tawani <https://github.com/tawani>,
I'm still not seeing any attachment. GitHub must scrub them from emails.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#235 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOWpV4bPYspmjxHGKLIVepK72_Z4uAbks5r7IuvgaJpZM4I2Cd2>
.
|
Hello @tawani, Unfortunately, I still do not see any attachment. Do you mind uploading to a service like Dropbox? So far, I'm unable to reproduce the issue. Also, we have a new example that might help you. With Best Regards, Elmer |
Hi,
I'm using the example code to send email on MVC web app but it not response on the line dynamic response = sg.client.mail.send.post(requestBody: mail.Get()); even it has been sent successfully. Am I missing something?
Note: the example code work fine on console app only (response after post)
Thanks
The text was updated successfully, but these errors were encountered: