How to Upgrade to WebSocket?

Wirtl, Marco 11 Reputation points
2020-08-11T08:40:20.543+00:00

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 AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
841 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Steven Kanberg 16 Reputation points
    2020-09-03T17:38:20.647+00:00

    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);  
           });  
       });  
    
    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.