[Question] Error: "Sorry my bot code has an issue" - on sending messages to the bot at the same time from different instances
System Information (Required)
- SDK Language: .NET
- SDK Version: 3.8.4
- Development Environment: Azure App Service and DirectLine
Bot Info
-
Bot name: ProgMngmentBotPOC
-
Bot handle: progmntbotpoc
-
App ID: bbc75279-a183-4bb3-a148-b9faee0bcac9
-
Connected channels: Directline
Issue Description
I have hosted my chatbot inside a webapp via DirectLine. Whenever I am trying to run two different instance of this webapp on same or different browser I get "Sorry my bot code has a issue". It happens only when I try to send messages to both the bots at the same time. I also have noticed that the error message appears on the bot which was 2nd in sending the request. For Eg : BotA and BotB running at the same time. I send message to BotA and quickly send a message to BotB. Both will process the request and display the result, but "Sorry my bot code has a issue" will appear only on 'BotB' sent after BotA. There is no way I can debug this exception. It does not appear in any of the catch blocks in bot. The only log we have is the following :
directline.botframework.com/v3/directline/conversations/A9pzYz8BfNfHl2hXTLdyon/activities:1 POST https://directline.botframework.com/v3/directline/conversations/A9pzYz8BfNfHl2hXTLdyon/activities 502 (Bad Gateway)
{error: {code: "ServiceError", message: "Failed to send activity: bot returned an error"}} error:{code: "ServiceError", message: "Failed to send activity: bot returned an error"} code:"ServiceError" message:"Failed to send activity: bot returned an error" The bot dashboard reports the error as There was an error sending this message to your bot: HTTP status code InternalServerError
Its very difficult to figure out the reason based on these few error messages. What could be the reason for this error? Any way where I can debug this internal error message "Sorry my bot code has an issue" and get the full stacktrace? Any help or pointers will be highly appreciated.
Steps to Reproduce the Issue
1.Run the web app in two different instance and send the message at the same time to the bot. 2. It throws "Sorry my bot code has an issue" message in second bot. 3.The execution of the bot continues smoothless despite the error message.
Expected Behavior
Smooth execution without "Sorry my bot code has an issue" message.
Actual Results
Any feedback on this from community? Has anyone faced the same issue ?
@PreranaPolekar Please post the webchat code you are using on your website.
I you want to have multiple webchat instances, try configuring the WebChat channel and add multiple site configurations there. This way, each iFrame will have a unique key so the bot/user messages won't clash.
Example multiple site definitions in WebChat channel config:

@PreranaPolekar Were you able to solve the issue by setting up multiple Web Chat site configurations? Let me know if you have additional questions.
Hi @nwhitmont, Sorry for delay in response. Please correct me if I am wrong, does it mean for every new user I need to have new site inside my WebChat configuration? If so, then technically that won't be feasible. I am targeting around 1k users might use my app at the same time.
@nwhitmont any suggestion?
Hoping that issue has been resolved, closing it. Feel free to reopen if any questions.
Nope the issue was not resolved :(
Hi @PreranaPolekar did you able to resolved your problem now? . i also have same problem help me
Hi, I'm having similar issue. At start it runs smoothly but after a couple of test from a few people it started to show bot is having an issue.
@PreranaPolekar @Suneethae7 @nitecloack Multiple connections to the Direct Line from different users should not be causing issues. The Microsoft Bot Framework has a multitude of bots doing this on a daily basis, without this issue.
Would one of you please share your bot code, so we can help determine what the issue is exactly?
@EricDahlvang Exactly! It should be able to handle thousands of users at the same time. Sorry I didn't understand but exactly which part of code you require as I am not sure the root cause of the issue ? Do mean to say the bot ID and password ?
If you can debug this locally, you should be able to get a stack trace or obtain more information about the error. This blog post discusses how to debug any channel locally using ngrok: https://blog.botframework.com/2017/10/19/debug-channel-locally-using-ngrok/
Application Insights would also provide more detail, with stack traces for errors between the connector service and the bot: https://docs.microsoft.com/en-us/bot-framework/resources-app-insights-keys
If you are able to provide us with a simplified code example, it would be useful for us to help diagnose the issue further. (note: secrets and passwords should always be kept private, or someone could impersonate the bot).
reopen if you're still having issues
Thanks @EricDahlvang .Sorry for delay in reply, was switched to another project. Currently I am not able to work on this but will get back if the issue persists. Thanks again guys :) Happy New Year, Happy Coding :)
If anybody experience this issue in the future, i was able to resolve by specifying unique id for user as following.
BotChat.App({ bot: { id: '{{Chat_Bot_Id}}' }, botConnection: botConnection, user: { id: {{Any_Unique_ID}} }, resize: 'detect', locale: 'en-en' }, document.getElementById('bot'));