Closed JasonSowers closed 6 years ago
Frequency - Every 2-3 hrs. What channels is this happening on, is it working on any channels? -> We are available only on teams and it's happening on teams.
Stack trace -> unauthorized_stacktrace.txt
Deployment where is this happening - Azure
1) 2-3 hours and only one message, following messages would be processed without any issues, can appears in background job logs (perform connector.Conversations.SendToConversation((Activity)message);). 2) Telegram Group Chat 3) StackTrace.txt 4) Azure 5) Web App (Actualy don't understand this question) 6) Disabled right now 7) 2018-06-12 12:57:38.4186 and -230902953
Every 2-5 hours, the first message
Webchat, Facebook
at Microsoft.Bot.Connector.Conversations.d9.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 Microsoft.Bot.Connector.ConversationsExtensions.d9.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 Microsoft.Bot.Builder.Dialogs.Internals.AlwaysSendDirect_BotToUser.d4.MoveNext() in D:\a\1\s\CSharp\Library\Microsoft.Bot.Builder\ConnectorEx\BotToUser.cs:line 124\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 Microsoft.Bot.Builder.Dialogs.Internals.InputHintQueue.d4.MoveNext() in D:\a\1\s\CSharp\Library\Microsoft.Bot.Builder\ConnectorEx\BotToUser.cs:line 184\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 Microsoft.Bot.Builder.Dialogs.Internals.AutoInputHint_BotToUser.d3.MoveNext() in D:\a\1\s\CSharp\Library\Microsoft.Bot.Builder\ConnectorEx\BotToUser.cs:line 146\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 Microsoft.Bot.Builder.Dialogs.Internals.MapToChannelData_BotToUser.d3.MoveNext() in D:\a\1\s\CSharp\Library\Microsoft.Bot.Builder\ConnectorEx\BotToUser.cs:line 295\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 Microsoft.Bot.Builder.Dialogs.Internals.LogBotToUser.d4.MoveNext() in D:\a\1\s\CSharp\Library\Microsoft.Bot.Builder\ConnectorEx\IActivityLogger.cs:line 131\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 Microsoft.Bot.Builder.Dialogs.Internals.DialogContext.d12.MoveNext() in D:\a\1\s\CSharp\Library\Microsoft.Bot.Builder\Dialogs\DialogContext.cs:line 87\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 Microsoft.Bot.Builder.Dialogs.Extensions.d14.MoveNext() in D:\a\1\s\CSharp\Library\Microsoft.Bot.Builder\Dialogs\IDialogContext.cs:line 150\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 Microsoft.Bot.Sample.SimpleEchoBot.EchoDialog.d2.MoveNext() in C:\SW\dotnet\projects\arcofel Messenger\ArcofelMessengerBot-src\Dialogs\EchoDialog.cs:line 38\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 Microsoft.Bot.Builder.Dialogs.Internals.DialogTask.ThunkResume1.
Default Echo bot with CustomPostUnhandledExceptionToUser
@ujwalakhaire @prorok-kane @kevinport Are your bots using the default state service? If not, what state store are they using?
@EricDahlvang now InMemoryDataStore.
@EricDahlvang TableBotDataStore, like the default azure bot template
Hi,
I am using TableBotDataStore but would like to know if global.asax.cs below is right:
using Autofac; using Autofac.Integration.WebApi; using Microsoft.Bot.Builder.Azure; using Microsoft.Bot.Builder.Dialogs.Internals; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Reflection; using System.Web.Http; using Microsoft.Bot.Builder.Dialogs; using Microsoft.Bot.Connector; using Microsoft.WindowsAzure.Storage; using System.Configuration;
namespace botzapprices2018 { public class Global : System.Web.HttpApplication { protected void Application_Start(object sender, EventArgs e) { { var config = GlobalConfiguration.Configuration; Conversation.UpdateContainer( builder => { builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));
var store = new TableBotDataStore(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
builder.Register(c => store)
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
.AsSelf()
.SingleInstance();
// Register your Web API controllers.
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
builder.RegisterWebApiFilterProvider(config);
});
config.DependencyResolver = new AutofacWebApiDependencyResolver(Conversation.Container);
}
// WebApiConfig stuff
GlobalConfiguration.Configure(config =>
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
});
}
public static ILifetimeScope FindContainer()
{
var config = GlobalConfiguration.Configuration;
var resolver = (AutofacWebApiDependencyResolver)config.DependencyResolver;
return resolver.Container;
}
}
}
From the current Azure Template
`using Autofac; using System.Web.Http; using System.Configuration; using System.Reflection; using Microsoft.Bot.Builder.Azure; using Microsoft.Bot.Builder.Dialogs; using Microsoft.Bot.Builder.Dialogs.Internals; using Microsoft.Bot.Connector; using arcofel_UniversalBot.Dialogs;
namespace SimpleEchoBot { public class WebApiApplication : System.Web.HttpApplication { protected void Application_Start() { // Bot Storage: This is a great spot to register the private state storage for your bot. // We provide adapters for Azure Table, CosmosDb, SQL Azure, or you can implement your own! // For samples and documentation, see: https://github.com/Microsoft/BotBuilder-Azure
Conversation.UpdateContainer(
builder =>
{
builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));
// Using Azure Table Storage
var store = new TableBotDataStore(ConfigurationManager.AppSettings["AzureWebJobsStorage"]); // requires Microsoft.BotBuilder.Azure Nuget package
// To use CosmosDb or InMemory storage instead of the default table storage, uncomment the corresponding line below
// var store = new DocumentDbBotDataStore("cosmos db uri", "cosmos db key"); // requires Microsoft.BotBuilder.Azure Nuget package
// var store = new InMemoryDataStore(); // volatile in-memory store
builder.Register(c => store)
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
.AsSelf()
.SingleInstance();
builder
.RegisterType<CustomPostUnhandledExceptionToUser>()
.Keyed<IPostToBot>(typeof(PostUnhandledExceptionToUser));
});
GlobalConfiguration.Configure(WebApiConfig.Register);
}
}
} `
@EricDahlvang We use TableBotDataStore
Hi Kevin,
Thanks for your reply. I have already tried the global.asax.cs from the Azure template and others.
I am using the one from https://github.com/Microsoft/BotBuilder-Azure/blob/master/CSharp/Samples/AzureTable/Global.asax.cs .
May someone tell which one is better ?
Hi, we recently started to get this issue and reported in the msdn forums and after a few replies they mentioned this issue.
Same here. Lib 3.15.2.2
Recently I got an update to the Nuget Packages System.IdentityModel.Tokens.Jwt and Microsoft.IdentityModel.Tokens (version 5.2.4 for both) and in my case the issue seems to be fixed and I don't have the Unauthorized response.
I will keep testing and checking in case something's wrong, but at first it seem resolved.
Hi,
Even with 5.2.4 update it fails.
It was the first time in two days. I use web app, sdk 3.15.2.2, the fail was in Telegram, at 2018-06-27 05:23:34.777, with service url https://telegram.botframework.com and conversation id 371758214. Less than 2 seconds later the bot was able to send a message successfully.
It was the first message I was trying to send to this user in reply to its "/start" message .
Hi,
we are getting this issue as well
Microsoft.Bot.Connector.ErrorResponseException:
at Microsoft.Bot.Connector.Conversations+<ReplyToActivityWithHttpMessagesAsync>d__8.MoveNext (Microsoft.Bot.Connector, Version=3.14.0.7, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at Microsoft.Bot.Connector.ConversationsExtensions+<ReplyToActivityAsync>d__7.MoveNext (Microsoft.Bot.Connector, Version=3.14.0.7, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at ZainOmniBot.Controllers.BotController+<sendReply>d__8.MoveNext (ZainOmniBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullZainOmniBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Users\admin\Desktop\Projects\zain_prototype\ZainOmniBot\Controllers\BotControllers\BotController.csZainOmniBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 312)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at ZainOmniBot.ZainBotController+<Greeting>d__19.MoveNext (ZainOmniBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullZainOmniBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Users\admin\Desktop\Projects\zain_prototype\ZainOmniBot\Controllers\BotControllers\ZainBotController.csZainOmniBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 383)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at ZainOmniBot.ZainBotController+<NonLoggedIn>d__11.MoveNext (ZainOmniBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullZainOmniBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Users\admin\Desktop\Projects\zain_prototype\ZainOmniBot\Controllers\BotControllers\ZainBotController.csZainOmniBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 159)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at ZainOmniBot.Controllers.BotController+<routeActivity>d__7.MoveNext (ZainOmniBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullZainOmniBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Users\admin\Desktop\Projects\zain_prototype\ZainOmniBot\Controllers\BotControllers\BotController.csZainOmniBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 297)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at ZainOmniBot.Controllers.BotController+<Post>d__5.MoveNext (ZainOmniBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullZainOmniBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Users\admin\Desktop\Projects\zain_prototype\ZainOmniBot\Controllers\BotControllers\BotController.csZainOmniBot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 67)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Threading.Tasks.TaskHelpersExtensions+<CastToObject>d__1`1.MoveNext (System.Web.Http, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Web.Http.Controllers.ApiControllerActionInvoker+<InvokeActionAsyncCore>d__1.MoveNext (System.Web.Http, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Web.Http.Filters.ActionFilterAttribute+<CallOnActionExecutedAsync>d__6.MoveNext (System.Web.Http, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Http.Filters.ActionFilterAttribute+<CallOnActionExecutedAsync>d__6.MoveNext (System.Web.Http, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Web.Http.Filters.ActionFilterAttribute+<ExecuteActionFilterAsyncCore>d__5.MoveNext (System.Web.Http, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Web.Http.Controllers.ActionFilterResult+<ExecuteAsync>d__5.MoveNext (System.Web.Http, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Web.Http.Dispatcher.HttpControllerDispatcher+<SendAsync>d__15.MoveNext (System.Web.Http, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
Hi, Can confirm this issue.
Frequency - Randomly. Mostly as soon as a user connects and bot send a greeting message. Out bot is deployed on directline channel. The bot is using Table storage for state service.
var store = new TableBotDataStore(ConfigurationManager.ConnectionStrings["StateStorageConnectionString"].ConnectionString);
// Register bot data store to enable state management using database
builder.Register(c => store)
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
.AsSelf()
.SingleInstance();
builder.Register(c => new CachingBotDataStore(store,
CachingBotDataStoreConsistencyPolicy.LastWriteWins))
.As<IBotDataStore<BotData>>()
.AsSelf()
.InstancePerLifetimeScope();
Some conversation id and timestamps :
Conversation ID | Timestamps |
---|---|
CAQe8wxkmtmAWdfshvwzYS | 2018-06-27T00:44:57.6233173+00:00 |
7KUUlIOqur3tYzBZXr34S | 2018-06-26T01:54:10.118322+00:00 |
CKhvy5zMKmqCD9pI4g6sjF | 2018-06-26T08:06:04.5426479+00:00 |
HPEw084s3j1A3ER61hKOoy | 2018-06-25T18:06:15.8236009+00:00 |
Stack trace of 1 of the id can be found at this pastebin url
@ujwalakhaire @prorok-kane @kevinport @JonesAbramoff @NioZero @BenAffleckIsBatman @Lepird @Kartik1607 We have released a new package 3.15.2.3 that we believe addresses this issue. Please let us know if you are still experiencing this issue after upgrading.
Hi,
I updated all nuget packages and got the same error.
Channel: Slack service URL: https://slack.botframework.com Conversation ID: BBFSMK2LA:TBGJN8ZHC:DBFPQMFKM Time: 2018-06-28 16:34:15.023 UTC−03:00
It was the first message.
I am using Global.asax.cs from https://github.com/Microsoft/BotBuilder-Azure/blob/master/CSharp/Samples/AzureTable/Global.asax.cs as posted earlier above.
Would you recommend to change it ?
@JonesAbramoff have you only seen this on the first message? I notice you said this was the case on 2 posts in this thread. If this is the case, what you are seeing might be unrelated and will need to be investigated separately.
Hi Jason,
I don´t know if my global.asax.cs is related to the unauthorized problem. It was just my guess.
It fails only a few times and almost always in my welcome (first) message.
It happened again:
Channel: Telegram Service URL: https://telegram.botframework.com Conversation Id: 446555179 Time: 2018-06-29 01:03:17.657 UTC−03:00
It was responding to /start with a new contact using the function SelecionaPais2. In its catch code I call SelecionaPais3 that works.
public static async Task<string> SelecionaPais2(Activity activity)
{
try
{
// Use the data stored previously to create the required objects.
var userAccount = new ChannelAccount(activity.From.Id, activity.From.Name);
var botAccount = new ChannelAccount(activity.Recipient.Id, activity.Recipient.Name);
ConnectorClient connector = ConnectorClient_Obter(activity.ServiceUrl);
// Create a new message.
IMessageActivity message = Activity.CreateMessageActivity();
message.ServiceUrl = activity.ServiceUrl;
message.ChannelId = activity.ChannelId;
string IdConversa = "";
if (string.IsNullOrEmpty(activity.Conversation.Id))
{
// Conversation ID was not stored previously, so create a conversation.
// Note: If the user has an existing conversation in a channel, this will likely create a new conversation window.
IdConversa = (await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount)).Id;
}
else
{
IdConversa = activity.Conversation.Id;
}
SelecionaPais_Preenche_Msg(message);
// Set the address-related properties in the message and send the message.
message.From = botAccount;
message.Recipient = userAccount;
message.Conversation = new ConversationAccount(id: IdConversa);
message.Locale = "pt-BR";
await connector.Conversations.SendToConversationAsync((Activity)message);
Utils.Log_Grava("sucesso em SelecionaPais2");
}
catch (Exception ex)
{
Utils.Log_Grava($"SelecionaPais2 Failed with message: {ex.Message}");
await SelecionaPais3(activity.ChannelId,activity.ServiceUrl, activity.From.Id, activity.From.Name, activity.Recipient.Id, activity.Recipient.Name);
}
return ("");
}
public static async Task<string> SelecionaPais3(string IDCanal, string ServiceURL, string IdUsuario, string NomeUsuario, string IdBot, string NomeBot)
{
try
{
// Use the data stored previously to create the required objects.
var userAccount = new ChannelAccount(IdUsuario, NomeUsuario);
var botAccount = new ChannelAccount(IdBot, NomeBot);
ConnectorClient connector = ConnectorClient_Obter(ServiceURL);
// Create a new message.
IMessageActivity message = Activity.CreateMessageActivity();
message.ChannelId = IDCanal;
message.ServiceUrl = ServiceURL;
// Conversation ID was not stored previously, so create a conversation.
// Note: If the user has an existing conversation in a channel, this will likely create a new conversation window.
string IdConversa = (await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount)).Id;
SelecionaPais_Preenche_Msg(message);
// Set the address-related properties in the message and send the message.
message.From = botAccount;
message.Recipient = userAccount;
message.Conversation = new ConversationAccount(id: IdConversa);
message.Locale = "pt-BR";
await connector.Conversations.SendToConversationAsync((Activity)message);
Utils.Log_Grava("sucesso em SelecionaPais3");
}
catch (Exception ex)
{
Utils.Log_Grava($"SelecionaPais3 Failed with message: {ex.Message}");
}
return ("");
}
public static void SelecionaPais_Preenche_Msg(IMessageActivity message)
{
try
{
message.Text = "Welcome! I am a bot that compares prices among stores!";
message.Attachments.Add(
new HeroCard
{
Subtitle = "Please select a country:",
Buttons = new List<CardAction> {
new CardAction(ActionTypes.ImBack, $"Australia", value: $"AU", text: $"Australia", displayText: $"Australia"),
new CardAction(ActionTypes.ImBack, $"Brasil", value: $"BR", text: $"Brasil", displayText: $"Brasil"),
new CardAction(ActionTypes.ImBack, $"Canada", value: $"CA", text: $"Canada", displayText: $"Canada"),
new CardAction(ActionTypes.ImBack, $"Deutschland", value: $"DE", text: $"Deutschland", displayText: $"Deutschland"),
new CardAction(ActionTypes.ImBack, $"España", value: $"ES", text: $"España", displayText: $"España"),
new CardAction(ActionTypes.ImBack, $"France", value: $"FR", text: $"France", displayText: $"France"),
new CardAction(ActionTypes.ImBack, $"India", value: $"IN", text: $"India", displayText: $"India"),
new CardAction(ActionTypes.ImBack, $"Italia", value: $"IT", text: $"Italia", displayText: $"Italia"),
new CardAction(ActionTypes.ImBack, $"México", value: $"MX", text: $"México", displayText: $"México"),
new CardAction(ActionTypes.ImBack, $"Nederland", value: $"NL", text: $"Nederland", displayText: $"Nederland"),
new CardAction(ActionTypes.ImBack, $"United Kingdom", value: $"GB", text: $"United Kingdom", displayText: $"United Kingdom"),
new CardAction(ActionTypes.ImBack, $"United States", value: $"US", text: $"United States", displayText: $"United States"),
new CardAction(ActionTypes.ImBack, $"Россия (Russia)", value: $"RU", text: $"Россия (Russia)", displayText: $"Россия (Russia)"),
}
}.ToAttachment()
);
}
catch (Exception ex)
{
Utils.Log_Grava($"SelecionaPais_Preenche_Msg Failed with message: {ex.Message}");
}
}
You all may want to hold off on upgrading we will have another new version dropping soon. 3.15.3
Same error with 3.15.3. Always in proactive message that called a second later works fine. I will change my code to retry when fails.
@JonesAbramoff will you start a new issue detailing your issue. It seems yours is not related to the fix we recently put in. I would like to track it separately from this issue so we can look into it.
I am going to leave this issue open for this week to monitor any other reports.
Although frequency has decreased but the issue still exists in the updated code. Occurred 5 times in past 3 days. Only occurring after the first greeting message sent by bot.
Conversation ID | Timestamps |
---|---|
HZCFg6owRc8FDBGlvlOpqi | 2018-06-30T10:54:04.6611466+00:00 |
2kbLKBZ83QPLbqr8iAF1h1 | 2018-06-30T23:13:55.0952924+00:00 |
1D0diPwsKoXMjvR89iqeu | 2018-07-01T13:05:13.5875871+00:00 |
CycJsRiEzAR2NPwgu3V3v1 | 2018-07-02T18:48:07.8127725+00:00 |
9zvkjcwLTZaE1buVViJ58E | 2018-07-02T20:17:07.4171416+00:00 |
The exceptions occur when the bot had been idle for a long period like for 2-3 hours.
The same problem for our app.
Thanks in advance for your support Alex
Thanks for reporting your results all, we will continue to look into this.
Looks like you are not alone here @JonesAbramoff
Hi Jason,
This problem has been around since March 15 in issue 4321 and I would like to contribute to solve it as I can. I can privately send you my source code or change it to include whatever debugging code you ask.
Right now all my messages to the user have a retry to be used when the first attempt fails.
Best regards,
Jones
Hi, experienced the same.
Bot Info SDK Platform: C# SDK Version: 3.12.2.4 Active Channels: Web chat, FB Deployment Environment: On-Premise
Frequency - Happen on all the messages. Never success on sending out one. Stack trace - There was an error sending this message to your bot: HTTP status code Unauthorized Deployment where is this happening - On prem, local testing is fine. State Service: Default state service
Issue Description: Found bot no response from FB recently. Last working response received was in June 2018. Tried to troubleshoot by testing bot in Azure web chat, the message couldnt send. Web Chat issue logged: There was an error sending this message to your bot: HTTP status code Unauthorized. However with the same code, the bot is functional when using emulator.
Code Example In web.config, set microsoftappid, microsoftapppassword:
add key="MicrosoftAppId" value="0f5b4ab2-800a-4447-bfe7-c89ad9d90719" add key="MicrosoftAppPassword" value="xxxxxxxx"
In Message controller:
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Message)
{
var connector = new ConnectorClient(new Uri(activity.ServiceUrl));
Activity isTypingReply = activity.CreateReply();
isTypingReply.Type = ActivityTypes.Typing;
await connector.Conversations.ReplyToActivityAsync(isTypingReply);
await Conversation.SendAsync(activity, () => new Dialogs.ExceptionHandlerDialog<object>(
new Dialogs.RootDialog()
));
}
else
{
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
Reproduction Steps https://www.facebook.com/messages/t/mayabotdemo, try talk to the bot. Please advise if the way if the team wants to test out the azure web chat.
Expected Behavior The bot will able to respond after received user's reply.
Actual Results The bot does not reply now due to error logged in azure. There was an error sending this message to your bot: HTTP status code Unauthorized.
@JonesAbramoff if you think you have a fix please submit a pull request. If you do not want to submit one you can send the code to the email in my profile.
Sorry, I have no fix to suggest. I am only using a very ugly retry code to live with this failures.
@huyjack178 has provided an interesting workaround to avoid this error here: https://github.com/Microsoft/BotBuilder/issues/4322#issuecomment-405528802
@huyjack178 thank you for mentioning that post, but what if the bot is hosted as Azure web app and it is being consumed by webchat, or directline channels? Is there any hint on how i could update the connector token?
@asfyra There is example code here: https://blog.botframework.com/2017/11/02/optimizing-latency-bot-framework/ demonstrating how to add code for periodically refreshing the token.
We upgraded to latest version of bot builder SDK (3.15.3) and we see this issue lot less frequently now.
@ujwalakhaire We are also on the latest version (3.15.3) but the issue remains. Just leave the bot inactive for a couple of hours and the error returns :cry:
This bug should have the highest priority.
We are actively looking into this.
Me Too
I meet the same problem when I use Keyvault to store my ids and keys.
I have to be tortured crazy recently.
SDK Platform: .Net
【Frequency】: After one hour I deploy, it responds nothing. Every message. No matter what I send to Bot, it responds nothing.
【Channel】: MS Teams. Web chat is ok. Or sometimes Web chat exists this problem suddenly, but it recovers quickly.
【Deployment】: Locally git to Azure
【Type of bot Functions bot】: Web App Bot. (QnA surely has this problem, LUIS maybe(I am testing))
【Is there any relevant info in app insights】: I don't know know how to see app insights about MS Teams in Azure. I get this exception just in Web chat's app insights by chance.
【Details】: { "message": "An error has occurred.", "exceptionMessage": "Operation returned an invalid status code 'Unauthorized'", "exceptionType": "Microsoft.Bot.Connector.ErrorResponseException",
"stackTrace": " at Microsoft.Bot.Connector.Conversations.
This is happening for my bot as well, details:
1) Frequency - Roughly once every 24 hours, usually between 10:00 and 10:30 UTC (which, as others have commented, is usually after a longer period of inactivity for our bot) 2) Channel - Direct Line. We're only on this channel so I can't speak to other ones. 3) Stack trace:
Operation returned an invalid status code 'Unauthorized'
**************************************************
StatusCode=401
ReasonPhrase=Unauthorized
Request=Microsoft.Rest.HttpRequestMessageWrapper
Response=Microsoft.Rest.HttpResponseMessageWrapper
TargetSite=Void MoveNext()
Source=Microsoft.Bot.Connector
HResult=-2146233088
StackTrace
**************************************************
at Microsoft.Bot.Connector.Conversations.<SendToConversationWithHttpMessagesAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Connector.ConversationsExtensions.<SendToConversationAsync>d__5.MoveNext()
4) Deployment - Customized container orchestration service (hosted in Azure East US 2) 5) Bot type - Self hosted 6) No relevant info in App Insights. One or two requests fail to authorize, and all subsequent requests succeed for approximately the next 24 hours. 7) Some conversation ID (directline) / timestamp (UTC) pairs:
Rt7tQfIk8e6wPhDyWYPzr / 2018-07-30 10:15:24.4937
18XZnA6tIWb435j6DxkJRZ / 2018-07-28 10:27:01.8811
HkJ3HIQZMP87rN6BZM9pXL / 2018-07-27 13:34:12.1247
AgrLyhLJUPtEHJ7za2haPQ / 2018-07-26 10:09:22.2380
kUkM3l6ihH5MX0Jn5ziy / 2018-07-25 10:01:47.4448
8) We use the DocumentDbBotDataStore implementation of IBotDataStore
for state storage in CosmosDB.
Hi, I'm facing this issue to. It happens randomly like once a day after longer bot inactivity. I updated to latest version of bot builder SDK (3.15.3)
Hi, I'm facing this issue to. I updated to latest version of bot builder SDK (3.15.3):
I am experiencing the problem with :
Microsoft.Bot.Schema.BotTimeoutException: POST to MyMangosteenBotReg timed out after 15s
at Microsoft.Bot.ChannelConnector.BotAPI+
I am using the latest Bot.builder SDK 3.15.3
It happens periodically and it seems to happen after a user is inactive but it happens at different time periods. Other users can be using the bot and not experience the issue.
In order to clear it, I have to stop and restart the app.
I am using the Facebook Channel exclusively other than testing.
I am in a pickle here because I assured my bosses that it was a good thing to build on top of the Microsoft infrastructure. We are trying to launch a new product using the bot this week. Please help.
Hi, I'm using bot within following scenario:
When bot is idle e.g. for a couple of hours I sometimes get Unauthorized exception when bot is trying to reply.
I'm tried following workaround which seems that fixes the issue:
call GetTokenAsync()
on MicrosoftAppCredentials
of your bot just before reply
if (string.Equals("initConversationEvent", message.Name, StringComparison.OrdinalIgnoreCase))
{
// possible workaround to avoid occasional 401 http errors when replying back to user, see https://github.com/Microsoft/BotBuilder/issues/4733
await _botRegistrationAppCredentials.GetTokenAsync();
await ReplyWithWelcomeMessageAsync(message);
}
I have some good news, we have a release that should address this issue coming out soon. If you would like to test it you can try the build on our MyGet daily build feed
@aymandaqa your problem seems to be unrelated, can you please open a new issue and share the code from your messages controller.
I had the same issues mentioned in this thread. The bot wouldn't work when authentication is turned on and gave me 401 errors. Now I have upgraded to the new 3.16 bot builder update and I get following compile time errors CS1705 Assembly 'Microsoft.Bot.Builder' with identity 'Microsoft.Bot.Builder, Version=3.16.0.37658, Culture=neutral, PublicKeyToken=xxxx' uses 'Microsoft.Bot.Connector, Version=3.16.0.37658, Culture=neutral, PublicKeyToken=xxxx' which has a higher version than referenced assembly 'Microsoft.Bot.Connector' with identity 'Microsoft.Bot.Connector, Version=3.15.3.0, Culture=neutral, PublicKeyToken=yyy' VendorDetailsBotApplicationWithLUIS
What gives?
@ani-sm somehow the versions got out of sync. if you upgrade your packages using these commands for bot.builder and bot.connector the packages should install correctly. I just tested it and was able to successfully build. Basically the solution is to install the 3.16.0.37621
versions of both. We will get this sorted out moving forward.
Microsoft.Bot.Builder
:
Install-Package Microsoft.Bot.Builder -Version 3.16.0.37621 -Source https://botbuilder.myget.org/F/botbuilder-v3-dotnet-daily/api/v3/index.json
Microsoft.Bot.Connector
:
Install-Package Microsoft.Bot.Connector -Version 3.16.0.37621 -Source https://botbuilder.myget.org/F/botbuilder-v3-dotnet-daily/api/v3/index.json
A couple updates... @JasonSowers Thanks.. that helped... I did get some compile errors but now I able to test the bot in the emulator with authentication turned on. I have deployed it to Azure and with all settings in place I'm getting "Sorry, my bot code is having an issue." errors. When I debugg it with ngrok I see some messages due to using default state. Since using default state is not allowed in production, could this be the case for the error above? Or can it be still related to the Bot authentication ?
Diving Deep...will provide more updates when I surface!
It's hard to say without seeing your code @ani-sm. "Sorry, my bot code is having an issue." is a catch-all error that doesn't provide much information. A stack trace or some code where the error is occurring may help to diagnose.
Bot Info
If you are experiencing this issue please post the following details, do not just post "Me too" with no details
if not locally
Type of bot Functions bot? Web App bot?
Is there any relevant info in app insights?
Timestamp and conversation ID when this occurs?
Is the bot using the default state service? What state store is the bot using?