homebridge-http-switch icon indicating copy to clipboard operation
homebridge-http-switch copied to clipboard

Homebridge 1.3.1 / The read handler for the characteristic 'On' was slow to respond!

Open NorbertM21 opened this issue 3 years ago • 9 comments

[homebridge-http-switch] This plugin slows down Homebridge. The read handler for the characteristic 'On' was slow to respond! See https://git.io/JtMGR for more info.

NorbertM21 avatar Feb 26 '21 18:02 NorbertM21

Hi - any chance of updating the plugin to resolve this problem? Much appreciated.

cjastennett avatar Mar 27 '21 19:03 cjastennett

This really depends on your setup. As the http-switch plugins queriers the http url you specify when it gets a request from HomeKit. Thus, when the warning appears that a request handled by this plugin took longer than 3s (or longer) it really means that your http service was slow to respond and took longer than e.g 3 seconds to respond.

I can mitigate the warning (e.g. return early with a cached result) and use the updated value for the next request coming. But I can't fix the problem, which is your http service being slow to respond.

To get a better understanding of the problem, it might help to get a log output to check how often this warning appears, or if it only appears within certain conditions (e.g. when multiple clients query at once). The plugin could indeed be advance such that multiple request coming (roughly at the same time) from different HomeKit clients result only in one http request to the http service.

Supereg avatar Mar 27 '21 19:03 Supereg

As recommended in my Link above, I solved it for me:

getStatus: function (callback) { const value = this.homebridgeService.getCharacteristic(Characteristic.On).value; callback(null, value); }

and than with a seperate

getStatusTT: function (callback) { ... http.httpRequest(this.status, (error, response, body) => { ... this.homebridgeService.getCharacteristic(Characteristic.On).updateValue(switchedOn); ... }

NorbertM21 avatar Mar 28 '21 12:03 NorbertM21

@NorbertM21

Thats exactly what I meant with:

I can mitigate the warning (e.g. return early with a cached result) and use the updated value for the next request coming. But I can't fix the problem, which is your http service being slow to respond.

This will e.g. not allow to immediately report errors back to HomeKit should e.g. the http request fail for some reason.

I'm not yet sure how to deal with that and if I really wan't to go the route you proposed.

Supereg avatar Mar 28 '21 12:03 Supereg

@Supereg this came up with Hombridge 1.3 (same problem with other plugins). Looks like they don't accept any delay to improve the system.

So I set pulltimer to a tempvalue of 100ms and get a quick response in HomeKit by getStatusTT - everything fine for me :-)

regards

NorbertM21 avatar Mar 28 '21 13:03 NorbertM21

this came up with Hombridge 1.3 (same problem with other plugins). Looks like they don't accept any delay to improve the system.

I know. I'm one of the guys who developed the warning system 🙃 Its about speeding about the general bridge, as the bridge is as slow to respond as the slowest plugin.

Its just, this requirements doesn't fit very fell for the use case of this plugin. Though, of course, the plugin will need to adapt in one or another way, I just need to check how I make this change without breaking anybody's setup.

Supereg avatar Mar 28 '21 13:03 Supereg

Hello,

Could you add the proposed workaround, this seems useful in any case :

I can mitigate the warning (e.g. return early with a cached result) and use the updated value for the next request coming. But I can't fix the problem, which is your http service being slow to respond.

matthieularge avatar May 31 '21 13:05 matthieularge

@matthieularge that's definitely the plan, though requires some minor architectural changes of the plugin. I currently can't make any promises in regards to timing, don't want it to be a rushed, half baked change.

There is functionally and in terms of behavior no difference to running this plugin with previous versions of homebridge. Its just that homebridge v1.3.x starts to print the warning now.

Supereg avatar May 31 '21 14:05 Supereg

strange, i have written the HTTP service i'm polling for the state on my own and it definetly doesn't take more than 3 seconds to respond, it's more like 50-100miliseconds for any request - but still i got these warnings printed after homebridge is running for like one two hours - for my taste, the states are pulled way too often as i see in the logs - sometimes two-three times in the same second...

rvetere avatar Dec 22 '23 07:12 rvetere