rosskouk / asknavidrome

An Alexa skill to allow streaming of music from Subsonic API compatible media servers on Amazon Echo devices.
https://rosskouk.github.io/asknavidrome
MIT License
48 stars 7 forks source link

The requested skill did not provide a valid response[ISSUE] #23

Closed kevinwenyu closed 9 months ago

kevinwenyu commented 1 year ago

i set the skill as your instruction, but always get the failure "The requested skill did not provide a valid response" i searched online for help, but get no result. can you help me on the failure?

rosskouk commented 1 year ago

Hi,

The first thing to do would be enabling debugging and checking the logs generated by the skill. Unfortunately that error effectively just means something went wrong. I'll need some more information to help.

kevinwenyu commented 1 year ago

after a few tries, i got alexa skill work with asknavidrome, but the asknavidrome faces SSL verification with NaviDrome, the fault is below: 2023-05-28 09:31:25,714 - root - ERROR - General Exception: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)>

any suggestion ?

rosskouk commented 1 year ago

Hey,

Yes, Amazon will only connect via HTTPS, and it must be a well known certificate. You will need to ensure that the certificates on both Navidrome and the skill are not self signed. Using Letsencrypt is probably the easiest way to do that, there are also some suggestions in the docs here: https://rosskouk.github.io/asknavidrome/#deploying-the-asknavidrome-web-service

Let me know how you get on.

kevinwenyu commented 1 year ago

i didnt get an Domain Name, so i just use ZeroSSL to sign the IP address. i think this is the root cause. i'll try the LetsEncrypt.

kevinwenyu commented 1 year ago

I think there's something wrong with my nginx reverse proxy. the failure hints shows blow: 2023-05-28 21:43:16,962 - werkzeug - INFO - Press CTRL+C to quit 2023-05-28 21:43:49,958 - werkzeug - INFO - 172.17.0.1 - - [28/May/2023 21:43:49] "POST /:5001/rest/getRandomSongs HTTP/1.0" 404 - 2023-05-28 21:43:49,960 - root - ERROR - General Exception: HTTP Error 404: NOT FOUND 2023-05-28 21:43:49,960 - root - ERROR - Request Type Was: IntentRequest 2023-05-28 21:43:49,960 - root - ERROR - Intent Name Was: NaviSonicPlayMusicRandom 2023-05-28 21:43:49,962 - werkzeug - INFO - 172.17.0.1 - - [28/May/2023 21:43:49] "POST / HTTP/1.0" 200 -

kevinwenyu commented 1 year ago

alright, i solved this after hundreds times failure and tries. thanks a lot. and really great app. my echo dot is back to life. many thanks again.

rosskouk commented 1 year ago

Thanks, glad to hear you're up and running

MrAlucardDante commented 1 year ago

Could you provide any info as how you resolved your issue ? I am using the skill behind traefik and I am facing the same issue. Asknavidrome receives the request and I can see in the logs that the skill plays a song on navidrome. But unfortunately amazon can’t deal with the response sent by the skill

kevinwenyu commented 1 year ago

i think you should post the log for trouble shooting.

rosskouk commented 1 year ago

Yes, agreed your logs and a sanitised copy of your skill config would be good.

Normally I would look at your certificates, they have to be well known.

MrAlucardDante commented 1 year ago

Here are the logs, nothing seems wrong, AskNavidrome receives the request from Alexa and starts playing, but the response it sends is empty.

2023-06-06 14:59:06,167 - asknavidrome.subsonic_api - INFO - Successfully connected to Navidrome

2023-06-06 14:59:06,205 - werkzeug - INFO - 172.18.0.8 - - [06/Jun/2023 14:59:06] "POST / HTTP/1.1" 200 -

2023-06-06 14:59:27,346 - werkzeug - INFO - 172.18.0.8 - - [06/Jun/2023 14:59:27] "POST / HTTP/1.1" 200 -

2023-06-06 14:59:31,313 - root - INFO - Playing music by: korn

2023-06-06 14:59:31,315 - asknavidrome.controller - INFO - Playing track: Dead by: Korn

2023-06-06 14:59:31,316 - werkzeug - INFO - 172.18.0.8 - - [06/Jun/2023 14:59:31] "POST / HTTP/1.1" 200 -

Here is my config:

asksonic:
    image: ghcr.io/rosskouk/asknavidrome:v0.8
    container_name: asksonic
    restart: unless-stopped
    depends_on:
      - navidrome
    environment:
      TZ: Europe/Paris
      NAVI_SKILL_ID: XXX
      NAVI_SONG_COUNT: 50
      NAVI_URL: https://my.navidrome.url
      NAVI_USER: XXX
      NAVI_PASS: XXX
      NAVI_PORT: 443
      NAVI_API_PATH: /rest
      NAVI_API_VER: 1.16.1
      NAVI_DEBUG: 1

My certificate is valid and verified by Google (through Cloudflare and Traefik). I am using a wilcard domain with a DNS challenge, so I don't have to deal with individual certificates for each subdomains.

Since Alexa can talk to AskNavidrome in the first place (Alexa answer with "Ready!" when the skill is launch), i doubt that it's a certificate issue, but I might be wrong.

Here is the initial response when the skill is started:

{
    "body": {
        "version": "1.0",
        "response": {
            "outputSpeech": {
                "type": "SSML",
                "ssml": "<speak>Ready!</speak>"
            },
            "reprompt": {
                "outputSpeech": {
                    "type": "SSML",
                    "ssml": "<speak>Ready!</speak>"
                }
            },
            "shouldEndSession": false,
            "type": "_DEFAULT_RESPONSE"
        },
        "sessionAttributes": {},
        "userAgent": "ask-python/1.18.0 Python/3.9.16"
    }
}
rosskouk commented 1 year ago

Thanks for adding the info, everything looks good. Could you set NAVI_DEBUG to 3 and retest? The increased debugging should display the raw JSON requests and responses in the logs. Part of the response from AskNavidrome will be the URL of the track that should be played on the echo.

Copy and paste the URL into your browser and make sure the track actually plays, that should confirm everything is working.

If you still have the issue, try rebooting the echo (I'm sure you've already done this, but I'm mentioning it just in case). I do get the same issue from time to time and a reset of the echo is all that resolved it.

If the issue still persists the next thing I'd check is the encoding, format, bit rate of the tracks. There are limitations to what echo devices support, and if that is the issue you should be able to work around it using transcoding on the Navidrome side. Hopefully the increased debugging will give a clue to what's going on.

MrAlucardDante commented 1 year ago

Thank you for your help.

Since I am using Traefik, I have 2 URL for Navidrome, one local (that is only accessible in my LAN) and one accessible from the internet.

In my asknavidrome config I used the local URL because I thought that AskNavidrome would forward the song to the Echo, but from what I can tell in the logs, AskNavidrome actually sends the Navidrome URL to the Echo device, so I need to use the latter URL.

After updating it, I now get a JSON response, but it keeps saying "Sorry I didn't get that, can you please say it again"

I have made my own alexa.json for a French version of the intents. I just tried switching it back to your english version, but even after asking Alexa "play songs by xxx", I still get that response.

Any ideas ?

rosskouk commented 1 year ago

Hi, I'm glad you had some success, I had issues with the same problem when I was building the skill.

The "Sorry I didn't get that, can you please say it again" error is normally only generated when a request reaches the skill that it doesn't have a handler for. Updating the alexa.json file is fine, but the intent names cannot be changed. If you keep debugging on you should see the Intent being called.

For example, when you say "play songs by xxx". That needs to be an intent called "NaviSonicPlaySongByArtist", the sentences can be anything you like but the name must match or the skill won't know how to deal with the request.

If that doesn't help can you give me logs of the attempts with debug level 3 please?

MrAlucardDante commented 1 year ago

Well, looks like I’m stuck.

If I use my local URL, asknavidrome connects to navidrome but like we said previously, it doesn’t work since navidrome has to be accessible from the internet.

If I switch to the exposed URL, asknavidrome fails to connect to navidrome (403 forbidden). I don’t understand why, since both URL are managed by traefik that calls the same service. Maybe cloudflare blocks something, or maybe a missing header.

Do you have the api endpoint for login so I can try to connect manually to see the response ? I have found /auth/login online but I can’t seem to connect for some reason.

MrAlucardDante commented 1 year ago

Here's what I've tried inside the container so far:

echo $NAVI_URL:$NAVI_PORT$NAVI_API_PATH returns https://<my_navidrome_instance_url>:443/rest which matches the env var in my docker compose.

wget -O ./test.xml "$NAVI_URL:$NAVI_PORT$NAVI_API_PATH/ping?u=$NAVI_USER&p=$NAVI_PASS&v=$NAVI_API_VER&c=asksonic" ouputs <subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.16.1" type="navidrome" serverVersion="0.49.3 (8b93962f)"></subsonic-response>.

Calling the URL with postman gives the same results

So asksonic has no issues talking to navidrome. I don't understand why it fails to connect at startup. And the error message is very generic even with NAVI_DEBUG=3:

2023-06-12 15:10:12,114 - root - INFO - AskNavidrome 0.6!

2023-06-12 15:10:12,114 - root - DEBUG - Getting configutration from the environment...

2023-06-12 15:10:12,114 - root - INFO - Skill ID set to: <redacted>

2023-06-12 15:10:12,115 - root - INFO - Minimum song count is set to: 50

2023-06-12 15:10:12,115 - root - INFO - The URL for Navidrome is set to: <redacted>

2023-06-12 15:10:12,115 - root - INFO - The Navidrome user name is set to: <redacted>

2023-06-12 15:10:12,115 - root - INFO - The Navidrome password is set

2023-06-12 15:10:12,115 - root - INFO - The Navidrome port is set to: 443

2023-06-12 15:10:12,115 - root - INFO - The Navidrome API path is set to: /rest

2023-06-12 15:10:12,115 - root - INFO - The Navidrome API version is set to: 1.16.1

2023-06-12 15:10:12,115 - root - DEBUG - Configuration has been successfully loaded

2023-06-12 15:10:12,115 - root - DEBUG - Log level set to DEBUG

2023-06-12 15:10:12,115 - root - DEBUG - MediaQueue object created...

2023-06-12 15:10:12,116 - asknavidrome.subsonic_api - DEBUG - Connected to Navidrome

2023-06-12 15:10:12,116 - asknavidrome.subsonic_api - DEBUG - In function ping()

2023-06-12 15:10:12,213 - asknavidrome.subsonic_api - ERROR - Failed to connect to Navidrome

2023-06-12 15:10:12,274 - root - INFO - AskNavidrome Web Service is ready to start!

2023-06-12 15:10:12,277 - root - WARNING - AskNavidrome debugging has been enabled, this should only be used when testing!

2023-06-12 15:10:12,277 - root - WARNING - The /buffer, /queue and /history http endpoints are available publicly!

 * Serving Flask app 'app'

 * Debug mode: off

2023-06-12 15:10:12,281 - werkzeug - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.

 * Running on all addresses (0.0.0.0)

 * Running on http://127.0.0.1:5000

 * Running on http://172.18.0.4:5000

2023-06-12 15:10:12,281 - werkzeug - INFO - Press CTRL+C to quit
Ebusicano commented 11 months ago

@MrAlucardDante i have the same issue, did u find a solution? I´m getting crazy with this thing.

MrAlucardDante commented 11 months ago

@Ebusicano unfortunately no. I have the same headers in traefik for both my local and remote URL and my certificate is generated by traefik through Cloudflare’s dns challenge. But asknavidrome can only connect to navidrome on the local URL, even though calling the external URL manually works. I gave up for now, maybe there is something I need to configure on Cloudflare.

rosskouk commented 9 months ago

Closing as this issue is related to traefik.