kovacsbalu / WazeRouteCalculator

Calculate actual route time and distance with Waze api
GNU General Public License v3.0
144 stars 57 forks source link

Fix Empty response error. #37

Closed Petro31 closed 5 years ago

Petro31 commented 5 years ago

So alot of users with home assistant have been reporting errors coming from WazeRouteCalculator. These errors are essentially emtpy response or Internal Error which come directly from waze. I've tracked the error down to one simple fact. If you make a route request to the wrong server first, the subsequent requests get ignored or also fail. This must be new to the API because it wasn't always like this. So the fix is the use location based routing server requests. Similar to how the COORD_SERVERS work.

I tested this in a build of home assistant with 11 separate routes. 3 in US using PRIVATE, TAXI, and MOTORCYCLE, 3 in EU using PRIVATE, TAXI, and MOTORCYCLE, 3 in IL using PRIVATE, TAXI, and MOTORCYCLE, and 2 others in IL and EU (random ones just for testing home assistant settings). In this test calculate_all_routes getting performed twice a minute for a maximum of 1320 requests per hour.

Prior to PR, roughly 776 errors per hour.

After PR, roughly 124 errors per hour. 124 errors was my mistake, searching for an IL route inside the EU. After fixing that on my end the errors went down to roughly 0 inside an hour with requests being made every 30 seconds.

The current 124 errors seem to plague Taxi routes in EU and Motorcycle routes in IL. I'm not 100% sure what is causing that problem. However, the private routes had about 4 errors for the hour among the 4 routes.

hmmbob commented 5 years ago

You might also want to have a look at "rate limiting" with multiple Waze sensors - it seems that (at least in my setup) the first request will go through, but the other requests done at more or less the same time get an empty response back. The author of WazeRouteCalculator earlier indicated that this might point at "too many requests" at the same time.

By the way, the sensors that initially fail will update fine after 5 mins, the default update time in HA.

Petro31 commented 5 years ago

You might also want to have a look at "rate limiting" with multiple Waze sensors - it seems that (at least in my setup) the first request will go through, but the other requests done at more or less the same time get an empty response back. The author of WazeRouteCalculator earlier indicated that this might point at "too many requests" at the same time.

By the way, the sensors that initially fail will update fine after 5 mins, the default update time in HA.

Well, I've ran more tests. And it turns out that most of the 124 errors per hour was my mistake. I was searching for IL routes in the EU. So this pretty much reduces the number of errors per hour to close to zero.

I don't think we'll need to use rate limiting.

Petro31 commented 5 years ago

By the way, the sensors that initially fail will update fine after 5 mins, the default update time in HA.

Yes, I pretty much wrote the waze_travel_time.py. I still haven't figured out why they fail on startup. Me and a few others have tried all sorts of different startup settings. Nothing has worked. It's rather annoying. It appears to be 100% HA side now that when I use this PR in home assistant.

coveralls commented 5 years ago

Coverage Status

Coverage increased (+0.9%) to 95.798% when pulling 45963826dc1f35c63150faaaa8b43d595dc104c7 on Petro31:patch-1 into 3384b35aef9cdf58b750a374d0f874c39e162f1c on kovacsbalu:master.