Closed frlarsendeloitte closed 4 years ago
What locale are you supposed to be in? You have multiple devices spread across different time zones. Are you supposed to be logging into amazon.com
as opposed to a local amazon domain?
Thanks for your reply! I'm in Europe/Copenhagen, and I can see the other devices (which are Sonos speakers) are the en-us locale. I'm using a amazon.com account in my Echo. I seem to remember that it was the only account type that was possible to setup the Alexa device with 'back in the day'. I don't use the other devices in Alexa Media, but I can't find a way to disable them through HA's Integrations. Should I make the manual Alexa Media Player configuration in configuration.yaml to exclude these devices instead?
I've managed to exclude the devices, but I'm still getting an endless loop of the log, I've pasted below. Is this still a problem with locale, you think?
Sorry, I don't think the exclusions make a difference. The reason I was asking is if you're connected to the wrong domain, it's possible that's why the websockets are being disconnected on you. However, you should only switch domains if your devices are enabled on that domain. I don't think there's an Alexa domain for Denmark. The way we normally ask people to check is to login to alexa.amazon.com and see if they see their devices. Sometimes they have to change their domain to see everything.
If you're comfortable using the developer tools for web browsers, one thing you could try to check is using the Alexa webapp at alexa.amazon.com. That is where we copied the websocket logic from. You could see whether that's also losing the websocket connection and if not, if you pulled the connection string, that could help debug this.
Otherwise, I think the only thing we can do for you is to disable websockets so you don't get the attempts constantly failing. There is probably bug in the sense it should detect this state and give up. The issue is it does successfully connect and resets the counter.
Thanks again for your help.. I'm currently logged into the webapp on the .com domain. My device is there and fully functioning. I do know how to use the DevTool for Chrome, but I'm not used to look at network traffic. I can't seem to find any errors or info regarding the websockets. Can you point me in the right direction regarding where I can find the connection string?
If there's something else I should provide or do, please let me know.
If you go into Devtools, there's a Network tab. Reload the alexa.amazon.com page after logging in and it will show you a bunch of connection info. You can filter the info down to websockets ("WS") next to Doc and Manifest.
Take a look at the behavior as you change volume to see if it's connecting for you. Here's an example message I've redacted. It shows also the tabs you should be on to view message content.
If you're seeing proper websocket messages in the client without disconnects, then I may need more info from you on the messages you're actually sending. We probably should not use GitHub to share, so Discord may be best. If you're not seeing any websocket at all, it could just be a region issue and I'd just have make sure it stops trying to connect.
I can see the websocket when reloading the page:
wss://dp-gw-na-js.amazon.com/?x-amz-device-type=ALEGCNGL9K0HM&x-amz-device-serial=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I can't see any problems or errors when I'm fx turning down the volume:
MSG 0x00000362 0x5647251f f 0x00000001 0xea725e3f 0x00000225 GWM MSG 0x0000b479 0x0000005c urn:tcomm-endpoint:service:serviceName:DeeWebsiteMessagingService:domain:prod:realm:USAmazon 0x00000081 urn:tcomm-endpoint:device:customerId:xxxxxxxxxxxxxxxx:deviceType:ALEGCNGL9K0HM:deviceSerialNumber:xxxxxxxxxxxxxxxxx {"payload":"{\"destinationUserId\":\"xxxxxxxxxxxx\",\"dopplerId\":{\"deviceType\":\"A3S5BH2HU6VAYF\",\"deviceSerialNumber\":\"xxxxxxxxxxxxx\"},\"volumeSetting\":43,\"isMuted\":false}","command":"PUSH_VOLUME_CHANGE"}FABE
Let me know if and how you want some more info from me :) Thanks!
Thanks. Do you feel comfortable editing the alexapy library files or custom installing it? I'd like to test if it's the fact we have compression on so we'd have to modify the alexapy/alexawebsocket.py around line 252 to disable compression. compress=0
await self.websocket.send_bytes(bytes("0x99d4f71a 0x0000001d A:HTUNE", "utf-8"), compress=0)
await asyncio.sleep(0.1)
await self.websocket.send_bytes(self._encode_ws_handshake(), compress=0)
await asyncio.sleep(0.1)
await self.websocket.send_bytes(self._encode_gw_handshake(), compress=0)
await asyncio.sleep(0.1)
await self.websocket.send_bytes(self._encode_gw_register(), compress=0)
EDIT: realized the syntax changed
I thought I was comfortable, but I can't seem to find the correct github library that contains the alexawebsocket.py file. Can you point me in the right direction for the basics? I guess that I just have to dump the correct alexapy directory in the custom_components, right? Thanks!
This entry describes how you can install alexapy into custom_components
. You'll need to remove the directory later or it'll always use that version.
Installed it and changed alexawebsocket.py, but it doesn't seem to use the custom_components/alexapy as you can see here:
2020-03-12 01:33:02 DEBUG (MainThread) [alexapy.alexawebsocket] WebSocket Connection Closed. <Task finished coro=<WebsocketEchoClient.process_messages() done, defined at /usr/local/lib/python3.7/site-packages/alexapy/alexawebsocket.py:146> result=None>
Anything else I'm missing to add/configure here?
You need to run the pip3 install --target /config --no-dependencies alexapy
command in the right python environment so it knows you have a custom_components install. Just copying the library there isn't enough.
Got it working now, but I'm afraid it didn't make a change:
2020-03-12 10:15:43 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Existing: [<Entity TV: standby>, <Entity Bathroom: idle>, <Entity Kitchen: standby>, <Entity Livingroom: standby>, <Entity Frank's Echo Dot: standby>, <Entity This Device: standby>, <Entity Frank's Alexa Apps: unavailable>] New: []; Filtered out by not being in include: [] or in exclude: [] 2020-03-12 10:15:43 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'> 2020-03-12 10:15:43 DEBUG (MainThread) [alexapy.alexawebsocket] WebSocket Connection Closed. <Task finished coro=<WebsocketEchoClient.process_messages() done, defined at /config/alexapy/alexawebsocket.py:146> result=None> 2020-03-12 10:15:43 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Received websocket error #2 <class 'aiohttp.streams.EofStream'>
Let me know, if you want me to test anything else.
Can you provide the full websocket connection cycle starting from Connecting to wss://dp
?
I want to check the full handshake is succeeding. My next thought was trying to extend the time between the registration packets from the 0.1 that it's set to right now for the sleep command.
Here you go:
2020-03-14 21:23:24 DEBUG (MainThread) [alexapy.alexawebsocket] Connecting to wss://dp-gw-na-js.amazon.com/?x-amz-device-type=ALEGCNGL9K0HM&x-amz-device-serial=131-1488076-9651502-1584217404000 with {'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': '*', 'Referer': 'https://alexa.amazon.com/spa/index.html', 'Cookie': 'session-id=137-4104098-5510033; session-id-time=2214937143l; ubid-main=131-1488076-9651502; session-token=PTuRouseVJwGOzLdQA4jb+8NO9Od9WMcZ5ZLgh0Xpa16nwTlghEXAVpadBvzetQMBba9QV7/r0KptiX/+2UVaRgqSsNIyUDTRsIOKoip0/FPlVHtzt+YOEi+CiMOu6SL7LNk2UhyunF2fBVPQQFyXkfzYL2rrjMFNxLugrVv89mJWCYCOWBpK9UsxKUlaJCczSt33oCjMBcmrY98xkcqdp6yC7wq/AhC/jh5wdHHx3E=; x-main=a3nzFbdF9@zVTTy@U83MdXJOdYo8Vjv4aha69vxO@qQ59ucMl0q@H1T@UA9bu9e3; at-main=Atza|IwEBIBjmSz1Qs4gDRUHWyL34SP_Utc1oChan3JKPCFMnewArFtmH9swpwllq5lG20WdocuMC9lyG369OeBTX8s3qGKDiqbW4iYUVKuyZq24wtm0vHPIxDe-n98DmJPijAcCPbI_GpZ-Okyzi27b-4Aus2Pin-RciDYM8gcPKmHoK7NWzIFxpqsrYJFGQgxJaCYnDKMIZo85gGz5JcRzB8snKKL-PLJsZD_x7nI0UmANoS1gTe3Txu1D8jlnaJ1HQ99D5Q59XbU59zhjANc5P2776g43SlVaKNJ_u4kFFF4KBcB6GlLvoi5DOgpbWU7rc_5dVrbxCpYzCbgM7w7jA1EDJA92f-l899xlCTkG4tCcwS0Bvi1OtPzMfQP7bBcRQQ-VyN7QShS-MFQurX6xGTV3Lrgr9; sess-at-main=yWwGA043qqn5+RYEvT2zEQ9AwBctDzZVWRAWg5wFf80=; csrf=-718429675; ', 'Origin': 'https://alexa.amazon.com', 'csrf': '-718429675'}
2020-03-14 21:23:24 DEBUG (MainThread) [alexapy.alexawebsocket] Initating Async Handshake.
2020-03-14 21:23:24 DEBUG (MainThread) [alexapy.alexawebsocket] Starting message parsing loop.
2020-03-14 21:23:24 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding WebSocket Handshake MSG.
2020-03-14 21:23:24 DEBUG (MainThread) [alexapy.alexawebsocket] Received WebSocket: 0xbafef3f3 0x000000cd {"protocolName":"A:H","parameters":{"AlphaProtocolHandler.supportedEncodings":"GZIP","AlphaProtocolHandler.maxFragmentSize":"16000","AlphaProtocolHandler.receiveWindowSize":"16"}}TUNE
2020-03-14 21:23:24 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding Gateway Handshake MSG.
2020-03-14 21:23:24 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
2020-03-14 21:23:24 DEBUG (MainThread) [alexapy.alexawebsocket] WebSocket Connection Closed. <Task finished coro=<WebsocketEchoClient.process_messages() done, defined at /config/alexapy/alexawebsocket.py:146> result=None>
2020-03-14 21:23:24 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Received websocket error #0 <class 'aiohttp.streams.EofStream'>
2020-03-14 21:23:24 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding Gateway Register MSG.
2020-03-14 21:23:24 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Websocket succesfully connected
2020-03-14 21:23:24 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Websocket closed; retries exceeded; polling
2020-03-14 21:23:24 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Websocket closed; reconnect #3 in 40s
2020-03-14 21:23:24 DEBUG (MainThread) [alexapy.alexawebsocket] Received WebSocket: MSG 0x00000361 0x262793f7 f 0x00000001 0xa7ba147f 0x000000b9 ACK 0x00000003 1.0 0x00000024 01e09e62-f504-476c-85c8-9c97c8da26ed 0x00000064 0x0000016978ff598c 0x00000170dab78ea2 END FABE
2020-03-14 21:23:24 DEBUG (MainThread) [alexapy.alexawebsocket] Received ACK MSG for Registration.
2020-03-14 21:23:25 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Websocket created: <alexapy.alexawebsocket.WebsocketEchoClient object at 0x7ff32281bd10>
2020-03-14 21:23:25 DEBUG (MainThread) [alexapy.alexawebsocket] Connecting to wss://dp-gw-na-js.amazon.com/?x-amz-device-type=ALEGCNGL9K0HM&x-amz-device-serial=131-1488076-9651502-1584217405000 with {'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': '*', 'Referer': 'https://alexa.amazon.com/spa/index.html', 'Cookie': 'session-id=137-4104098-5510033; session-id-time=2214937143l; ubid-main=131-1488076-9651502; session-token=PTuRouseVJwGOzLdQA4jb+8NO9Od9WMcZ5ZLgh0Xpa16nwTlghEXAVpadBvzetQMBba9QV7/r0KptiX/+2UVaRgqSsNIyUDTRsIOKoip0/FPlVHtzt+YOEi+CiMOu6SL7LNk2UhyunF2fBVPQQFyXkfzYL2rrjMFNxLugrVv89mJWCYCOWBpK9UsxKUlaJCczSt33oCjMBcmrY98xkcqdp6yC7wq/AhC/jh5wdHHx3E=; x-main=a3nzFbdF9@zVTTy@U83MdXJOdYo8Vjv4aha69vxO@qQ59ucMl0q@H1T@UA9bu9e3; at-main=Atza|IwEBIBjmSz1Qs4gDRUHWyL34SP_Utc1oChan3JKPCFMnewArFtmH9swpwllq5lG20WdocuMC9lyG369OeBTX8s3qGKDiqbW
Thanks, let's try another edit. It's the same file. Need you to add another sleep(0.5)
at line 259.
async def async_on_open(self) -> None:
"""Handle Async WebSocket Open."""
_LOGGER.debug("Initating Async Handshake.")
await self.websocket.send_bytes(bytes("0x99d4f71a 0x0000001d A:HTUNE", "utf-8"))
await asyncio.sleep(0.1)
await self.websocket.send_bytes(self._encode_ws_handshake())
await asyncio.sleep(0.1)
await self.websocket.send_bytes(self._encode_gw_handshake())
await asyncio.sleep(0.1)
await self.websocket.send_bytes(self._encode_gw_register())
await asyncio.sleep(0.5)
if not self.websocket.closed:
await self.open_callback()
I both tried with and without the compress=0 which we added earlier, but no difference there:
2020-03-15 19:17:11 DEBUG (MainThread) [alexapy.alexawebsocket] Connecting to wss://dp-gw-na-js.amazon.com/?x-amz-device-type=ALEGCNGL9K0HM&x-amz-device-serial=131-1488076-9651502-1584296231000 with {'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': '*', 'Referer': 'https://alexa.amazon.com/spa/index.html', 'Cookie': 'session-id=137-4104098-5510033; session-id-time=2214937143l; ubid-main=131-1488076-9651502; session-token=PTuRouseVJwGOzLdQA4jb+8NO9Od9WMcZ5ZLgh0Xpa16nwTlghEXAVpadBvzetQMBba9QV7/r0KptiX/+2UVaRgqSsNIyUDTRsIOKoip0/FPlVHtzt+YOEi+CiMOu6SL7LNk2UhyunF2fBVPQQFyXkfzYL2rrjMFNxLugrVv89mJWCYCOWBpK9UsxKUlaJCczSt33oCjMBcmrY98xkcqdp6yC7wq/AhC/jh5wdHHx3E=; x-main=a3nzFbdF9@zVTTy@U83MdXJOdYo8Vjv4aha69vxO@qQ59ucMl0q@H1T@UA9bu9e3; at-main=Atza|IwEBIBjmSz1Qs4gDRUHWyL34SP_Utc1oChan3JKPCFMnewArFtmH9swpwllq5lG20WdocuMC9lyG369OeBTX8s3qGKDiqbW4iYUVKuyZq24wtm0vHPIxDe-n98DmJPijAcCPbI_GpZ-Okyzi27b-4Aus2Pin-RciDYM8gcPKmHoK7NWzIFxpqsrYJFGQgxJaCYnDKMIZo85gGz5JcRzB8snKKL-PLJsZD_x7nI0UmANoS1gTe3Txu1D8jlnaJ1HQ99D5Q59XbU59zhjANc5P2776g43SlVaKNJ_u4kFFF4KBcB6GlLvoi5DOgpbWU7rc_5dVrbxCpYzCbgM7w7jA1EDJA92f-l899xlCTkG4tCcwS0Bvi1OtPzMfQP7bBcRQQ-VyN7QShS-MFQurX6xGTV3Lrgr9; sess-at-main=yWwGA043qqn5+RYEvT2zEQ9AwBctDzZVWRAWg5wFf80=; csrf=-718429675; ', 'Origin': 'https://alexa.amazon.com', 'csrf': '-718429675'} 2020-03-15 19:17:11 DEBUG (MainThread) [alexapy.alexawebsocket] Initating Async Handshake. 2020-03-15 19:17:11 DEBUG (MainThread) [alexapy.alexawebsocket] Starting message parsing loop. 2020-03-15 19:17:11 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding WebSocket Handshake MSG. 2020-03-15 19:17:11 DEBUG (MainThread) [alexapy.alexawebsocket] Received WebSocket: 0xe891f630 0x000000cd {"parameters":{"AlphaProtocolHandler.supportedEncodings":"GZIP","AlphaProtocolHandler.maxFragmentSize":"16000","AlphaProtocolHandler.receiveWindowSize":"16"},"protocolName":"A:H"}TUNE 2020-03-15 19:17:11 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding Gateway Handshake MSG. 2020-03-15 19:17:11 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding Gateway Register MSG. 2020-03-15 19:17:11 DEBUG (MainThread) [alexapy.alexawebsocket] Received WebSocket: MSG 0x00000361 0x03b33a14 f 0x00000001 0x9e8416d4 0x000000b9 ACK 0x00000003 1.0 0x00000024 01e09e62-f504-476c-85c8-9c97c8da26ed 0x00000064 0x0000016978ff598c 0x00000170df6a62db END FABE 2020-03-15 19:17:11 DEBUG (MainThread) [alexapy.alexawebsocket] Received ACK MSG for Registration. 2020-03-15 19:17:12 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Websocket succesfully connected 2020-03-15 19:17:12 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Websocket closed; retries exceeded; polling 2020-03-15 19:17:12 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Websocket closed; reconnect #4 in 80s 2020-03-15 19:17:12 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'> 2020-03-15 19:17:12 DEBUG (MainThread) [alexapy.alexawebsocket] WebSocket Connection Closed. <Task finished coro=<WebsocketEchoClient.process_messages() done, defined at /config/alexapy/alexawebsocket.py:146> result=None> 2020-03-15 19:17:12 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Received websocket error #0 <class 'aiohttp.streams.EofStream'> 2020-03-15 19:17:14 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Websocket created: <alexapy.alexawebsocket.WebsocketEchoClient object at 0x7f12eb8bf050>
Can you try this PR to see if it helps? If not, please provide the logs.
Thanks, it seems to help a bit:
2020-03-25 11:24:57 DEBUG (MainThread) [alexapy.alexawebsocket] Connecting to wss://dp-gw-na-js.amazon.com/?x-amz-device-type=ALEGCNGL9K0HM&x-amz-device-serial=131-1488076-9651502-1585131897000 with {'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': '*', 'Referer': 'https://alexa.amazon.com/spa/index.html', 'Cookie': 'session-id=137-4104098-5510033; session-id-time=2214937143l; ubid-main=131-1488076-9651502; session-token=PTuRouseVJwGOzLdQA4jb+8NO9Od9WMcZ5ZLgh0Xpa16nwTlghEXAVpadBvzetQMBba9QV7/r0KptiX/+2UVaRgqSsNIyUDTRsIOKoip0/FPlVHtzt+YOEi+CiMOu6SL7LNk2UhyunF2fBVPQQFyXkfzYL2rrjMFNxLugrVv89mJWCYCOWBpK9UsxKUlaJCczSt33oCjMBcmrY98xkcqdp6yC7wq/AhC/jh5wdHHx3E=; x-main=a3nzFbdF9@zVTTy@U83MdXJOdYo8Vjv4aha69vxO@qQ59ucMl0q@H1T@UA9bu9e3; at-main=Atza|IwEBIBjmSz1Qs4gDRUHWyL34SP_Utc1oChan3JKPCFMnewArFtmH9swpwllq5lG20WdocuMC9lyG369OeBTX8s3qGKDiqbW4iYUVKuyZq24wtm0vHPIxDe-n98DmJPijAcCPbI_GpZ-Okyzi27b-4Aus2Pin-RciDYM8gcPKmHoK7NWzIFxpqsrYJFGQgxJaCYnDKMIZo85gGz5JcRzB8snKKL-PLJsZD_x7nI0UmANoS1gTe3Txu1D8jlnaJ1HQ99D5Q59XbU59zhjANc5P2776g43SlVaKNJ_u4kFFF4KBcB6GlLvoi5DOgpbWU7rc_5dVrbxCpYzCbgM7w7jA1EDJA92f-l899xlCTkG4tCcwS0Bvi1OtPzMfQP7bBcRQQ-VyN7QShS-MFQurX6xGTV3Lrgr9; sess-at-main=yWwGA043qqn5+RYEvT2zEQ9AwBctDzZVWRAWg5wFf80=; csrf=-718429675; ', 'Origin': 'https://alexa.amazon.com', 'csrf': '-718429675'} 2020-03-25 11:24:57 DEBUG (MainThread) [alexapy.alexawebsocket] Initating Async Handshake. 2020-03-25 11:24:57 DEBUG (MainThread) [alexapy.alexawebsocket] Starting message parsing loop. 2020-03-25 11:24:57 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding WebSocket Handshake MSG. 2020-03-25 11:24:57 DEBUG (MainThread) [alexapy.alexawebsocket] Received WebSocket: 0xe891f630 0x000000cd {"parameters":{"AlphaProtocolHandler.supportedEncodings":"GZIP","AlphaProtocolHandler.maxFragmentSize":"16000","AlphaProtocolHandler.receiveWindowSize":"16"},"protocolName":"A:H"}TUNE 2020-03-25 11:24:57 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding Gateway Handshake MSG. 2020-03-25 11:24:58 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding Gateway Register MSG. 2020-03-25 11:24:58 DEBUG (MainThread) [alexapy.alexawebsocket] Received WebSocket: MSG 0x00000361 0x20493dcb f 0x00000001 0xcd8312b0 0x000000b9 ACK 0x00000003 1.0 0x00000024 01e09e62-f504-476c-85c8-9c97c8da26ed 0x00000064 0x0000016978ff598c 0x000001711139ddca END FABE 2020-03-25 11:24:58 DEBUG (MainThread) [alexapy.alexawebsocket] Received ACK MSG for Registration.
Around 400 lines later filled with:
2020-03-25 11:24:58 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Websocket succesfully connected 2020-03-25 11:25:00 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/devices-v2/device returned 200:OK:application/json 2020-03-25 11:25:00 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/bluetooth?cached=false returned 200:OK:application/json 2020-03-25 11:25:01 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/device-preferences returned 200:OK:application/json 2020-03-25 11:25:01 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/dnd/device-status-list returned 200:OK:application/json 2020-03-25 11:25:01 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/notifications returned 200:OK:application/json 2020-03-25 11:25:01 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Found 7 devices, 7 bluetooth 2020-03-25 11:25:02 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/notifications returned 200:OK:application/json 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Updated 0 notifications for 1 devices at 2020-03-25 11:25:02.085589+01:00 2020-03-25 11:25:02 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/activities?startTime=&size=10&offset=1 returned 200:OK:application/json 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Updated last_called: {'serialNumber': 'G************H3S', 'timestamp': 1585078200911} 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] TV: Locale en-us timezone None 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] TV: DND False 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] Bathroom: Locale en-us timezone None 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] Bathroom: DND False 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] Kitchen: Locale en-us timezone None 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] Kitchen: DND False 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] Livingroom: Locale en-us timezone None 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] Livingroom: DND False 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] Frank's Echo Dot: Locale en-us timezone Europe/Copenhagen 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] Frank's Echo Dot: DND False 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] This Device: Locale en-gb timezone Europe/Copenhagen 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] This Device: DND False 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] Frank's Alexa Apps: Locale en-us timezone Europe/Copenhagen 2020-03-25 11:25:02 DEBUG (MainThread) [custom_components.alexa_media] Frank's Alexa Apps: DND False
I'm getting the EoFStream again:
2020-03-25 11:25:58 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'> 2020-03-25 11:25:58 DEBUG (MainThread) [alexapy.alexawebsocket] WebSocket Connection Closed. <Task finished coro=<WebsocketEchoClient.process_messages() done, defined at /config/alexapy/alexawebsocket.py:146> result=None> 2020-03-25 11:25:58 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Received websocket error #1 <class 'aiohttp.streams.EofStream'>: type <class 'str'> 2020-03-25 11:25:58 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Immediate abort on EoFstream 2020-03-25 11:25:58 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Websocket closed; reconnect #2 in 20s 2020-03-25 11:25:58 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Websocket created: <alexapy.alexawebsocket.WebsocketEchoClient object at 0x7f95e2d80550>
Can you try the new version I just pushed please?
Thanks, I did it and this is the result:
2020-03-30 00:20:15 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Websocket created: <alexapy.alexawebsocket.WebsocketEchoClient object at 0x7f837ef11290> 2020-03-30 00:20:15 DEBUG (MainThread) [alexapy.alexawebsocket] Connecting to wss://dp-gw-na-js.amazon.com/?x-amz-device-type=ALEGCNGL9K0HM&x-amz-device-serial=131-1488076-9651502-1585520415000 with {'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': '*', 'Referer': 'https://alexa.amazon.com/spa/index.html', 'Cookie': 'session-id=137-4104098-5510033; session-id-time=2216240210l; ubid-main=131-1488076-9651502; session-token=xnqIeBHZf2So503jr83wnN0aMXtbMedL86NVfZlq7JULLjDM9LMcf5rlMzb0OiZpUOIVbcy04WC5NRplCH/ONJU5Dw3In05E1YaW3vKMxIl2+oiDwQtViKKho7m2FVJ1KJmedibyLWZ1So6cMGEBMPMM0sBnIxOwIJkUubSVIKz80TzI81uX3dQdO4g0+7zbBbL03oCBBp5u2XNB+s5fgXO1RsPvSzUH+Fds0aJeLqA=; x-main=hC@KQWju7iP0aO9kkwAibeBG55KraPM7UN0JikDjPR2noFNRw09?ABJGyNklOCrU; at-main=Atza|IwEBIKKTOQdHlqEWVSxrrDQ7I3bAn1fPcP9k2zgRxz8o25aOTrOe7xDtdNeyOpdERRhvuCQCsHH_QvBRqeRgDd8To6CMke9IClVCClOwvU0ups6GOoO-VphW3sxpQvW5pixk7JCr8-YmtHKaJfOFd_a8Xa-QNYNnJXLAv2fOiZf3M7paOGazIDzd9pU4f32Wn5d2wvZdCBv_NwnrQUmg1ah9Qs1_NhSzZzhc2l46y9vMBoQ8xrVffIOw4yZT3gG7yjy7p77aAQB5LQB0HbDTAnPyev3JJM-Yzc40mHUk8HRt9aah1_Gn7UXwvIqbKl55dHYkTxh-x3YzPilGpjfCRywsoI-trQmWzGu929UsZ0wLj4GrQ-htNQyJJhrNV8lnaEqljKLN8uMtZtvvv-3kOxpz98Q7; sess-at-main=3plA5cdfASzjhU65ufeKJcdToutSdImCkmM6bCwiqTA=; csrf=-718429675; ', 'Origin': 'https://alexa.amazon.com', 'csrf': '-718429675'} 2020-03-30 00:20:17 DEBUG (MainThread) [alexapy.alexawebsocket] Initating Async Handshake. 2020-03-30 00:20:17 DEBUG (MainThread) [alexapy.alexawebsocket] Starting message parsing loop. 2020-03-30 00:20:17 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding WebSocket Handshake MSG. 2020-03-30 00:20:17 DEBUG (MainThread) [alexapy.alexawebsocket] Received WebSocket: 0xbafef3f3 0x000000cd {"protocolName":"A:H","parameters":{"AlphaProtocolHandler.supportedEncodings":"GZIP","AlphaProtocolHandler.maxFragmentSize":"16000","AlphaProtocolHandler.receiveWindowSize":"16"}}TUNE 2020-03-30 00:20:17 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding Gateway Handshake MSG. 2020-03-30 00:20:17 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding Gateway Register MSG. 2020-03-30 00:20:17 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding PING. 2020-03-30 00:20:17 DEBUG (MainThread) [alexapy.alexawebsocket] Received WebSocket: MSG 0x00000361 0x438aaad5 f 0x00000001 0x9eb8177f 0x000000b9 ACK 0x00000003 1.0 0x00000024 01e09e62-f504-476c-85c8-9c97c8da26ed 0x00000064 0x0000016978ff598c 0x0000017128619be3 END FABE 2020-03-30 00:20:17 DEBUG (MainThread) [alexapy.alexawebsocket] Received ACK MSG for Registration. 2020-03-30 00:20:18 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Websocket succesfully connected 2020-03-30 00:20:28 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Websocket closed; retries exceeded; polling 2020-03-30 00:20:29 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/devices-v2/device returned 200:OK:application/json 2020-03-30 00:20:29 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/bluetooth?cached=false returned 200:OK:application/json 2020-03-30 00:20:30 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/device-preferences returned 200:OK:application/json 2020-03-30 00:20:30 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/dnd/device-status-list returned 200:OK:application/json 2020-03-30 00:20:31 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/notifications returned 200:OK:application/json 2020-03-30 00:20:31 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Found 7 devices, 7 bluetooth 2020-03-30 00:20:31 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/notifications returned 200:OK:application/json 2020-03-30 00:20:31 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Updated 0 notifications for 1 devices at 2020-03-30 00:20:31.846118+02:00 2020-03-30 00:20:32 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/activities?startTime=&size=10&offset=1 returned 200:OK:application/json 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Updated last_called: {'serialNumber': 'G************H3S', 'timestamp': 1585337419740} 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] TV: Locale en-us timezone None 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] TV: DND False 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] Bathroom: Locale en-us timezone None 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] Bathroom: DND False 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] Kitchen: Locale en-us timezone None 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] Kitchen: DND False 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] Livingroom: Locale en-us timezone None 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] Livingroom: DND False 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] Frank's Echo Dot: Locale en-us timezone Europe/Copenhagen 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] Frank's Echo Dot: DND False 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] This Device: Locale en-gb timezone Europe/Copenhagen 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] This Device: DND False 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] Frank's Alexa Apps: Locale en-us timezone Europe/Copenhagen 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] Frank's Alexa Apps: DND False 2020-03-30 00:20:32 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Existing: [<Entity TV: standby>, <Entity Bathroom: idle>, <Entity Kitchen: paused>, <Entity Livingroom: standby>, <Entity Frank's Echo Dot: standby>, <Entity This Device: standby>, <Entity Frank's Alexa Apps: unavailable>] New: []; Filtered out by not being in include: [] or in exclude: [] 2020-03-30 00:21:17 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'> 2020-03-30 00:21:17 DEBUG (MainThread) [alexapy.alexawebsocket] WebSocket Connection Closed. <Task finished coro=<WebsocketEchoClient.process_messages() done, defined at /usr/local/lib/python3.7/site-packages/alexapy/alexawebsocket.py:146> result=None> 2020-03-30 00:21:17 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Received websocket error #1 <class 'aiohttp.streams.EofStream'>: type <class 'str'> 2020-03-30 00:21:17 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Immediate abort on EoFstream 2020-03-30 00:21:17 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Websocket closed; reconnect #2 in 20s
Ok, new version pushed.
Thanks, this seemed to do the trick.
After a restart, I get the first and only entry of EofStream:
2020-03-30 09:20:14 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'> 2020-03-30 09:20:14 DEBUG (MainThread) [alexapy.alexawebsocket] WebSocket Connection Closed. <Task finished coro=<WebsocketEchoClient.process_messages() done, defined at /usr/local/lib/python3.7/site-packages/alexapy/alexawebsocket.py:146> result=None> 2020-03-30 09:20:14 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Received websocket error #0 <class 'aiohttp.streams.EofStream'>: type <class 'str'> 2020-03-30 09:20:14 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Immediate abort on EoFstream
After around 10 minutes with nothing in the log, it repeats the following again and again:
2020-03-30 09:40:00 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/devices-v2/device returned 200:OK:application/json 2020-03-30 09:40:01 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/bluetooth?cached=false returned 200:OK:application/json 2020-03-30 09:40:01 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/device-preferences returned 200:OK:application/json 2020-03-30 09:40:02 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/dnd/device-status-list returned 200:OK:application/json 2020-03-30 09:40:02 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/notifications returned 200:OK:application/json 2020-03-30 09:40:02 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Found 4 devices, 4 bluetooth 2020-03-30 09:40:03 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/notifications returned 200:OK:application/json 2020-03-30 09:40:03 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Updated 0 notifications for 1 devices at 2020-03-30 09:40:03.284326+02:00 2020-03-30 09:40:04 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/activities?startTime=&size=10&offset=1 returned 200:OK:application/json 2020-03-30 09:40:04 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Updated last_called: {'serialNumber': 'G************H3S', 'timestamp': 1585337419740} 2020-03-30 09:40:04 DEBUG (MainThread) [custom_components.alexa_media] Kitchen: Locale en-us timezone None 2020-03-30 09:40:04 DEBUG (MainThread) [custom_components.alexa_media] Kitchen: DND False 2020-03-30 09:40:04 DEBUG (MainThread) [custom_components.alexa_media] Frank's Echo Dot: Locale en-us timezone Europe/Copenhagen 2020-03-30 09:40:04 DEBUG (MainThread) [custom_components.alexa_media] Frank's Echo Dot: DND False 2020-03-30 09:40:04 DEBUG (MainThread) [custom_components.alexa_media] This Device: Locale en-gb timezone Europe/Copenhagen 2020-03-30 09:40:04 DEBUG (MainThread) [custom_components.alexa_media] This Device: DND False 2020-03-30 09:40:04 DEBUG (MainThread) [custom_components.alexa_media] Frank's Alexa Apps: Locale en-us timezone Europe/Copenhagen 2020-03-30 09:40:04 DEBUG (MainThread) [custom_components.alexa_media] Frank's Alexa Apps: DND False 2020-03-30 09:40:04 DEBUG (MainThread) [custom_components.alexa_media] f***************n@g*******m: Existing: [<Entity Kitchen: paused>, <Entity Frank's Echo Dot: standby>, <Entity This Device: standby>, <Entity Frank's Alexa Apps: unavailable>] New: []; Filtered out by not being in include: [] or in exclude: []
Is this normal behaviour?
Yes. If it isn't using websockets, the only way it can determine what is happening is with polling.
Thanks for all the help, @alandtse! :)
Everything is working as expected, but my HA logfile is showing 'aiohttp.streams.EofStream' twice every minute. Like these: 2020-03-03 14:04:56 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'> 2020-03-03 14:05:06 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'> 2020-03-03 14:05:27 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'> 2020-03-03 14:06:07 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'> 2020-03-03 14:06:08 ERROR (MainThread) [alexapy.alexawebsocket] WebSocket Error: <class 'aiohttp.streams.EofStream'>
To Reproduce With or without using the Alexa Media Player, the logfile shows the error around two times per minute.
Expected behavior Is this normal or not? :)
System details
Logs