botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Exception when sending messages in short intervals to LuisDialog

Open ThisWillDoIt opened this issue 10 years ago • 12 comments

Some internals crash when sending messages in fast succession to a LuisDialog.

I tried it with an "empty" LuisDialog. Works fine when the messages are send with some time inbetween. (copying a sentence and doing crtl + v --> enter 4 times in a row always triggers this error at least once in all my tests)

public class TestDialog : LuisDialog<object>
{
    [LuisIntent("")]
    public async Task None(IDialogContext context, LuisResult result)
    {
        context.Wait(MessageReceived);
    }
}

I think the Bot might have problems with messing up the bot state and can't persist it properly.

Full exception: http://pastebin.com/fX3JcQ6F

ThisWillDoIt avatar Nov 23 '16 15:11 ThisWillDoIt

Here is some more information about 412/409:

https://docs.botframework.com/en-us/technical-faq/#what-causes-precondition-failed-412-or-conflict-409-http-errors https://docs.botframework.com/en-us/technical-faq/#how-can-i-fix-precondition-failed-412-or-conflict-409-http-errors

and here is some more background:

https://docs.botframework.com/en-us/technical-faq/#where-is-conversation-state-stored https://docs.botframework.com/en-us/technical-faq/#what-is-an-etag--how-does-it-relate-to-bot-data-bag-storage

I'm happy to answer further questions.

willportnoy avatar Nov 26 '16 02:11 willportnoy

Okay, interesting to know that C# and Node take different approaches. Changing my C# code to use the Node way works fine for me.

Sorry for missing that part of the docu and opening an issue...

ThisWillDoIt avatar Nov 30 '16 10:11 ThisWillDoIt

@ThisWillDoIt we're happy to talk to users through the issues - sometimes we point to documentation to save time with some text that has been edited/refined/improved over time rather than answer "off the cuff".

willportnoy avatar Dec 07 '16 19:12 willportnoy

@willportnoy where should I put the code to avoid "412" errors, the one that is here: https://docs.botframework.com/en-us/technical-faq/#how-can-i-fix-precondition-failed-412-or-conflict-409-http-errors, in the messageController?

fercom avatar Jan 25 '17 20:01 fercom

@fercom anywhere that executes just once, since you're updating the static container.

Perhaps a static constructor for MessagesController, or Global.asax.cs, or wherever you configure your container.

Relevant at some point: https://github.com/Microsoft/BotBuilder/issues/1966

willportnoy avatar Jan 25 '17 22:01 willportnoy

@willportnoy I put it in global.asax.cs, but my bot is still throwing "412's"

protected void Application_Start()
       {
             var builder = new ContainerBuilder();
           builder
               .Register(c => new CachingBotDataStore(c.Resolve<ConnectorStore>(), CachingBotDataStoreConsistencyPolicy.LastWriteWins))
               .As<IBotDataStore<BotData>>()
               .AsSelf()
               .InstancePerLifetimeScope();
           builder.Update(Conversation.Container);

           GlobalConfiguration.Configure(WebApiConfig.Register);
       }

fercom avatar Jan 26 '17 19:01 fercom

@willportnoy I put it in a static constructor for MessageController, it seems that the "412"s are gone but now it is throwing 400's and 403's image

fercom avatar Jan 26 '17 20:01 fercom

@fercom I would open a new top level issue for that. 400 is a 'bad request" and 403 is "authorization failed", so it seems likely they are caused by other issues.

willportnoy avatar Jan 31 '17 16:01 willportnoy

@willportnoy it seems that the code used to solve this problem doesn't work anymore with version 3.5.1 of the bot builder. it says: The requested service 'Microsoft.Bot.Builder.Dialogs.Internals.ConnectorStore' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.

fercom avatar Feb 02 '17 17:02 fercom

Just to let you know that this is still an issue after updating to 3.5.3

fercom avatar Feb 22 '17 22:02 fercom

@fercom I'd open a top level issue for your question because we don't look at closed issues.

In your case, the ConnectorStore is registered differently now, but it's IBotDataStore interface:

https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Library/Microsoft.Bot.Builder.Autofac/Dialogs/DialogModule.cs#L140

willportnoy avatar Feb 25 '17 00:02 willportnoy

@willportnoy ok, it is here: https://github.com/Microsoft/BotBuilder/issues/2345

fercom avatar Feb 25 '17 02:02 fercom