question

WirtlMarco-8087 avatar image
2 Votes"
WirtlMarco-8087 asked PhilippR answered

How to Upgrade to WebSocket?

I created a new Echo Bot in the Azure Portal. I would test it in the WebChat (just the deployed template) and i got the error: "There was an error sending this message to your bot: HTTP status code InternalServerError" in the WebChat Channel Tab!

The messaging endpoint xxx.azurewebsites.net/api/messages says "Upgrade to WebSocket is required."

16877-azure.png



Enabled the Streaming Endpoint as well.

How to solve the problem and get the bot to work?


UPDATE: The /api/messages is available now and getting "There was an error sending this message to your bot: HTTP status code ServiceUnavailable" in the WebChat

azure-bot-service
azure.png (26.3 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@WirtlMarco-8087 what pricing tier is your bot in?

0 Votes 0 ·
StevenKanberg-2404 avatar image
1 Vote"
StevenKanberg-2404 answered

Likely, you have not enabled Web Sockets in the App Service configuration. If you haven't already, review the BotFramework docs that detail all the necessary steps to take in ABS in order to stand up Direct Line Speech. In particular, these steps.

It is also necessary to add code to your bot to complete integration. There are docs available if you are using the C# SDK for building your bot. If you are using JS, please add this code to your bot, if missing:

// Listen for Upgrade requests for Streaming.
server.on('upgrade', (req, socket, head) => {
    // Create an adapter scoped to this WebSocket connection to allow storing session data.
    const streamingAdapter = new BotFrameworkAdapter({
        appId: process.env.MicrosoftAppId,
        appPassword: process.env.MicrosoftAppPassword
    })

    // Set onTurnError for the BotFrameworkAdapter created for each connection.
    streamingAdapter.onTurnError = onTurnErrorHandler;

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



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

PhilippR avatar image
0 Votes"
PhilippR answered

I don't understand the concept. So if I write a bot, I have to host/deploy it somewhere. This should be Azure in 90% of all cases. So how do i create a bot for Azure? Visual Studio and bot framework v4 or is there a better way?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.