port: Streaming Library Refactor (#5908)
The changes in Streaming Library Refactor (#5908) may need to be ported to maintain parity with microsoft/botbuilder-dotnet.
Fixes #5630Description
This PR refactors the Bot Framework streaming protocol implementation in order to address certain issues (race conditions, memory leaks, reliability, testability, etc.) found with the legacy implementation. The details of the design and motivation behind this change can be found here.
Bot Framework Streaming Protocol
The Bot Framework Streaming Protocol stays the same even after this change, only the underlying implementation is being refactored. CloudAdapter uses the new implementation as default, and BotFrameworkHttpAdapter uses the legacy implementation as default. Both these defaults can be overridden if needed.
Architecture
Class Diagrams
![]()
Specific Changes
- The only public APIs exposed are
StreamingConnection(used by the bot adapter), andIStreamingTransportClient(used by channel SDK). The concrete implementations of these interfaces areWebSocketStreamingConnectionandWebSocketClientrespectively.- Legacy implementations in
StreamingRequestHandlerare refactored into a new obsolete public classLegacyStreamingConnectionwhich extendsStreamingConnection.CloudAdapteris updated to use new streaming library, and support for responding to proactive/skills messages over web socket connection.- Internal classes in the Session layer and Transport layer that encapsulate the 2-way transfer of request/response streams.
Related docs
- System.IO.Pipelines: The new implementation uses I/O Pipelines to abstract a lot of socket boilerplate code. Kestrel and signalR use this with great success.
- High performance logging: The streaming stack uses the high performance logging pattern from asp.net core, given the potentially higher volume of operations.
Please review and, if necessary, port the changes.
The Bot Framework Streaming Protocol stays the same even after this change, only the underlying implementation is being refactored. CloudAdapter uses the new implementation as default, and BotFrameworkHttpAdapter uses the legacy implementation as default. Both these defaults can be overridden if needed.
