There was an error sending this message to your bot: HTTP status code GatewayTimeout
Bot Info
- SDK Platform: .NET
- SDK Version: 3.14.1.1
- Active Channels: Skype, MS Teams, Direct Line, Skype for Business
- Deployment Environment: Azure Web App and Bot Channels Registration
Issue Description
I have a chatbot in production, and yesterday I've had some issues regarding exceptions being thrown within the chatbot, resulting in the "Sorry my bot code is having an issue" message.
Weirdly the chatbot provides the correct response to the user, however after the expected activity the user get's the "Sorry my bot code is having an issue".
I've got the error bot on Skype for Business and DirectLine (via WebChat):

When I open the Skype for Business log I see the following error messages:

When I go to the Application Insights of this bot I see the following exceptions were raised:

As you can see the Microsoft.Bot.Schema.BotTimeoutException was raised a bunch of times.
If I inspect this exception within the Application Insights I can see this information:

Here's the call stack:
Microsoft.Bot.Schema.BotTimeoutException: at Microsoft.Bot.ChannelConector.BotAPI+
d__30.MoveNext (Microsoft.Bot.ChannelConnector, Version=3.2.1.0, Culture=neutral, PublicKeyToken=null)
From what I was able to gather this happens when the bot takes more than 15 seconds to provide a response to the bot connector. However sometimes the bot gives us the expected reply within something like 3 seconds, and we still get this exception.
This is the chatbot Microsoft App Id: 2eb9dadb-2d6f-4cea-a6e0-8cce748722ab
I'm not sure if I can post the bot handler publicly, as it contains the name of our client. But If needed I can provide it to someone via email.
You can send me your code at the email listed in my profile, this is not going to be enough information to diagnose anything.
@ItsMeArthur If you sent me anything I did not get it, can you resend?
@JasonSowers Just mailed you the source code. Sorry for taking so long, but I had to get the proper permission from my managers. Thank you very much for looking into this.
@ItsMeArthur I did not receive anything, I will make a private repo and invite you to it so you can drop the code in there instead. I'll give you full access to delete it at any time.
Hi @JasonSowers. Weird, just added the files on the repo you've created.
Thanks, i will take a look as soon as i get a chance
@ItsMeArthur I was able to use your bot in webchat and I was not able to see the behavior you are describing. This exception occurs when the bot takes longer than 15 seconds to respond. I see you are making some API calls and have other processes that are adding to the time to respond. It doesn't seem like anything you are doing in your code should make the response time > 15 seconds so I wonder... Is there any chance when you noticed this happening there was just slowness on your network, or maybe even reaching Azure? Is this consistently happening or did it just happen in a small time period?
Hi @JasonSowers.
Is this consistently happening or did it just happen in a small time period?
This exception it's kind of random, it happens in a kind of intermittent manner. When compared to the total amount of messages exchanged between users and bot the number is low, but high enough to bother some users and my clients want it gone.
I see you are making some API calls and have other processes that are adding to the time to respond.
In the code I've shared with you we get the reply to the user from an external service. I'm using Application Insights to monitor response times and the response time rarely exceeds one second, and when it does it's by little.
Is there any chance when you noticed this happening there was just slowness on your network, or maybe even reaching Azure?
This happens sometimes when I'm using our corporate network, which is really good, and also when using my 4G mobile connection, which is also not bad. I've tried to use a really robust Web App with a lot of RAM and also using CosmosDB to store state data. The problem still happens sometimes (again, enough to bother some users and clients).
This issue was brought up yesterday by other people in a WhatsApp chatbot developers group I'm part of, and many people were facing the same issue. When this happens the bot gives an "Sorry, my bot code is having an issue" to the users. Some people have stopped trying to figure out the problem and are now just trying to suppress the exception message, which I'm not sure it's something we should be doing, but we have bots in production and wee need to find a way around this issue.
I've tried to send a lot of messages to a simple bot (not even using LUIS) made from the standard template from the Bot Framework V3 and the issue has happened. So we're really at loss here.
I have the same exactly problem.
Which data centers are your bots deployed to? I'm wondering if you are both in the same data center(s). This is strange that many people are claiming to see this. Most of my days are spent tinkering with and testing bots and I am not seeing it at all.
How often are you seeing this? When you do see it does it seem to happen in clusters or is it truly random?
I do experience the exact same problem.
The published bot is located at Azure/West Europe. It does seem to be random, but in clusters. Today has been critical.
I rarely experience it with my local emulator.
| Time | Message |
|---|---|
| 6/14/2018, 11:49:15 AM | There was an error sending this message to your bot: HTTP status code GatewayTimeout |
| 6/14/2018, 11:47:35 AM | There was an error sending this message to your bot: HTTP status code GatewayTimeout |
| 6/14/2018, 11:47:28 AM | There was an error sending this message to your bot: HTTP status code GatewayTimeout |
| 6/14/2018, 11:46:43 AM | There was an error sending this message to your bot: HTTP status code GatewayTimeout |
| 6/14/2018, 11:31:09 AM | There was an error sending this message to your bot: HTTP status code GatewayTimeout |
| ... | ... |
If you guys found a way to get around or somehow mitigate the issue, please let me know.
@JasonSowers Sorry for the delayed answer. I always deploy my chatbots either to Central US or South Central US, and I had the problem occur in bot regions.
I am also having the same error occuring randomly. It's a Q&A bot that makes async http posts on an external site to get the answers. The bot is hosted on azure and i use CosmosDB for the bot state. There are days that the error is more frequent than others.
Thank you
I upgraded to the most recent version of the NuGet packages (not preview). This seems to mitigate the issue, hence I haven't been able to replicate the error yet.
@nrishoj I use .NET version of the bot builder and i am on the latest version. Maybe the next .net version deals with this problem.
I use .NET version of the bot builder and i am on the latest version. Maybe the next .net version deals with this problem.
OK - Same for me.
Thank you all for reporting the behavior and keeping us updated, please continue to do so. We will continue to monitor the applications we are testing and using to see if I can find a reproduction and root cause.
There was a new bot.builder package released today 3.15.2.3 I'm not exactly sure what changes were including as I just came back from being out of the country. I would like to suggest you try it out and see if this still persists. I know there was a 401 issue addressed and there is a chance you could be seeing the same issue, it is just masked under some error that was causing the timeouts.
Has anyone been able to test with the new packages and see if that helped?
SDK Platform: .NET SDK Version: 3.15.3 Active Channels: Direct Line, WebChat Deployment Environment: Azure App Service and Web App Bot State: Cosmos DB
I am on the latest version of the packages and today i had three issues. One almost every one hour.
timestamp [UTC]: 2018-07-03T11:13:13.397Z ConversationID: 9oTcIXJjCpZI57rGB6rw0f
Microsoft.Bot.Schema.BotTimeoutException at Microsoft.Bot.ChannelConnector.BotAPI+<PostActivityToBotAsync>d__30.MoveNext
[{
"parsedStack": [{
"assembly": "Microsoft.Bot.ChannelConnector, Version=3.2.2.1, Culture=neutral, PublicKeyToken=null",
"method": "Microsoft.Bot.ChannelConnector.BotAPI+<PostActivityToBotAsync>d__30.MoveNext",
"level": 0,
"line": 0
}],
"outerId": "0",
"message": "POST to piraeusbot timed out after 15s",
"type": "Microsoft.Bot.Schema.BotTimeoutException",
"id": "5076890"
}]