Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Provide Cleanup Guidance around closing websockets #1668

Closed
cleemullins opened this issue Feb 5, 2020 · 4 comments · Fixed by #1783
Closed

Provide Cleanup Guidance around closing websockets #1668

cleemullins opened this issue Feb 5, 2020 · 4 comments · Fixed by #1783
Assignees
Labels
blocked Current progress is blocked on something else. Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-replied-to Indicates that the team has replied to the issue reported by the customer. Do not delete. customer-reported Issue is created by anyone that is not a collaborator in the repository. P1 Painful if we don't fix, won't block releasing R8 Release 8 - March 16th, 2020
Milestone

Comments

@cleemullins
Copy link
Contributor

Originally reported in #1655, and moved here so we've got an issue tracking the ask.

As there's not a single BotFrameworkAdapter but one for every WebSocket connection, it would also mean the new SkillHandler as well as ChannelServiceRoutes have to exist multiple times, which results in every conversation/connection resulting in a different endpoint via the SkillHandler (skillEndpoint.register(server, '/api/skills');).
Which currently is not easy to cleanup as the WebSocket does not seem to expose a disconnected event. This would result in a memory leak.

This is work we plan on shipping as part of R8, which ships ~March 15.

@cleemullins cleemullins added customer-reported Issue is created by anyone that is not a collaborator in the repository. R8 Release 8 - March 16th, 2020 Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-replied-to Indicates that the team has replied to the issue reported by the customer. Do not delete. labels Feb 5, 2020
@alopix
Copy link
Contributor

alopix commented Feb 6, 2020

Giving feedback on the linked ticket:
The setup is basically a combination of the two samples:

server.on('upgrade', async (req, socket, head) => {
    // Create an adapter scoped to this WebSocket connection to allow storing session data.
    const streamingAdapter = new BotFrameworkAdapter(adapterSettings);
    // Set onTurnError for the BotFrameworkAdapter created for each connection.
    streamingAdapter.onTurnError = onTurnErrorHandler;

    await streamingAdapter.useWebSocket(req, socket, head, async (context) => {
        // After connecting via WebSocket, run this logic for every request sent over
        // the WebSocket connection.
        await myBot.run(context);
    });
});

combined with (both top-level)

// Create and initialize the skill classes
const authConfig = new AuthenticationConfiguration([], allowedSkillsClaimsValidator);
const handler = new SkillHandler(adapter, bot, conversationIdFactory, credentialProvider, authConfig);
const skillEndpoint = new ChannelServiceRoutes(handler);
skillEndpoint.register(server, '/api/skills');

Would not work, as SkillHandler requires access to the adapter, which is only created on connection -> ChannelServiceRoutes and registration with the server would have to be inside the websocket connection handler as well, so requires a different endpoint all the time.

@johnataylor
Copy link
Member

From another thread:

This is a problem that occurs when custom adapters that abstract http request-reply protocols are combined with Skills that use the Bot Framework http based "inline proactive" protocol where replies are returned to a caller by initiating a new secondary http call in the opposite direction.

Examples of custom adapter that abstract underlying http request-reply are the Amazon Alexa and the Google Home adapters.

As the front end protocol is request-reply when the call is forwarded to another party (as is the case with a Skill) it makes sense to do this as a request-reply call with its intrinsic network affinity, rather than splitting the call into what would be separate http calls initiated in opposite directions.

The proposal is to add a value of RequestReply to the DeliveryMode field of an Activity that indicates that parties that need to forward the Activity should do so with a conventional http request and then expect any reply Activities on that request's reply.

Alternative designs considered include making the Activity the value of an InvokeActivity which already has this network binding by default. However, this design has the disadvantage of requiring more code further up the stack, particularly around making it so the extra nesting is hidden from the application layer. Overall using the DeliveryMode is the simpler design.

@cleemullins cleemullins added the blocked Current progress is blocked on something else. label Feb 18, 2020
@cleemullins
Copy link
Contributor Author

Blocked until Big Rocks closed on the path forward.

@cleemullins cleemullins added the P1 Painful if we don't fix, won't block releasing label Feb 18, 2020
@cleemullins
Copy link
Contributor Author

The design discussion(S) around this close today, so we should be unblocked tomorrow (Feb 26).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Current progress is blocked on something else. Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-replied-to Indicates that the team has replied to the issue reported by the customer. Do not delete. customer-reported Issue is created by anyone that is not a collaborator in the repository. P1 Painful if we don't fix, won't block releasing R8 Release 8 - March 16th, 2020
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants