Alexa unable to connect. HTTP 500 Error?

Hi all!

The main issue is that when I attempt to issue a command via the simulator on Amazon is gives me the following error:

There was an error calling the remote endpoint, which returned HTTP 500 : Internal Server Error

Some background:

  • Using a duckdns server. It works. I can connect to the dns server address and it pulls up HA just fine. (so I’m guessing the port forwarding is working)
  • Used LetsEncrypt to do the certficates. Specifically, I followed these directions: Set up encryption using Let's Encrypt - Home Assistant
  • I’ve set up amazon developer and created a test skill (it just turns on a light)
  • When I try it from the web service I get the error above. If I try it from the echo directly it says “There was a problem with the requested skill’s response”

Other information:

  • This is on a raspberry pi 2 running rasbian jessie
  • I’m able to successfully access my HA through the DNS with no issue for the web portal.
  • Noticed my wemo switch is no longer automatically found now that i’ve moved to the DNS & LetsEncrypt
  • Not sure what to do with SSL Certificate on the amazon skill. I assumed it was “I will upload a self-signed certificate in X.509 format” but that didn’t work (pasted fullchain.pem into the box) (also, the checkmark on “SSL Certificate” stays gray on this option. I’ve also tried both of the other options for SSL Certificate to no avail. Each one gives me the same error.
  • My HA log is filled with python errors like the following:

17-01-16 02:09:59 aiohttp.server: Error handling request
Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/deps/aiohttp/web_server.py”, line 61, in handle_request
resp = yield from self._handler(request)
File “/home/homeassistant/.homeassistant/deps/aiohttp/web.py”, line 249, in _handle
resp = yield from handler(request)
File “/usr/lib/python3.4/asyncio/coroutines.py”, line 143, in coro
res = yield from res
File “/usr/lib/python3.4/asyncio/coroutines.py”, line 141, in coro
res = func(*args, **kw)
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/http/auth.py”, line 41, in auth_middleware_handler
validate_password(request, request.GET[DATA_API_PASSWORD])):
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/http/auth.py”, line 66, in validate_password
request.app[‘hass’].http.api_password)
TypeError: comparing strings with non-ASCII characters is not supported

Please let me know if any other information could be helpful. Any help is very much appreciated! Thanks!

There’s an option that says something like “I’ve already installed a certificate from a trusted source.” That’s what I did.

When you say that you’ve “set up a test skill”, do you mean that you did so using the Alexa component?

1 Like

I have the skill configured on the amazon web service as well as an “alexa:” section in my configuration.

I can post my code here if that would be easier. I am just unsure if it’s a code error or a certificate/access error. Not really sure how to diagnose the difference.

If you don’t have a green check mark next to the SSL requirement, I’d fix that first.

Then, confirm that you can make API calls from outside your network. Loading the HASS UI on your phone when not on wifi is sufficient. But do it w/o using the VPN - you’re trying to simulate how the Alexa service sees your setup.

And make sure you’ve got your password in the URL that you set up on the Alexa dev portal.

https://YOUR-DYNAMIC-ADDRESS/api/alexa?api_password=YOUR-PASSWORD

1 Like

Ok. So I can access my HA from outside the network, without VPN, from my duckdns address on my phone. I also verified I am currently using the “My development endpoint has a certificate from a trusted certificate authority” which results in a green check for the SSL section on amazon developer portal. Finally, the password has been verified to be correct for the amazon URL.

Is there anything I can do to verify, from my end, that the api call made my amazon will work? Could it be related to the python errors I am seeing?

Thanks so much for your help so far!

EDIT: Also, I noticed in the original configuration.yaml file that “base_url” under http says “# Uncomment this if you are using SSL or running in Docker etc” but didn’t see it referenced in the instructions. Am I missing something here? I tried it uncommented with my duckdns web address and it didn’t seem to help or change the behavior of the error.

Ok I fixed a lot of the log file errors I was getting (some static IPs weren’t set up properly and it took me a while to figure that out).

However, I’m almost positive that the error code below is related to the Service Simulator (amazon website) error being generated. I cleared the log 3 times and fired off a test from amazon and each time it resulted in the same error being populated in the log file. I’ve included the error below.

17-01-16 19:21:22 aiohttp.server: Error handling request
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/deps/aiohttp/web_server.py", line 61, in handle_request
    resp = yield from self._handler(request)
  File "/home/homeassistant/.homeassistant/deps/aiohttp/web.py", line 249, in _handle
    resp = yield from handler(request)
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 141, in coro
    res = func(*args, **kw)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/http/auth.py", line 41, in auth_middleware_handler
    validate_password(request, request.GET[DATA_API_PASSWORD])):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/http/auth.py", line 66, in validate_password
    request.app['hass'].http.api_password)
TypeError: comparing strings with non-ASCII characters is not supported

Any ideas?

I’m including my alexa configuration (HA side) below to see if anyone can spot an error…

alexa:
  intents:
    SleepTimeIntent:
      action:
        service: light.turn_off
        data_template:
          entity_id: light.living_room_lamp
          transition: 10
      speech:
        type: plaintext
        text: OK

Perhaps something in here is giving me the error? The python errors in the above post make me think something with security but this is my first alexa command so it could be my script.

Ok. I found the issue.

It’s my password. I had the right password in the alexa configuration, however, it had a special character (%) in it. For some reason it isn’t interpreting the % correctly and saying it’s a non-ascii letter in the TypeError. I tried a temporary password with only letters and numbers and it worked perfectly. (Yay!)

Anyone have any idea how to input the password in alexa http request to interpret the special characters? I already tried to use the html escape character (%25 and &#37) to no avail instead of the %.

I have tried everything here and I still get the http 500 error. My password is just letters and numbers. I have letsencrypt working properly, but for the life of me I cannot get the alexa api to return anything but 500
alexa:
smart_home:

Is what I have configured for slexa within configuration.yaml

1 Like

Error in my home assistant log if this helps:

2018-02-14 09:05:11 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 416, in start
    resp = yield from self._request_handler(request)
  File "/usr/lib/python3.6/site-packages/aiohttp/web.py", line 325, in _handle
    resp = yield from handler(request)
  File "/usr/lib/python3.6/site-packages/aiohttp/web_middlewares.py", line 93, in impl
    return (yield from handler(request))
  File "/usr/lib/python3.6/site-packages/homeassistant/components/http/ban.py", line 58, in ban_middleware
    return (yield from handler(request))
  File "/usr/lib/python3.6/site-packages/homeassistant/components/http/auth.py", line 49, in auth_middleware
    return (yield from handler(request))
  File "/usr/lib/python3.6/site-packages/homeassistant/components/http/static.py", line 70, in staticresource_middleware
    return (yield from handler(request))
  File "/usr/lib/python3.6/site-packages/homeassistant/components/http/__init__.py", line 430, in handle
    result = yield from result
  File "/usr/lib/python3.6/site-packages/homeassistant/components/alexa/intent.py", line 66, in post
    message = yield from request.json()
  File "/usr/lib/python3.6/site-packages/aiohttp/web_request.py", line 513, in json
    return loads(body)
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This happens when ever I try to post via postman to https://ha.xxxxx.net/api/alexa/smart_home?api_password=

For some reason a complete restart of the VM running hass.io fixed my issue