BotFramework-WebChat icon indicating copy to clipboard operation
BotFramework-WebChat copied to clipboard

Connection lost after 4 minutes of inactivity and unable to reconnect

Open miketrexler opened this issue 3 years ago • 1 comments

Is it an issue related to Adaptive Cards?

  • [ ] Yes, this is an Adaptive Card issue but it is specific to Web Chat.

Do you have any screenshots?

No response

What version of Web Chat are you using?

Latest production

Which distribution are you using Web Chat from?

NPM

Which hosting environment does this issue primarily affect?

Others or unrelated

Which browsers and platforms do the issue happened?

Platform: Android

Which area does this issue affect?

Protocol or service

Is this an accessibility issue?

  • [ ] Yes, this is an accessibility issue.

Please describe the bug

We have encountered an unusual behavior in our Android implementation of WebChat. We are serving the WebChat application within a WebView, hosted inside the Android app. On Android the app is loaded via an aliased localhost url: https://appassets.androidplatform.net/assets/mswebchat/index.js

Our Android mobile app is unable to reconnect to chat after 4 or more minutes of not interacting with it.

Do you see any errors in console log?

We have logged the ChatBot actions and see the following chain of actions, which occur when we attempt to reconnect: DIRECT_LINE/POST_ACTIVITY DIRECT_LINE/POST_ACTIVITY_PENDING WEB_CHAT/SET_SUGGESTED_ACTIONS WEB_CHAT/STOP_DICTATE WEB_CHAT/STOP_SPEAKING DIRECT_LINE/POST_ACTIVITY_IMPEDED DIRECT_LINE/POST_ACTIVITY_REJECTED

How to reproduce the issue?

To reproduce the issue, 1 Log into mobile app, then open WebChat. 2 After the chat screen opens, do not interact with it for at least 4 minutes. 3 Enter "Hi" into the message field and tap "Send". You will either receive the "Send failed. Retry" message or the "Taking longer than usual to connect" message. If you get "Send failed. Retry" and tap "Retry" you will receive the "Send failed. Retry" message after the retry. If you receive the "Taking longer than usual to connect" message, you will be able to type in a message but the "Send" button will not work.

What is the expected and actual behavior?

Expected: WebChat either does not disconnect, or is able to successfully reconnect after being idle for >4 minutes.

Actual: WebChat is disconnected and unable to reconnect after being idle for >4 minutes.

Adaptive Card JSON

No response

Additional context

We are not seeing the issue on iOS or Web. Has anyone encountered a similar issue, where the connection seems to be lost and unrecoverable, that affects Android only?

We understand it may be an issue with the Android platform specifically, but are unsure how to proceed to troubleshoot the issue as the reconnection logic appears to be happening within the WebChat code.

miketrexler avatar Sep 19 '22 17:09 miketrexler

@miketrexler - I've got a variety of questions for you to help clarify and narrow down the issue.

  • Can you tell me the version of Web Chat you are using? Also, the versions of any other pertinent libraries (Node, React, Angular, etc.)?
    • Have you tried using any other versions?
  • Which version of Android is used?
    • If possible to test, does this occur on other versions of Android?
  • Which browser and version?
    • Have you tried other browsers and/or versions?

Do you have Application Insights enabled on your bot in Azure? If so, are you able to share some of the logs that correspond to an incident? If not, is that something you would consider setting up (ref. doc, if interested)?

I'm unfamiliar with Android (iOS user, here). Is it possible to enable logging in order to capture any browser-generated logs or to view the developer's console?

Web Chat makes use of web sockets, by default. It could be that Web Chat is having difficulty maintaining that socket connection. It's possible to disable web sockets and switch to polling by passing in websocket: false in the createDirectLine() method. Does this work if you switch to polling?

Is it possible the hosting page is partially or wholly refreshing causing Web Chat to lose its connection or recreate the DirectLine object but still using cached data (activities, etc.)?

stevkan avatar Sep 20 '22 20:09 stevkan

Update: Working with Azure Support Escalation Engineer over Teams to try and identify the issue.

stevkan avatar Sep 28 '22 21:09 stevkan

@miketrexler @7208395096 Closing issue due to unexplained activity.

tracyboehrer avatar Oct 13 '22 18:10 tracyboehrer