alexa / alexa-skills-kit-sdk-for-nodejs

The Alexa Skills Kit SDK for Node.js helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.
Apache License 2.0
3.13k stars 738 forks source link

Local Debug Error: WebSocket error: Unexpected server response: 401 #743

Open NAVOO-davidemarchesan opened 3 weeks ago

NAVOO-davidemarchesan commented 3 weeks ago

I'm submitting a...


[x] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Expected Behavior

Test and debug custom Alexa Skill in a local environment as described by the documentation:

Current Behavior

Receiving error

WebSocket error: Unexpected server response: 401
WebSocket is closed: CloseEvent {target: WebSocket, type: 'close', wasClean: false, reason: '', code: 1006}

when start debugging.

Possible Solution

Steps to Reproduce (for bugs)

Since error 401 should means 'Unauthorized', I started a fresh project.

1. Clone a skill

Clone a fresh skill using VS Code Extension Alexa Skills Toolkit.

2. Clone a sample skill and install packages (nodejs)

Create a lambda folder. Download and move content from Hello World Sample to the lambda folder. Run the following commands to install all required packages (inside lambda folder):

npm install
npm install --save ask-sdk-model@^1.29.0
npm install --save-dev ask-sdk-local-debug

3. Set up environment

Follow Set up the test environment instructions to create and set up the launch.json file:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Alexa Skill (Node.js)",
            "type": "node",
            "request": "launch",
            "program": "${command:ask.debugAdapterPath}",
            "args": [
                "--accessToken",
                "${command:ask.accessToken}",
                "--skillId",
                "${command:ask.skillIdFromWorkspace}",
                "--handlerName",
                "handler",
                "--skillEntryFile",
                "${workspaceFolder}/lambda/index.js",
                "--region",
                "EU"
            ]
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${file}"
        }
    ]
}

4. Start Debugging

Select Debug Alexa Skill (Node.js) and start debugging.

C:\Program Files\nodejs\node.exe .\lambda\node_modules\ask-sdk-local-debug\dist\LocalDebuggerInvoker.js --accessToken Atza|XXXXXX --skillId amzn1.ask.skill.XXXXX --handlerName handler --skillEntryFile D:\<mypath>/lambda/index.js --region EU
Region chosen: EU
WebSocket error: Unexpected server response: 401
WebSocket is closed: CloseEvent {target: WebSocket, type: 'close', wasClean: false, reason: '', code: 1006}

5. Get a new access token

Run command ask util generate-lwa-tokens --scopes alexa::ask:skills:debug to get a new access token. Replace (hard-coding temporarily) ${command:ask.accessToken} with the new fresh access token. Start debugging. Same error.

6. Configure profile

Try to re-configure profile with ask configure --profile XXXX. Reload VS Code. Start Debugging. Same error.

Context

I am trying to test and debug Alexa skill from VS Code. Thing is, the debugger used to work some days ago (and always worked). My colleagues are in the same situation. It seems that it just stopped working suddenly. Getting new access tokens should exclude a problem with authorization.

Note that we are trying to use the debugger from EU region.

Your Environment

Node.js and NPM Info

ankitrex31 commented 22 hours ago

Hey, Did you find any solution for this issue?

NAVOO-davidemarchesan commented 22 hours ago

No, but found a workaround. Just create a US amazon developer account. Clone your EU skill there with manifest and model. In launch.json file, switch region to NA and start debugging your US skill.

Seems like there is a problem with EU region.

gilleswb commented 21 hours ago

Thank you bringing these reports to our attention. I wanted to confirm this concern with EU endpoints is currently being addressed on our end. We should have an update shortly to confirm once this is resolved. Thank you!

ankitrex31 commented 19 hours ago

I appreciate you taking the time to provide this feedback and report the issue. I'll be sure to follow up on this and provide any updates I receive.

Thank you.