Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Client Disconnected During SSE - Microsoft Bot Framework with Ngrok #6682

Open
Harish-ilink opened this issue Jan 31, 2025 · 0 comments
Open

Comments

@Harish-ilink
Copy link

Harish-ilink commented Jan 31, 2025

I am developing a Microsoft Teams bot using the Microsoft Bot Framework and tunneling it with Ngrok. However, I am encountering the following error during execution:
2025-01-31 17:54:51 | responses = await self.adapter.send_activities(self, output)
2025-01-31 17:54:51 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-01-31 17:54:51 | File "/usr/local/lib/python3.11/site-packages/botbuilder/core/cloud_adapter_base.py", line 90, in send_activities
2025-01-31 17:54:51 | raise Error("Unable to extract ConnectorClient from turn context.")
2025-01-31 17:54:51 | copy.Error: Unable to extract ConnectorClient from turn context.
2025-01-31 17:54:51 |
2025-01-31 17:54:51 | During handling of the above exception, another exception occurred:
2025-01-31 17:54:51 |
2025-01-31 17:54:51 | Traceback (most recent call last):
2025-01-31 17:54:51 | File "/usr/local/lib/python3.11/site-packages/sse_starlette/sse.py", line 258, in wrap
2025-01-31 17:54:51 | await func()
2025-01-31 17:54:51 | File "/usr/local/lib/python3.11/site-packages/sse_starlette/sse.py", line 245, in stream_response
2025-01-31 17:54:51 | async for data in self.body_iterator:
2025-01-31 17:54:51 | File "/backend/app/api/msteams.py", line 587, in event_generator
2025-01-31 17:54:51 | await on_error(context, error=e)
2025-01-31 17:54:51 | File "/backend/app/api/msteams.py", line 447, in on_error
2025-01-31 17:54:51 | await context.send_activity("An unexpected error occurred while processing your request")
2025-01-31 17:54:51 | File "/usr/local/lib/python3.11/site-packages/botbuilder/core/turn_context.py", line 173, in send_activity
2025-01-31 17:54:51 | result = await self.send_activities([activity_or_text])
2025-01-31 17:54:51 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-01-31 17:54:51 | File "/usr/local/lib/python3.11/site-packages/botbuilder/core/turn_context.py", line 225, in send_activities
2025-01-31 17:54:51 | return await self._emit(self._on_send_activities, output, logic())
2025-01-31 17:54:51 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-01-31 17:54:51 | File "/usr/local/lib/python3.11/site-packages/botbuilder/core/turn_context.py", line 303, in _emit
2025-01-31 17:54:51 | return await logic
2025-01-31 17:54:51 | ^^^^^^^^^^^
2025-01-31 17:54:51 | File "/usr/local/lib/python3.11/site-packages/botbuilder/core/turn_context.py", line 220, in logic
2025-01-31 17:54:51 | responses = await self.adapter.send_activities(self, output)
2025-01-31 17:54:51 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-01-31 17:54:51 | File "/usr/local/lib/python3.11/site-packages/botbuilder/core/cloud_adapter_base.py", line 90, in send_activities
2025-01-31 17:54:51 | raise Error("Unable to extract ConnectorClient from turn context.")
2025-01-31 17:54:51 | copy.Error: Unable to extract ConnectorClient from turn context.

Issue Details:
The bot is handling messages asynchronously, and it appears that the event stream (astream_messages) is being canceled unexpectedly, leading to the CancelledError. This is causing the client to disconnect from the SSE (Server-Sent Events).

Troubleshooting Steps Taken:
Checked if Ngrok tunnel was stable and active.
Verified if the bot was receiving messages before the disconnection.
Ensured the bot's Azure App registration and permissions were correctly set.
Tried handling the CancelledError exception explicitly but still observed the same issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant