AmbientWeather Websocket Errors [aioambient]

This is normal to see in the SYSLOG:

2023-06-08 11:31:52.581 INFO (MainThread) [aioambient] Attempting WebSocket connection to wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=a43e37ab30374fc5856c4a3a88a6125e7305e36182d64eea89969c01e53100fb&transport=websocket&EIO=3

…and then a “ping” and “pong” type messages showing the “aioambient” connection is alive…

…but this keeps appearing instead:

2023-06-08 11:31:52.673 INFO (MainThread) [aioambient] Connection failed, new attempt in 5.41 seconds

Unable to see the external temp on the default Lovelace panel… “unknown”

I’ve been having trouble with this since last night. I have made too many recent config changes to really pin down the cause here. I moved HA from a VM to a real machine last night; it has never worked on the new machine, but also stopped working on the VM. But, I upgraded the VM before the move, and wasn’t really paying attention as to whether or not the integration was working at the time. I’ve done some debugging with websocat; last night it was 503-ing 100% of the time, today it 502s some % of the time, but also sometimes works. For example:

$ websocat 'wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=<working app key>&transport=websocket&EIO=3'
websocat: WebSocketError: WebSocketError: Received unexpected status code (502 Bad Gateway)

$ websocat 'wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=<working app key>&transport=websocket&EIO=3' -v
[INFO  websocat::lints] Auto-inserting the line mode
[INFO  websocat::stdio_threaded_peer] get_stdio_peer (threaded)
[INFO  websocat::ws_client_peer] get_ws_client_peer
[INFO  websocat::ws_client_peer] Connected to ws
0{"sid":"4peWAtrBjPsxeixjABDA","upgrades":[],"pingInterval":25000,"pingTimeout":20000}
[INFO  websocat::ws_peer] incoming None
[INFO  websocat::sessionserve] Reverse finished

It seems like they might be having some server trouble, but because I have changed so much in my setup at about the same time any downtime might have started, I can’t blame them for sure.

I poked at this a little more and am seeing some signs of life from the rt2 .ambientweather .net server:

2023-06-08 16:20:11.998 INFO (MainThread) [aioambient] Attempting WebSocket connection to wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=ad6b16ce523a4c66a8bd4fe08050c3d153bad6aecd1249d68815ae5441503923&transport=websocket&EIO=3                                                                                                                       2023-06-08 16:20:17.497 INFO (MainThread) [aioambient] WebSocket connection accepted with {'sid': 'OD3nHwUrgFwUrfI4ABQQ', 'upgrades': [], 'pingInterval': 25000, 'pingTimeout': 20000}                                                                                                                                                                                  2023-06-08 16:20:17.497 INFO (MainThread) [aioambient] Engine.IO connection established                                                                                             2023-06-08 16:20:17.497 INFO (MainThread) [aioambient] Reconnection successful                                                                                                      2023-06-08 16:20:17.498 INFO (MainThread) [aioambient] Sending packet PING data None                                                                                                2023-06-08 16:20:20.112 INFO (MainThread) [aioambient] Received packet PONG data None                                                                                               2023-06-08 16:20:20.631 INFO (MainThread) [aioambient] Unexpected error receiving packet: "WebSocket read returned None", aborting                                                  2023-06-08 16:20:20.631 INFO (MainThread) [aioambient] Waiting for write loop task to end                                                                                           2023-06-08 16:20:20.631 INFO (MainThread) [aioambient] Exiting write loop task                                                                                                      2023-06-08 16:20:20.631 INFO (MainThread) [aioambient] Waiting for ping loop task to end                                                                                            2023-06-08 16:20:20.632 INFO (MainThread) [aioambient] Sending packet PING data None                                                                                                2023-06-08 16:20:20.632 INFO (MainThread) [aioambient] PONG response has not been received, aborting
2023-06-08 16:20:20.632 INFO (MainThread) [aioambient] Exiting ping task                                                                                                            2023-06-08 16:20:20.632 INFO (MainThread) [aioambient] Engine.IO connection dropped                                                                                                 2023-06-08 16:20:20.632 INFO (MainThread) [homeassistant.components.ambient_station] Disconnected from websocket
2023-06-08 16:20:20.633 INFO (MainThread) [aioambient] Exiting read loop task                                                                                                       2023-06-08 16:20:20.633 INFO (MainThread) [aioambient] Connection failed, new attempt in 1.21 seconds
2023-06-08 16:20:21.845 INFO (MainThread) [aioambient] Attempting WebSocket connection to wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=ad6b16ce523a4c66a8bd4fe08050c3d153bad6aecd1249d68815ae5441503923&transport=websocket&EIO=3                                                                                                                       2023-06-08 16:20:31.091 INFO (MainThread) [aioambient] Connection failed, new attempt in 2.17 seconds
2023-06-08 16:20:33.259 INFO (MainThread) [aioambient] Attempting WebSocket connection to wss://rt2.ambientweather.net/socket.io/?api=1&applicationKey=ad6b16ce523a4c66a8bd4fe08050c3d153bad6aecd1249d68815ae5441503923&transport=websocket&EIO=3                                                                                                                       

I tried some aioambient test scripts against rt. ambientweather. net and it worked, so I think it’s server problems. Unfortunately, the rt2. ambientweather. net host is hard-coded in aioambient, so if that’s the solution, we need to PR that repo, then PR home assistant to have them upgrade the version of aioambient.

(Sorry for the weird formatting; the forum software thinks I’m spamming links.)

And, it magically fixed itself. Guess it was a server thing.