Open Glebby opened 1 month ago
Hi @Glebby, I tried to reproduce this with the following code:
var builder = WebApplication.CreateBuilder(args);
var slackSettings = builder.Configuration.GetSection("Slack").Get<SlackSettings>();
builder.Services.AddSlackNet(c => c
.UseApiToken(slackSettings.ApiToken)
.UseAppLevelToken(slackSettings.AppLevelToken)
.UseSigningSecret(slackSettings.SigningSecret)
.RegisterEventHandler<MessageEvent, SlackEventHandler>()
);
var app = builder.Build();
app.UseSlackNet(c => c.UseSocketMode(true));
app.Run();
record SlackSettings
{
public string ApiToken { get; init; } = string.Empty;
public string AppLevelToken { get; init; } = string.Empty;
public string SigningSecret { get; init; } = string.Empty;
}
public class SlackEventHandler(ISlackApiClient slack) : IEventHandler<MessageEvent>
{
public async Task Handle(MessageEvent slackEvent)
{
try
{
await slack.Chat.PostMessage(new Message { Channel = "C1234567890", Text = "Hello, Slack!" });
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}
While debugging, it did break when the exception was thrown, and the Console.WriteLine
was hit and logged the error.
You might want to check your IDE's debugging settings to make sure it's breaking on all exceptions, and that you haven't enabled Just My Code or an equivalent setting.
Hope this helps.
Hello, I am trying to follow the AspNetCoreExample to post messages in Socket mode, everything works fine except when I am invoking any method, like
and there is an error from Slack (for example channel_not_found), the code withing the event handler doesn't throws an exception, and the debugger doesn't go to the next line, so I cannot check the response. It seems the async call is never completed. The same behavior is with any other method where Slack returns an error (as seen in the console log).
I am using .NET 8.0 console web application, and the bootstrap code in my program.cs looks like
Please advise. Kind Regards Gleb