I'm running Umbraco 8. I have a quite simple scenario:
Umbraco component is subscribed to ContentService.Published action
and have some conditions.
If conditions are true I need to send an email to the user. For
emails, I'm using SendGrid, which is very common in our days.
Sendgrid nuget package provides only async method to send an email.
And it doesn't work when I call it from the ContentPublished event handler.
Moreover, whatever async method I call from the event handler kills
IIS with Async Lock error.
In component initialize I have:
ContentService.Published += OnPublishedPage;
Handler code looks like this:
// async doesn't work here and kills IIS
var response = _emailSender.SendUserDownloadEmailAsync(members, tender).GetAwaiter().GetResult();
Is there any workaround or could you please point me to the right direction?
Interesting. Can you ... try to replace whatever happens in SendUserDownloadEmailAsync by a simple await Task.Delay(100) and see whether it still causes the error?
In which case, the error is narrowed down to the async call. Otherwise, it might have to do with Sendgrid.
Now... do you have details about "the event handler kills IIS with Async Lock error" - is it the entire w3wp process that dies? Where do you see the error? In the Event Log or in Umbraco's log? Can we have the full details on the error?
Suspecting some threading issue with the async call...
Well i have probably the same issue when i was trying to call an async method to post in facebook and twitter walls. Within the Published event when i was calling the async method in order to fire and forget, i didn't want the user to wait when the facebook and twitter posts will be completed, it looks that i had the same problem. And how i realize it? I was trying to get the Url of the published content. Without the async call everything was fine. With the async call, i was getting the IPublishedContent from the umbraco context but when i was trying to retrieve values i was getting null reference exception. Somehow the umbraco context dropped, and it couldn't retrieve the values.
Any suggestions how to resolve it? Fire and Forget like send an email or post to facebook wall are required, it must not make the user to wait until finish.
Following are the pictures when i retrieve the IPublishedContent with the values in the properties (Quick Watch print screen) and then when i try to retrieve the values from code the null reference exception.
Umbraco 8 Component ContentService.Published Async Action Kills IIS
Hi,
I'm running Umbraco 8. I have a quite simple scenario:
In component initialize I have:
Handler code looks like this:
Is there any workaround or could you please point me to the right direction?
Thanks, Alexander.
Interesting. Can you ... try to replace whatever happens in
SendUserDownloadEmailAsync
by a simpleawait Task.Delay(100)
and see whether it still causes the error?In which case, the error is narrowed down to the async call. Otherwise, it might have to do with Sendgrid.
Now... do you have details about "the event handler kills IIS with Async Lock error" - is it the entire w3wp process that dies? Where do you see the error? In the Event Log or in Umbraco's log? Can we have the full details on the error?
Suspecting some threading issue with the async call...
Well i have probably the same issue when i was trying to call an async method to post in facebook and twitter walls. Within the Published event when i was calling the async method in order to fire and forget, i didn't want the user to wait when the facebook and twitter posts will be completed, it looks that i had the same problem. And how i realize it? I was trying to get the Url of the published content. Without the async call everything was fine. With the async call, i was getting the IPublishedContent from the umbraco context but when i was trying to retrieve values i was getting null reference exception. Somehow the umbraco context dropped, and it couldn't retrieve the values.
Any suggestions how to resolve it? Fire and Forget like send an email or post to facebook wall are required, it must not make the user to wait until finish.
Following are the pictures when i retrieve the IPublishedContent with the values in the properties (Quick Watch print screen) and then when i try to retrieve the values from code the null reference exception.
is working on a reply...