alexa_media_player: 500 Internal Server Error Server got itself in trouble
Describe the bug At the end of the configuration, after entering the capcha the error appears: 500 Internal Server Error Server got itself in trouble
To Reproduce
- Go to Settings
- Click on Devices & Services
- Scroll down to Alexa Media Player
- Configure until capcha solved
System details
HA: Core 2024.7.3 Supervisor 2024.06.2 Operating System 12.4 Frontend 20240710.0
- Amazon 2FA is enabled (y/n). yes
Integration: alexa_media_player: 4.11.4
Logs
2024-07-21 12:16:08.741 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 69, in map_httpcore_exceptions
yield
File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 373, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 216, in handle_async_request
raise exc from None
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 196, in handle_async_request
response = await connection.handle_async_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection.py", line 101, in handle_async_request
return await self._connection.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 143, in handle_async_request
raise exc
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 113, in handle_async_request
) = await self._receive_response_headers(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 186, in _receive_response_headers
event = await self._receive_event(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 224, in _receive_event
data = await self._network_stream.read(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpcore/_backends/anyio.py", line 32, in read
with map_exceptions(exc_map):
File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
self.gen.throw(value)
File "/usr/local/lib/python3.12/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ReadTimeout
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
resp = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
response = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/alexa_media/config_flow.py", line 1001, in wrapped
return await cls.handler(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/authcaptureproxy/auth_capture_proxy.py", line 439, in all_handler
resp = await getattr(self.session, method)(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1892, in post
return await self.request(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1574, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1661, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1689, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1726, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1763, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 372, in handle_async_request
with map_httpcore_exceptions():
File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
self.gen.throw(value)
File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 86, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ReadTimeout
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 77
I managed to get the Alexa Media Player app set up again just now on the latest HA software and latest Alexa Media player app, it seems I made a monumetal mistake my end and I apologize for that, let me explain below what I think happened.
When I originally had the issue after updates 3- 4 days ago I came on here for support, 2 days ago during troublehsooting I went into the amazon web page as I had ticked the dont require OTP on this browser on a few of the systems I use at home (at the time I didnt realise this would be a problem but after some of Daniels posts it made me realise how it is working), during this time I disabled 2FA to try and see if it would make any difference (It didnt as using 2FA is a requirement for this app) I mentioned I had disabled 2FA in this comment - https://github.com/alandtse/alexa_media_player/issues/2347#issuecomment-2242751303
it seems I never re-enabled 2FA properly after disabling it (this is the biggest miskate ever, I had scanned the code and entered the 6 digit 2FA code but I didnt go to page 2 and confirm it) if you disable and set up 2FA again on your amazon account you will see what I mean by this comment of having to go to page 2 to confirm it, I only noticed this tonight when I cleared my browser cache again (I cleared the browser cache many times over the last few days) what prompted me to noticed 2FA was disabled this time is when I went to log back into Amazon I wasnt asked to enter a 2FA code when I should have been as I had reset the following options for surpessing of OTP the other day around the same time I disabled it, as I said above I wasnt aware supressing 2FA on the browser would cause this issue but it became clear to me after Daniels explaination on how its working in his comment above today, also the fact I left 2FA in a disabled state by accident thinking I had re-enabled it but I didnt (So all the testing and stuff I completed with restoring backups is null in void becuase 2FA is a requirement for this app setup to work and it was not set up during all of that testing and I only discovered that tonight)
I then went into my login settings within my amazon account tonight and discovered it was still disabled from 2 days ago, after re-enabling it and going through the 2 pages of prompts I then got the following screen when setting up the integration.
I have a feeling this issue was happening for me as I was surpressing the OPT code at the broswer level for my amazon account intially and I then continued to have issues after clearing the surpression as I disabled 2FA and thought I had re-enabled it but hadnt fully confirmed it as I said above (stupid stupid mistake my end)
Thank you for the help Daniel and sorry for any time you have wasted trying to help me with my problem even although the problem was not derived from code like I thought as it happened after an update, it was completely a user error on my part.
For other users I suggest the following:
I feel very silly after all of this and can only apologize to Daniel as I feel I waste his time, I can only hope that this information also helps other people out with the issues they have too!
Make sure 2FA OTP is enabled for your Amazon account. Make sure you haven’t previously checked the box
Don't require OTP on this browserwhen you’ve been logging into https://amazon.com` (or whatever domain your account is in). If you have then try clearing then viaRequire OTP on all devicesin Amazon > Your account > Login and security > Two-Step Verification (2SV) SettingsI believe this issue is now resolved then.
If nobody has any objections, I’d like to request it be closed…
It’s the only logical explaination I can come up with that I had it surpressed, thats not known its just an assumption as I see no other reason as 2FA was enabled on my account for a long time untill 2 days ago! I am also glad I found it and as I said I hope these posts help someone else.
It is also strange as during updates a few weeks ago I was asked to reauthenticate Alexa Media Playerand it worked without an issue, it only started failing after the most recent updates which is strange, I still dont fully understand why I was getting the capchta to begin with, I can only assume it was down to the supression on devices and then I made the problem permanent by disabling 2FA, I have +30 accounts where 2FA is set up and I also use a Yubikey for authetication for some things as I am very security concious, you need to be in todays world.
BTW, and FWIW, my browser always prompts for OTP when I log into Amazon no matter how many damns I’ve clicked the Don’t require OTP on this browser!
I think clearing the devices registered for OTP suppression in Amazon would be sufficient but then again, I can’t test that as it’s never worked reliably for me at any time!
Hey, there’s no need to apologize! Things like this keep me constantly thinking and maybe that might help defer Alzheimer’s! I’m just glad it’s finally figured out so, thank you for finally finding the reason no mater how silly or stupid! We’re all human! Plus having worked all these years in IT support, I’m used to problems that ended up being a PEBKAC! I and others I’ve worked alongside have completed many support tickets where the internal resolution note was simply “PEBKAC”…
OMG, thank you! I am up and running now too. The key is even though Amazon allows you to add an authenticator app, you need to actually go to Your Account > Account > Login & Security > and “Turn on 2FA”!