ambient-weather / api-docs

AmbientWeather.net API Documentation
64 stars 42 forks source link

API fails with https but works with http #25

Closed DaveDixon closed 4 years ago

DaveDixon commented 4 years ago

I was experiencing frequent failures with the homeassistant ambient_station component, so I downloaded the ambientweatheR code. It was giving me "An unexpected TLS packet was received" errors. I suspected an SSL-type problem, so I replaced https with http in the URLs, and it worked. And continues to work consistently. So I did the same with the ambient_station component, which then uses ws: instead of wss:, and it seems to be working consistently ever since. With SSL, the problem could be at my end, of course, but many homeassistant users are experiencing problems with ambient_station right now, so I'm wondering if there's an SSL certificate or similar problem on one of the Ambient Weather API servers.

owise1 commented 4 years ago

I'm seeing an SSL error too. hang tight

owise1 commented 4 years ago

@DaveDixon I believe this is a problem with CloudFlare using an erroneous SSL cert. Could you try changing the domain from "api.ambientweather.net" to "rt.ambientweather.net" and then going back to https? That endpoint seems to be ok. If that works I'd like to contact the original developer to have them update their code. do you have a link for it?

DaveDixon commented 4 years ago

The homeassistant code uses URL https://dash2.ambientweather.net

With the new URL it never even starts - it hangs on

"[engineio.client] Attempting WebSocket connection to wss://rt.ambientweather.net/socket.io/?api=1&applicationKey=..."

If I change the URL to http://rt.ambientweather.net and restart, it works.

DaveDixon commented 4 years ago

BTW, the RESTful code in ambientweatheR, which failed using https://api.ambientweather.net, works with https://rt.ambientweather.net

owise1 commented 4 years ago

thanks for looking into that. Until CloudFlare gets their end sorted out, the api -> rt change is going to have to be the workaround. "rt" will remain indefinitely so it's a safe long term fix. That is very strange about dash2 and rt because they are the same server. Is this a recent phenomena where realtime secure connections fail?

DaveDixon commented 4 years ago

This has been going on since Saturday. The HA community has seen it as randomly sporadic. I think it's a combination of unusual errors on the server side and incorrectly handling those errors on the client side.

The http fix stopped working, too, at 1417 this afternoon. Now, when I try the REST query from ambientweatheR, I get "Error: AmbientWeather API request failed [401] unknown-error".

DaveDixon commented 4 years ago

Have you done something different with the server? The websocket API has been working continuously for about 48 hours whereas before it had to be restarted every two hours on average.

owise1 commented 4 years ago

I have been tweaking things. is this still working for you?

DaveDixon commented 4 years ago

It's been running without problems since 2020-08-06 13:43:48. Thanks!