lynxcs / homebridge-ct200

Homebridge plugin for Bosch Easycontrol CT200
MIT License
21 stars 2 forks source link

Unhandled rejection Error: HTTP_TOO_MANY_REQUESTS #21

Closed fate8383 closed 2 years ago

fate8383 commented 2 years ago

Unhandled rejection Error: HTTP_TOO_MANY_REQUESTS at /usr/lib/node_modules/homebridge-ct200/node_modules/bosch-xmpp/lib/base-client.js:213:25 at tryCatcher (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (node:internal/timers:464:21) Unhandled rejection Error: HTTP_TOO_MANY_REQUESTS at /usr/lib/node_modules/homebridge-ct200/node_modules/bosch-xmpp/lib/base-client.js:213:25 at tryCatcher (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (node:internal/timers:464:21) Unhandled rejection Error: HTTP_TOO_MANY_REQUESTS at /usr/lib/node_modules/homebridge-ct200/node_modules/bosch-xmpp/lib/base-client.js:213:25 at tryCatcher (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (node:internal/timers:464:21) Unhandled rejection Error: HTTP_TOO_MANY_REQUESTS at /usr/lib/node_modules/homebridge-ct200/node_modules/bosch-xmpp/lib/base-client.js:213:25 at tryCatcher (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (node:internal/timers:464:21) Unhandled rejection Error: HTTP_TOO_MANY_REQUESTS at /usr/lib/node_modules/homebridge-ct200/node_modules/bosch-xmpp/lib/base-client.js:213:25 at tryCatcher (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (node:internal/timers:464:21) Unhandled rejection Error: HTTP_TOO_MANY_REQUESTS at /usr/lib/node_modules/homebridge-ct200/node_modules/bosch-xmpp/lib/base-client.js:213:25 at tryCatcher (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (node:internal/timers:464:21) Unhandled rejection Error: HTTP_TOO_MANY_REQUESTS at /usr/lib/node_modules/homebridge-ct200/node_modules/bosch-xmpp/lib/base-client.js:213:25 at tryCatcher (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (node:internal/timers:464:21) Unhandled rejection Error: HTTP_TOO_MANY_REQUESTS at /usr/lib/node_modules/homebridge-ct200/node_modules/bosch-xmpp/lib/base-client.js:213:25 at tryCatcher (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (node:internal/timers:464:21)

As suggested opening new issue for this. I am on the latest version and i am getting these like 2-3 times a day. It was not like this before. I have scheduled heating, it is not happening exactly at scheduled heating start time or end time but ballpark it is happening around that time frame. For example daily 8-12noon i have it on, then off and then start again in 2:30pm until 8pm. So these errors are happening around 7am ish and 3pm ish and sometimes 8:30pm ish, may not be related at all but i am not doing anything else to get these errors. Normal working sync process should not generate these errors i believe. Any suggestions? I can send more debug logs if you can instruct me.

Thanks a lot, still an awesome plugin regardless :)

lynxcs commented 2 years ago

Might have a theory for why this is happening. Previously getTargetTemperature was sending invalid request, which was fixed in v2.1.5. If I had to guess, invalid requests wouldn't count against the API rate limit, and so this error didn't appear, but now that the function works correctly, the amount of requests is too large and this error is shown.

It would be nice to know, how many zones you have, so I can have a better idea of what the API limit could be. As well, you could run homebridge in debug mode, it should show what requests are being made (and their responses), from that we could see what the most common request is (I suspect it will be something to do with target temperature).

As for possible fixes, at the moment I have no idea. One solution could be getting the target temperature from a single zone, but that is less than ideal, as it will only show correct results if all the zones have the same target temperature.

EDIT: I also believe the errors are not time-related, and correspond with how often homekit updates the thermostat target temperature (so, for example, opening the Home app will send a request to all the zones for their target temperatures (and other properties as well))

fate8383 commented 2 years ago

I have 10 zones (1 + 9 TRV)

cjaca commented 2 years ago

Hi @lynxcs, I can report same rejection Error: HTTP_TOO_MANY_REQUESTS for 6 zones

📜 Log Unhandled rejection Error: HTTP_TOO_MANY_REQUESTS at /usr/lib/node_modules/homebridge-ct200/node_modules/bosch-xmpp/lib/base-client.js:213:25 at tryCatcher (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (internal/timers.js:464:21) Unhandled rejection Error: HTTP_TOO_MANY_REQUESTS at /usr/lib/node_modules/homebridge-ct200/node_modules/bosch-xmpp/lib/base-client.js:213:25 at tryCatcher (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (internal/timers.js:464:21) Unhandled rejection Error: HTTP_TOO_MANY_REQUESTS at /usr/lib/node_modules/homebridge-ct200/node_modules/bosch-xmpp/lib/base-client.js:213:25 at tryCatcher (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (internal/timers.js:464:21) Unhandled rejection Error: HTTP_TOO_MANY_REQUESTS at /usr/lib/node_modules/homebridge-ct200/node_modules/bosch-xmpp/lib/base-client.js:213:25 at tryCatcher (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/homebridge-ct200/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (internal/timers.js:464:21)
fate8383 commented 2 years ago

Well debuging it for a day and it is not even once did this error, I am toggling Bosch app and home kit right and left to reach this limit to see the error but no luck. I think you are right it is asking for target temperature nothing else, like usual zone values. Maybe it was really caused by Bosch server response which I have no way of knowing but it seems like working just fine now. Maybe others can share debug logs.

lynxcs commented 2 years ago

I have been trying to recreate this issue, but haven't been able to, sent probably over >1000 requests simultaneously. After more testing I'm pretty sure that this error appears not because there is an actual API limit, but because of library that bosch-xmpp uses to send requests (bluebird). I've updated the code to show a nicer warning instead of the unhandled rejection. As for how to avoid this error - I'm not sure.

A possible reason for this error is that you're using a low-powered device (such as an raspberry pi). But I can't test this theory, since I don't have one myself and use a powerful server for homebridge.

cjaca commented 2 years ago

My homebridge instance is set up on a dedicated Ubuntu machine under VMware host, so we can totally ignore case :)

fate8383 commented 2 years ago

Updated to new version, will let you know

lynxcs commented 2 years ago

My homebridge instance is set up on a dedicated Ubuntu machine under VMware host, so we can totally ignore case :)

Good to know it's not because of device performance, another reason could be internet / connection to Bosch servers, but because you are using dedicated machine I think it's unlikely that you have unstable connection, so that is another thing we can ignore.

fate8383 commented 2 years ago

Just wanted to let you know, not even once I got this error in 4 days. I think you perfected it :) once again awesome plugin! Thanks a lot.

lynxcs commented 2 years ago

Glad to hear that it is working well! I will close this issue currently, since you're having no issues and I can't reproduce it. If the issue re-appears, comment again and re-open. (And if this issue re-appears for everyone at a similar time, that might be an indication that this isn't an issue with the plugin, but with the Bosch servers)