martijndierckx / homebridge-hydrawise

A homebridge plugin that creates sprinkler accessories for all your Hydrawise zones
13 stars 7 forks source link

Over-polling of the Hydrawise API #6

Closed joewilliamsca closed 4 years ago

joewilliamsca commented 5 years ago

Hi all,

Seeing this error coming from the plugin when I was setting it up in Homebridge today. The 429 from Request appears that I was making too many polling requests to the API. Has anyone else seen this error?

I have moved the polling interval to 30 seconds (30000) and it looks like its cut down on the errors being thrown in node, so I think this might be a throttling issue (unless Hunter wants to charge for API use)

Cheers, -Joe

Unhandled rejection StatusCodeError: 429 - undefined Jun 09 12:34:47 homekitbridge homebridge[21011]: at new StatusCodeError (/usr/lib/node_modules/homebridge-hydrawise/node_modules/request-promise/lib/errors.js:32:15) Jun 09 12:34:47 homekitbridge homebridge[21011]: at Request.RP$callback [as _callback] (/usr/lib/node_modules/homebridge-hydrawise/node_modules/request-promise/lib/rp.js:77:29) Jun 09 12:34:47 homekitbridge homebridge[21011]: at Request.self.callback (/usr/lib/node_modules/homebridge-hydrawise/node_modules/request/request.js:185:22) Jun 09 12:34:47 homekitbridge homebridge[21011]: at emitTwo (events.js:126:13) Jun 09 12:34:47 homekitbridge homebridge[21011]: at Request.emit (events.js:214:7) Jun 09 12:34:47 homekitbridge homebridge[21011]: at Request. (/usr/lib/node_modules/homebridge-hydrawise/node_modules/request/request.js:1161:10) Jun 09 12:34:47 homekitbridge homebridge[21011]: at emitOne (events.js:116:13) Jun 09 12:34:47 homekitbridge homebridge[21011]: at Request.emit (events.js:211:7) Jun 09 12:34:47 homekitbridge homebridge[21011]: at IncomingMessage. (/usr/lib/node_modules/homebridge-hydrawise/node_modules/request/request.js:1083:12) Jun 09 12:34:47 homekitbridge homebridge[21011]: at Object.onceWrapper (events.js:313:30) Jun 09 12:34:47 homekitbridge homebridge[21011]: at emitNone (events.js:111:20) Jun 09 12:34:47 homekitbridge homebridge[21011]: at IncomingMessage.emit (events.js:208:7) Jun 09 12:34:47 homekitbridge homebridge[21011]: at endReadableNT (_stream_readable.js:1064:12) Jun 09 12:34:47 homekitbridge homebridge[21011]: at _combinedTickCallback (internal/process/next_tick.js:139:11) Jun 09 12:34:47 homekitbridge homebridge[21011]: at process._tickCallback (internal/process/next_tick.js:181:9)

martijndierckx commented 5 years ago

Yes. I’ve seen the same error appear in the logs. But haven’t had time to investigate yet.

Thanks for the input.


Van: Joe Williams notifications@github.com Verzonden: Sunday, June 9, 2019 9:39:00 PM Aan: martijndierckx/homebridge-hydrawise CC: Subscribed Onderwerp: [martijndierckx/homebridge-hydrawise] Over-polling of the Hydrawise API (#6)

Hi all,

Seeing this error coming from the plugin when I was setting it up in Homebridge today. The 429 from Request appears that I was making too many polling requests to the API. Has anyone else seen this error?

I have moved the polling interval to 30 seconds (30000) and it looks like its cut down on the errors being thrown in node, so I think this might be a throttling issue (unless Hunter wants to charge for API use)

Cheers, -Joe

Unhandled rejection StatusCodeError: 429 - undefined Jun 09 12:34:47 homekitbridge homebridge[21011]: at new StatusCodeError (/usr/lib/node_modules/homebridge-hydrawise/node_modules/request-promise/lib/errors.js:32:15) Jun 09 12:34:47 homekitbridge homebridge[21011]: at Request.RP$callback [as _callback] (/usr/lib/node_modules/homebridge-hydrawise/node_modules/request-promise/lib/rp.js:77:29) Jun 09 12:34:47 homekitbridge homebridge[21011]: at Request.self.callback (/usr/lib/node_modules/homebridge-hydrawise/node_modules/request/request.js:185:22) Jun 09 12:34:47 homekitbridge homebridge[21011]: at emitTwo (events.js:126:13) Jun 09 12:34:47 homekitbridge homebridge[21011]: at Request.emit (events.js:214:7) Jun 09 12:34:47 homekitbridge homebridge[21011]: at Request. (/usr/lib/node_modules/homebridge-hydrawise/node_modules/request/request.js:1161:10) Jun 09 12:34:47 homekitbridge homebridge[21011]: at emitOne (events.js:116:13) Jun 09 12:34:47 homekitbridge homebridge[21011]: at Request.emit (events.js:211:7) Jun 09 12:34:47 homekitbridge homebridge[21011]: at IncomingMessage. (/usr/lib/node_modules/homebridge-hydrawise/node_modules/request/request.js:1083:12) Jun 09 12:34:47 homekitbridge homebridge[21011]: at Object.onceWrapper (events.js:313:30) Jun 09 12:34:47 homekitbridge homebridge[21011]: at emitNone (events.js:111:20) Jun 09 12:34:47 homekitbridge homebridge[21011]: at IncomingMessage.emit (events.js:208:7) Jun 09 12:34:47 homekitbridge homebridge[21011]: at endReadableNT (_stream_readable.js:1064:12) Jun 09 12:34:47 homekitbridge homebridge[21011]: at _combinedTickCallback (internal/process/next_tick.js:139:11) Jun 09 12:34:47 homekitbridge homebridge[21011]: at process._tickCallback (internal/process/next_tick.js:181:9)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/martijndierckx/homebridge-hydrawise/issues/6?email_source=notifications&email_token=AA6KD7TMAJ472W57UCDQX5DPZVL5JA5CNFSM4HWNJK32YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GYOODUQ, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AA6KD7XIZRBVNPDPD5D32QTPZVL5JANCNFSM4HWNJK3Q.

storkpkp commented 5 years ago

Any chance you have had time to look at this?

erpeters3 commented 5 years ago

Also seeing this error. Dropped my polling to 60000 and still getting errors.

oliverl commented 5 years ago

Same. Increasing the polling interval to a very high number doesn't seem to resolve anything. Perhaps there's a quick fix to handle just this error/StatusErrorCode so that it doesn't crash Homebridge? Anyone familiar enough with the code want to fork and make the tweak?

martijndierckx commented 5 years ago

Haven't had any chance to look into it. I do see the same error on my side.

I do want to know where it comes from. And worst case scenario, an error check needs to be built in as suggested above

beatit99 commented 5 years ago

Plugin works great thanks! Unfortunately I'm getting the error too. homebridge-0.4.50 homebridge-hydrawise 0.0.4 Pro HC 6 Station Controller 4.04

changed polling_interval to 10000, restarted homebridge and am getting less now.

camryan commented 5 years ago

Maximum API query rate is 30 requests in a 5 minute period. The default in your package should be changed to a minimum of 10000ms.

Note: also check that the API endpoint domain is set to app.hydrawise.com not hydrawise.com.

camryan commented 5 years ago

Also note that you must change to using app.hydrawise.com as your endpoint before 31st October 2019 to avoid service interruption.

beatit99 commented 5 years ago

Thanks @camryan, not seeing the errors now at 15000ms.

Also this module will need a patch for the endpoint. I have done locally, should just be this one: node_modules/hydrawise-api/index.js: this.url = 'https://hydrawise.com/api/v1/';

FlyingLemming commented 5 years ago

This is the e-mail I received from a Hydrawise product manager regarding this issue:

„Dear API User, We have noticed that you are using the Hydrawise Rest API. We have detected 2 issues with your usage of the Hydrawise API service:

  1. Your API application is using the wrong API endpoint. Our documentation (attached) states that it should be https://app.hydrawise.com/api/v1/ and you are using https://hydrawise.com/api/v1 (ie. you’re missing the “app” part of the domain name). Right now we are redirecting the wrong API endpoint to the correct address but this will be disabled in a few days and your API will cease to work if not corrected.
  2. Your application is also making excessive calls to the Hydrawise API service. Calls are rate limited to 30 API calls in a 5 minute period. Our logs show significantly higher request rate than this.

Can you please make these adjustments to the usage of our API service ASAP? We are currently redirecting your call but as of the 31st October we will no longer be supporting this.

Regards XXX“

However, I am using a polling interval of 60000 ms and it still seems to be too much... 🤔

oliverl commented 5 years ago

Received the same notification. I updated my local configuration to use the new URL (app.hydrawise.com...) and upped my polling interval to 100000 ms but the plugin is still crashing with that same '429 - undefined' error. I'll try to reach out to the hydrawise engineer to find out if we're all doing something wrong. would love to hear from @martijndierckx if he's found any time to look into this too...

beatit99 commented 5 years ago

I've tried 10000, 11000 & now 12000 and get occasional errors, maybe a couple a day. 15000 had none over a few days.

oliverl commented 5 years ago

perhaps it has to do with the number of zones? I have 10. what seems to crash it is when I open up the Home app and it starts "updating" my zones.

FlyingLemming commented 5 years ago

Five zones for me, polling interval 60,000 ms. Getting the errors when opening the Home app, just as oliverl observed.

BadgerBadgerAndFox commented 4 years ago

@martijndierckx Still an issue. I have corrected the API url and set my config as follows: "default_runtime": "600", "polling_interval": "15000" I've even tried reducing my zone count to 2 (disabled the other 2 zones)

The logs clearly indicate that this is a polling rate error, error statusCode 429 is followed by statusMessage 'Too Many Requests'

martijndierckx commented 4 years ago

Finally found the time to have a quick look. I changed the default polling interval to 10000 and changed the hydrawise-api dependancy to another fork, adapting to the new endpoint path.