microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.5k stars 2.44k forks source link

[WebChat] C# Precondition Failed 412 on WebChat API #2653

Closed alokraj68 closed 6 years ago

alokraj68 commented 7 years ago

System Information

SDK language C# SDK version 3.5.5 Development environment - Azure App Service

Issue Description

We are trying to implement Web Chat and found that when using the same bot in different tabs, it throws a Precondition failed 412. this can actually affect when the user navigates from one page to another through a website and the chat bot turns out with bug

Steps to Reproduce

  1. Implement web chat on 2 different pages say page A and page B
  2. Open chat in Page A start chatting
  3. Redirect user to next Page that is Page B.
  4. Try to chat and see the error.

Expected Behaviour

The bot should work on both pages without making any issues.

Actual Results

following exception is thrown.

Microsoft.Rest.HttpOperationException: The remote server returned an error: (412) Precondition Failed.
   at Microsoft.Bot.Connector.ErrorHandling.<HandleErrorAsync>d__2`1.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.BotStateExtensions.<SetUserDataAsync>d__3.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.Builder.Dialogs.Internals.ConnectorStore.<Microsoft-Bot-Builder-Dialogs-Internals-IBotDataStore<Microsoft-Bot-Connector-BotData>-SaveAsync>d__3.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.Builder.Dialogs.Internals.CachingBotDataStore.<Save>d__10.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.Builder.Dialogs.Internals.CachingBotDataStore.<Microsoft-Bot-Builder-Dialogs-Internals-IBotDataStore<Microsoft-Bot-Connector-BotData>-FlushAsync>d__5.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.Builder.Dialogs.Internals.BotDataBase`1.<FlushAsync>d__9.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.Builder.Dialogs.Internals.DialogTaskManagerBotDataLoader.<FlushAsync>d__10.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.Builder.Dialogs.Internals.PersistentDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__3.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.Builder.Dialogs.Internals.ExceptionTranslationDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__2.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.Builder.Dialogs.Internals.SerializeByConversation.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__4.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.Builder.Dialogs.Internals.PostUnhandledExceptionToUser.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Bot.Builder.Dialogs.Internals.PostUnhandledExceptionToUser.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__5.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.Builder.Dialogs.Internals.LogPostToBot.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__3.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.Builder.Dialogs.Conversation.<SendAsync>d__5.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.Builder.Dialogs.Conversation.<SendAsync>d__2.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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at ****************.<Post>d__1.MoveNext() in**************.cs:line 51
stevengum commented 7 years ago

Hi @alokraj68, are you getting the 412 code when you have two tabs open with the same chatbot and are attempting to talk through both of them in the same conversation? Or is this a user opening a new tab that has the same chatbot and then upon interaction a 412 is served?

alokraj68 commented 7 years ago

@stevengum97 yeah, the second scenario. the user interacting with the same chat bot on 2 pages. Let's say a follow-up page.

nwhitmont commented 7 years ago

@alokraj68 are you still experiencing the issue after upgrading to BotBuilder v3.8.1?

alokraj68 commented 7 years ago

YEs, the issue still persists and also, the bot is restarting itself at times.

Thanks and Regards,

[image: Astro-Vision Future Tech] https://htmlsig.com/t/000001C1E7PD

Alok Rajasukumaran / Developer - Innovation Team post@alokraj68.in / 00919995607654

Astro-Vision Future Tech Kuthappadi, Thamannam, ErnakulamKerala, India - 682032 alokraj68.in

[image: Twitter] https://htmlsig.com/t/000001BVYZJE [image: Facebook] https://htmlsig.com/t/000001BX9HG8 [image: Google +] https://htmlsig.com/t/000001BV7H1J [image: LinkedIn] https://htmlsig.com/t/000001C065D9 [image: Youtube] https://htmlsig.com/t/000001C06RDJ [image: Github] https://htmlsig.com/t/000001BYKTTT [image: Soundcloud] https://htmlsig.com/t/000001BX996X [image: Stack Overflow] https://htmlsig.com/t/000001BVE8RR

On 2 June 2017 at 04:05, Nils notifications@github.com wrote:

@alokraj68 https://github.com/alokraj68 are you still experiencing the issue after upgrading to BotBuilder v3.8.1?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BotBuilder/issues/2653#issuecomment-305639581, or mute the thread https://github.com/notifications/unsubscribe-auth/AIyDm21beMToC8EP1kjhK3ePAX8Mr2iDks5r_zzNgaJpZM4NIxcQ .

EricDahlvang commented 6 years ago

Please refer to https://docs.microsoft.com/en-us/bot-framework/bot-service-troubleshoot-general-problems#what-causes-an-error-with-http-status-code-412-precondition-failed-or-http-status-code-409-conflict for the 412 exception.

Please open a new issue if you require further assistance.