microsoft / BotBuilder-Samples

Welcome to the Bot Framework samples repository. Here you will find task-focused samples in C#, JavaScript/TypeScript, and Python to help you get started with the Bot Framework SDK!
https://github.com/Microsoft/botframework
MIT License
4.39k stars 4.88k forks source link

The bot encounted an error 'Cannot access a disposed object. Object name: ‘SendActivityAsync’. #3809

Closed davidimmanuel007 closed 2 years ago

davidimmanuel007 commented 2 years ago

Github issues for C# /JS / Java/ Python should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.

Sample information

  1. Sample type: [\samples\ or \solutions]](https://github.com/microsoft/BotBuilder-Samples/tree/main/experimental/handoff-library/csharp_dotnetcore/samples
  2. Sample language: dotnetcore
  3. Sample name: LivePersonProxyBot

Describe the bug

I'm integrating Livepersonproxybot into my existing bot framework solution as I want to escalate to human agent in some scenario, The sample (LivePersonProxyBot) works fine & the integrated solution of mine is also works fine except this exception **The bot encounted an error 'Cannot access a disposed object.

Object name: ‘SendActivityAsync , Im able to send and receive the messages from bot to agent & agent to bot , but along with each turn I get the above error. Unable to send the activities agent has accepted/Closed the conversation** to the bot, instead of these events Im getting turn errors as mentioned above.

To Reproduce

Steps to reproduce the behavior:

    1. Sample type: [\samples\ or \solutions]](https://github.com/microsoft/BotBuilder-Samples/tree/main/experimental/handoff-library/csharp_dotnetcore/samples
  1. Integrate to existing bot framework solution (SDK 3.1)
  2. replace the appsettings values with the proper credentials
  3. run the solution and debug in emulator
  4. See error

Expected behavior

Bot should receive the messages from the agent except showing -The bot encounted an error 'Cannot access a disposed object. Object name: ‘SendActivityAsync’.

Screenshots

Img 1. the working sample as expected image Img 2. the integrated soln which showing the error image

Additional context

here is the error stack trace Microsoft.Bot.Builder.Integration.AspNet.Core.BotFrameworkHttpAdapter: Error: [OnTurnError] unhandled error : Cannot access a disposed object. Object name: 'SendActivityAsync'.

System.ObjectDisposedException: Cannot access a disposed object. Object name: 'SendActivityAsync'.

End of stack trace from previous location where exception was thrown --- at Microsoft.Bot.Builder.BotAdapter.RunPipelineAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken) at LivePersonProxyBot.LoggingMiddleware.OnTurnAsync(ITurnContext turnContext, NextDelegate next, CancellationToken cancellationToken) in E:\handoff\DigitalAssistant Latest \LivePersonConnector\Middleware\LoggingMiddleware.cs:line 46 at LivePersonConnector.HandoffMiddleware.OnTurnAsync(ITurnContext turnContext, NextDelegate next, CancellationToken cancellationToken) in E:\handoff\DigitalAssistant Latest \LivePersonConnector\HandoffMiddleware.cs:line 80

breakingram commented 2 years ago

Hi @davidimmanuel007, I'm investigating this one.

breakingram commented 2 years ago

Hi @davidimmanuel007,

I see you are using the older bot framework SDK version 3.1.

Do you face the same problem if using the latest Bot Framework SDK 4.17.1? Or is this issue specific to SDK v3?

Thanks.

breakingram commented 2 years ago

closing due to inactivity. @davidimmanuel007 please re-open if needed.