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

WebSocket connection failed: Error during WebSocket handshake: Unexpected response code: 400 #3691

Closed
pinarkaymaz6 opened this issue Jan 31, 2021 · 2 comments
Assignees
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-replied-to Required for internal reporting. Do not delete. customer-reported Required for internal Azure reporting. Do not delete. question Further information is requested. Stack Overflow candidate support Internal request for assistance from the Support Team

Comments

@pinarkaymaz6
Copy link

pinarkaymaz6 commented Jan 31, 2021

[Question]

I have a Bot service running on Azure. I'm trying to voice enable the bot, however I keep getting Websocket connection error.

I have the echo-bot running on the server side. I followed this tutorial and I added a Direct Line Speech channel to the bot with a cognitive speech service on Azure portal.

As the client, I used the sample Direct Line Speech sample. Here is the full code:

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <script
      crossorigin="anonymous"
      src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
    <title>Speech Test</title>
          <style>
      html,
      body {
        height: 100%;
      }

      body {
        margin: 0;
      }

      #webchat {
        height: 100%;
        width: 100%;
      }
    </style>
  </head>
  <body >
    <div id="root"></div>
    <div id="webchat" role="main"></div>
    <script>
      (async function () {
        async function fetchCredentials(){
          const res = await fetch(
            "https://westeurope.api.cognitive.microsoft.com/sts/v1.0/issueToken",
            {
              method: "POST",
              headers: {
                "Ocp-Apim-Subscription-Key": `XXXXXXXXX`,
              },
            }
          );
          if (!res.ok) {
            throw new Error("Failed to fetch authorization token and region.");
          }
          return { authorizationToken: await res.text(), region: "westeurope" };
        };
        const adapters = await window.WebChat.createDirectLineSpeechAdapters({
          fetchCredentials
        });

        window.WebChat.renderWebChat(
          {
          ...adapters
          },
          document.getElementById("webchat")
        );
        document.querySelector("#webchat > *").focus();
      })().catch((err) => err);
    </script>
  </body>
</html>

What might be the reason for Websocket to fail?

[Version]

<meta name="botframework-directlinespeech:version" content="4.11.0">
<meta name="botframework-webchat:bundle:variant" content="full">
<meta name="botframework-webchat:bundle:version" content="4.11.0">
<meta name="botframework-webchat:core:version" content="4.11.0">
<meta name="botframework-webchat:ui:version" content="4.11.0">

[Error]

Firefox can’t establish a connection to the server at wss://westeurope.convai.speech.microsoft.com/api/v3?language=en-US&format=simple&Authorization=<XXXXXXXXXXXX>&X-ConnectionId=7047B4CE339E4DFDA5435664DEF8CE58
@pinarkaymaz6 pinarkaymaz6 added Bot Services Required for internal Azure reporting. Do not delete. Do not change color. question Further information is requested. Stack Overflow candidate customer-reported Required for internal Azure reporting. Do not delete. labels Jan 31, 2021
@corinagum corinagum added the support Internal request for assistance from the Support Team label Feb 2, 2021
@Zerryth
Copy link

Zerryth commented Feb 3, 2021

@pinarkaymaz6 it seems like you have your speech credentials different from how I sent them up in the past, when I got speech to work.

See this comment: #3407 (comment), last bullet, expanded.
You could also review the steps taken to get WC + DLS + bot working together there, although it was a JS bot.

Additionally, just to confirm, are you using a python bot?
Does the bot work in the portal when you deploy in the "Test in webchat" panel (i.e. the "regular", not speech protocol)

@Zerryth Zerryth added the customer-replied-to Required for internal reporting. Do not delete. label Feb 3, 2021
@Zerryth
Copy link

Zerryth commented Feb 11, 2021

Closing due to inactivity. Additionally, it seems like the error is telling you it's a malformed request.
(See previous comment for instructions on how to set up the scenario)

@Zerryth Zerryth closed this as completed Feb 11, 2021
@Zerryth Zerryth self-assigned this Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-replied-to Required for internal reporting. Do not delete. customer-reported Required for internal Azure reporting. Do not delete. question Further information is requested. Stack Overflow candidate support Internal request for assistance from the Support Team
Projects
None yet
Development

No branches or pull requests

3 participants