500 Internal Server Error in emulator - V3
I've recently upgraded my bot to the new V3 bot framework, and since then I've been getting 500 InternalServerErrors in the emulator and the "sorry, the bot is having trouble responding" messages in Slack, breakpoints anywhere in the method below don't get triggered at all so I can't really get a stack trace.
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Message)
{
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
// return our reply to the user
Activity reply = activity.CreateReply("hello world");
await connector.Conversations.ReplyToActivityAsync(reply);
}
else
{
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
This code is the default VS template code, with the correct Web.config settings.
Below is what appears in the log when testing the connection to the bot:
InternalServerError
{
"message": "An error has occurred.",
"exceptionMessage": "Could not load type 'System.IdentityModel.Tokens.TokenValidationParameters' from assembly 'System.IdentityModel.Tokens.Jwt, Version=5.0.0.127, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.",
"exceptionType": "System.TypeLoadException",
"stackTrace": " at Microsoft.Bot.Connector.BotAuthentication.<OnAuthorizationAsync>d__16.MoveNext()\r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)\r\n at Microsoft.Bot.Connector.BotAuthentication.OnAuthorizationAsync(HttpActionContext actionContext, CancellationToken cancellationToken)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}
Hi,
I had another problem: the NewtonSoft assembly was at version 9.x . Fixed that, redeployed, and now it seems to be working, error 500 is gone. I still have a compilation warning:
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
... but whatever this is, the bot seems to be working now.
(and I did remove the redirect from web.config)
I can confirm that if you accidentally upgrade your nugget packages, you will have to downgrade the packages and update the dependencies in the web.config file. I used TheMakerBotShow example to compare my project and everything worked find after updating.
Looking at the most recent reports on this thread, the latest outstanding issues related to assembly bindings. Are there any open runtime issues still present in your code?
I am closing this issue assuming that the improvements in auth reliability and exception translation released in nuget 3.1 addresses all of the issues in this thread.
Hello All,
I am facing the same issue like 500 internal server error. I changed the code to version 3. Please help me out
@nitk-rashid attach a debugger to your bot and see what exception is getting thrown by the bot when it receives the message.
One weird trick to get your bot to work in development: Run it with the debugger attached. It seems the BotAuthentication filter attribute will return early if MicrosoftAppId is empty, but only when debugger is attached. See line 27.
https://docs.botframework.com/en-us/csharp/builder/sdkreference/d0/d3b/_bot_authentication_8cs_source.html
I'm getting this now, and unable to hit a breakpoint. Are these dependencies still needing to be from versions earlier this year?
Maybe it's about changing the scope of your methods in the messagescontroller from "public" to "private".
This framework was too unstable and the docs not clear enough so I stopped using it. (That and the requirement to publish it - not OK for on premise connectivity)
i create my bot using bot builder framework in asp.net .Bot work fine in emulator but give me error when i try to connect it with skype ...
"Your bot did not respond to our Ping request with a success code. Please verify your bot is running and responsive before Publishing your bot. The error received from your bot was: Unauthorized(401), BotAuthenticator failed to authenticate incoming request!"
please help me !!
@UsamaAslam - You should check existing open and closed issues for "401" errors (there are many that have been closed) or open a new issue for that. This thread is for 500 errors.
@stingyJack - sorry to disturb you but i already open new thread and i receive no response so that is why i post here . if you know any thing please inform me i will be very thankful to you
@usamaalam - If none of the existing closed "401" issues matched your problem (not likely - a similar error message present is in several), you will just have to wait for the maintainer of this module to reply back.