mrb0nj / Slack.Webhooks

Even simpler integration with Slack's Incoming and Outgoing webhooks
MIT License
173 stars 53 forks source link

Post does not return #81

Closed DarthSonic closed 4 years ago

DarthSonic commented 4 years ago

This is our code:

public static void SendBackendNotification(string channel, string username, string actiontext, string emoji)
        {
            var slackClient = new SlackClient(ConfigurationManager.AppSettings["SLACK_WEBHOOK_URL_CM_NOTIFICATIONS_NEW"]);
            var slackMessage = new SlackMessage
            {
                Channel = channel,
                Username = username,
                Text = actiontext,
                IconEmoji = emoji
            };
            try
            {
                slackClient.Post(slackMessage);
            }
            catch (Exception slackException)
            {
                AiLogger.Log(slackException, new HttpContextWrapper(HttpContext.Current), false, false);
            }
        }

slackClient.Post(slackMessage); does not return to code and does not throw exception. It sends the message but request is pending until timeout occurs (ASP.NET MVC) or we end the application.

With release version 1.0.6 it works, with 1.1.0 or later it does not work.

How can we fix that?

Regards, Sven

mrb0nj commented 4 years ago

Hey Sven, apologies for this - Sounds very much like an issue we had way back regarding mixing blocking/async calls which resulted in setting .ConfigureAwait(false) on the HttpClient calls. This was then discussed in Issue #60

I've pushed a potential fix for this which you could try out here: https://github.com/mrb0nj/Slack.Webhooks/packages/42275 and let me know if this resolves your issue?

DarthSonic commented 4 years ago

Thx, that works!

mrb0nj commented 4 years ago

New build up on NuGet!