microsoft / botframework-sdk

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

Azure bot sometimes returns Bot timeout (502, 504) error but also getting right response #6597

Closed dkulkarni-ms closed 1 year ago

dkulkarni-ms commented 1 year ago

Github issues should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.

Version

What package version of the SDK are you using. 4.19.3 - Microsoft.Bot.Builder.* Client side - "botframework-webchat": "^4.15.7", "botframework-webchat-component": "^4.15.7",

Describe the bug

We have azure bot using as assistant and calling LLM APIs in the backend. On the client side we use directline from botframework to call into bot. Sometimes the GPT calls take longer time. We see that activities call timesout from network tab sometimes and returns 504 error. However, we do get the right response later from the backend. In UI we dont see any error message as timeout and we see next correct response from the backend displaying in UI. Its good that UI doesnt show any error and waits for bot to finish. We want to understand though is there any internal logic to ignore 504/502 errors and give more time for Bot to send the right response?

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

We should not see timeout for activity call. Rather should see that all calls are returning 200.

Screenshots

image

Additional context

Add any other context about the problem here.

Tracking Status

Dotnet SDK [TODO]()

Javascript SDK [TODO]()

Python SDK [TODO]()

Java SDK [TODO]()

Samples [TODO]()

Docs [TODO]()

Tools [TODO]()

anishprasad01 commented 1 year ago

Hi @dkulkarni-ms,

Direct Line enforces a service-side timeout of 15 seconds that cannot be modified. In order to eliminate these bot timeout errors, you will need to either perform LLM calls outside the bot or use asynchronous Tasks to perform the long running LLM calls on a background thread. Please take a look at this sample for a starting point on implementing this with background threads.