Alexa / Spotify not working - [aiohttp.server] Error handling request

Hello together,

I currently using version 0.46.1 on a raspi 3.

Since upgrading to version ( I guess 0.44.1) I have the following (similar looking) problems.

When calling https://mydomain.com/api/spotify I get the following error:

2017-06-20 17:59:19 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/deps/aiohttp/web_protocol.py", line 421, in start
resp = yield from self._request_handler(request)
  File "/home/homeassistant/.homeassistant/deps/aiohttp/web.py", line 303, 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 143, in coro
res = yield from res
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/http/ban.py", line 58, in ban_middleware_handler
return (yield from handler(request))
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/http/__init__.py", line 421, in handle
result = handler(request, **request.match_info)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/media_player/spotify.py", line 116, in get
self.oauth.get_access_token(request.query['code'])
  File "multidict/_multidict.pyx", line 124, in multidict._multidict._Base.__getitem__ (multidict/_multidict.c:3495)
  File "multidict/_multidict.pyx", line 119, in multidict._multidict._Base._getone (multidict/_multidict.c:3430)
KeyError: "Key not found: 'code'"

When calling POST /api/alexa with my pw I get the following:

2017-06-20 18:04:50 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/deps/aiohttp/web_protocol.py", line 421, in start
resp = yield from self._request_handler(request)
  File "/home/homeassistant/.homeassistant/deps/aiohttp/web.py", line 303, 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 143, in coro
res = yield from res
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/http/ban.py", line 58, in ban_middleware_handler
return (yield from handler(request))
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/http/__init__.py", line 424, in handle
result = yield from result
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/alexa.py", line 133, in post
data = yield from request.json()
  File "/home/homeassistant/.homeassistant/deps/aiohttp/web_request.py", line 469, in json
return loads(body)
  File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
return _default_decoder.decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

Both requests returning a 500. Also when calling the Alexa API via the Alexa Skill Dev tool I get a 500.

Any Ideas what is the cause for this Problem?

Thank you in advance!

Regards,
Jan

I could fix the Spotify issue.

The problem was a wrong http: base_url.

I had xy.zzzzz.cloud after changing to https://xy.zzzzz.cloud it worked!

hello
where did you change it?
i have the same proble acessing the HA outside the home
best regards

In my case this was the base_url under the http component.

Hope this helps, let me know if you still have any trouble.

Regards,
Jan

form me don’t worked :frowning:

every time that i am away from and do refresh or any comanda give me this error:

2 018-06-13 17:46:43 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_protocol.py”, line 385, in start
resp = await self._request_handler(request)
File “/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_app.py”, line 338, in _handle
resp = await handler(request)
File “/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_middlewares.py”, line 88, in impl
return await handler(request)
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/static.py”, line 68, in staticresource_middleware
return await handler(request)
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/real_ip.py”, line 27, in real_ip_middleware
return await handler(request)
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/ban.py”, line 68, in ban_middleware
return await handler(request)
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/auth.py”, line 54, in auth_middleware
return await handler(request)
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/view.py”, line 98, in handle
result = await result
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/websocket_api.py”, line 231, in get
return await ActiveConnection(request.app[‘hass’], request).handle()
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/websocket_api.py”, line 426, in handle
await self._writer_task
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/websocket_api.py”, line 265, in _writer
await self.wsock.send_json(message, dumps=JSON_DUMP)
File “/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_ws.py”, line 266, in send_json
await self.send_str(dumps(data), compress=compress)
File “/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_ws.py”, line 255, in send_str
await self._writer.send(data, binary=False, compress=compress)
File “/srv/homeassistant/lib/python3.6/site-packages/aiohttp/http_websocket.py”, line 609, in send
return await self._send_frame(message, WSMsgType.TEXT, compress)
File “/srv/homeassistant/lib/python3.6/site-packages/aiohttp/http_websocket.py”, line 588, in _send_frame
await self.protocol._drain_helper()
File “/usr/lib/python3.6/asyncio/streams.py”, line 217, in _drain_helper
yield from waiter
File “/usr/lib/python3.6/asyncio/selector_events.py”, line 784, in _write_ready
n = self._sock.send(self._buffer)
BrokenPipeError: [Errno 32] Broken pipe