forty2 / hap-client

Control HomeKit-enabled devices with Node
MIT License
27 stars 13 forks source link

Pairing with Philips Hue bridge throws Bad status: 429 Too Many Requests #5

Open surferandi opened 6 years ago

surferandi commented 6 years ago

Hi,

I want to pair with the Philips Hue bridge (on port 8080) using the example code.

I always get an exception Bad status: 429 Too Many Requests as response to the pair-setup request:

Caught | 2018-01-06 16:48:15.676 | error | by controller[18]: at TCP.onread (net.js:547:20)
-- | -- | -- | --
Caught | 2018-01-06 16:48:15.675 | error | by controller[18]: at Socket.Readable.push (_stream_readable.js:134:10)
Caught | 2018-01-06 16:48:15.675 | error | by controller[18]: at readableAddChunk (_stream_readable.js:187:13)
Caught | 2018-01-06 16:48:15.675 | error | by controller[18]: at emitReadable (_stream_readable.js:426:7)
Caught | 2018-01-06 16:48:15.674 | error | by controller[18]: at emitReadable_ (_stream_readable.js:432:10)
Caught | 2018-01-06 16:48:15.674 | error | by controller[18]: at Socket.emit (events.js:185:7)
Caught | 2018-01-06 16:48:15.674 | error | by controller[18]: at emitNone (events.js:86:13)
Caught | 2018-01-06 16:48:15.674 | error | by controller[18]: at Socket.socket.on (/opt/iobroker/node_modules/iobroker.javascript/node_modules/message-socket/dist/index.js:168:22)
Caught | 2018-01-06 16:48:15.674 | error | by controller[18]: at Array.forEach (native)
Caught | 2018-01-06 16:48:15.673 | error | by controller[18]: at messages.forEach.msg (/opt/iobroker/node_modules/iobroker.javascript/node_modules/message-socket/dist/index.js:175:40)
Caught | 2018-01-06 16:48:15.673 | error | by controller[18]: at Subject.next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/message-socket/dist/index.js:60:25)
Caught | 2018-01-06 16:48:15.673 | error | by controller[18]: at Array.forEach (native)
Caught | 2018-01-06 16:48:15.673 | error | by controller[18]: at _observers.forEach (/opt/iobroker/node_modules/iobroker.javascript/node_modules/message-socket/dist/index.js:63:19)
Caught | 2018-01-06 16:48:15.672 | error | by controller[18]: at TakeUntilSubscriber.Subscriber.next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/Subscriber.js:90:18)
Caught | 2018-01-06 16:48:15.672 | error | by controller[18]: at TakeUntilSubscriber.Subscriber._next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/Subscriber.js:126:26)
Caught | 2018-01-06 16:48:15.672 | error | by controller[18]: at FilterSubscriber.Subscriber.next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/Subscriber.js:90:18)
Caught | 2018-01-06 16:48:15.672 | error | by controller[18]: at FilterSubscriber._next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/operators/filter.js:89:30)
Caught | 2018-01-06 16:48:15.672 | error | by controller[18]: at TakeSubscriber.Subscriber.next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/Subscriber.js:90:18)
Caught | 2018-01-06 16:48:15.670 | error | by controller[18]: at TakeSubscriber._next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/operators/take.js:82:30)
Caught | 2018-01-06 16:48:15.670 | error | by controller[18]: at InnerSubscriber.Subscriber.next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/Subscriber.js:90:18)
Caught | 2018-01-06 16:48:15.670 | error | by controller[18]: at InnerSubscriber._next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/InnerSubscriber.js:23:21)
Caught | 2018-01-06 16:48:15.670 | error | by controller[18]: at DeferSubscriber.OuterSubscriber.notifyNext (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/OuterSubscriber.js:19:26)
Caught | 2018-01-06 16:48:15.670 | error | by controller[18]: at ExpandSubscriber.Subscriber.next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/Subscriber.js:90:18)
Caught | 2018-01-06 16:48:15.669 | error | by controller[18]: at ExpandSubscriber._next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/operators/expand.js:108:59)
Caught | 2018-01-06 16:48:15.669 | error | by controller[18]: at tryCatcher (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/util/tryCatch.js:6:31)
Caught | 2018-01-06 16:48:15.669 | error | by controller[18]: at /opt/iobroker/node_modules/iobroker.javascript/node_modules/hap-client/dist/HapClient.js:117:47
Caught | 2018-01-06 16:48:15.669 | error | by controller[18]: Error: Bad status: 429 Too Many Requests
Caught | 2018-01-06 16:48:15.669 | error | by controller[17]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:http returning from 99 to 99
Caught | 2018-01-06 16:48:15.668 | error | by controller[16]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:http parsing body
Caught | 2018-01-06 16:48:15.668 | error | by controller[15]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:http finished reading
Caught | 2018-01-06 16:48:15.668 | error | by controller[14]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:http There are 6 bytes left in the buffer
Caught | 2018-01-06 16:48:15.668 | error | by controller[13]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:http Reading 6 bytes for body...
Caught | 2018-01-06 16:48:15.667 | error | by controller[12]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:http status: HTTP, 1.1, 429, Too Many Requests
Caught | 2018-01-06 16:48:15.667 | error | by controller[11]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:http Request sent
Caught | 2018-01-06 16:48:15.667 | error | by controller[10]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:http raw request (post middleware): 504f5354202f706169722d736574757020485454502f312e310d0a486f73743a203139322e3136382e312e3133363a383038300
Caught | 2018-01-06 16:48:15.666 | error | by controller[9]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:http raw request: 504f5354202f706169722d736574757020485454502f312e310d0a486f73743a203139322e3136382e312e3133363a383038300d0a436f6e74656e742d
Caught | 2018-01-06 16:48:15.665 | error | by controller[8]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:http requesting: POST /pair-setup
Caught | 2018-01-06 16:48:15.665 | error | by controller[7]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:http POSTing to /pair-setup:
Caught | 2018-01-06 16:48:15.665 | error | by controller[6]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:hap encoded request:
Caught | 2018-01-06 16:48:15.665 | error | by controller[5]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:tlv adding 1 bytes of type 6 to the buffer starting at 0
Caught | 2018-01-06 16:48:15.664 | error | by controller[4]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:tlv turning 1 into buffer
Caught | 2018-01-06 16:48:15.664 | error | by controller[3]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:tlv adding 1 bytes of type 0 to the buffer starting at 0
Caught | 2018-01-06 16:48:15.664 | error | by controller[2]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:tlv turning 0 into buffer
Caught | 2018-01-06 16:48:15.664 | error | by controller[1]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:hap Reusing long-term keys
Caught | 2018-01-06 16:48:15.662 | error | by controller[0]: Sat, 06 Jan 2018 15:48:15 GMT hap-client:hap Generating long-term keys
javascript.1 | 2018-01-06 16:48:15.629 | error | at TCP.onread (net.js:547:20)
javascript.1 | 2018-01-06 16:48:15.629 | error | at Socket.Readable.push (_stream_readable.js:134:10)
javascript.1 | 2018-01-06 16:48:15.629 | error | at readableAddChunk (_stream_readable.js:187:13)
javascript.1 | 2018-01-06 16:48:15.629 | error | at emitReadable (_stream_readable.js:426:7)
javascript.1 | 2018-01-06 16:48:15.629 | error | at emitReadable_ (_stream_readable.js:432:10)
javascript.1 | 2018-01-06 16:48:15.629 | error | at Socket.emit (events.js:185:7)
javascript.1 | 2018-01-06 16:48:15.629 | error | at emitNone (events.js:86:13)
javascript.1 | 2018-01-06 16:48:15.629 | error | at Socket.socket.on (/opt/iobroker/node_modules/iobroker.javascript/node_modules/message-socket/dist/index.js:168:22)
javascript.1 | 2018-01-06 16:48:15.629 | error | at Array.forEach (native)
javascript.1 | 2018-01-06 16:48:15.629 | error | at messages.forEach.msg (/opt/iobroker/node_modules/iobroker.javascript/node_modules/message-socket/dist/index.js:175:40)
javascript.1 | 2018-01-06 16:48:15.629 | error | at Subject.next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/message-socket/dist/index.js:60:25)
javascript.1 | 2018-01-06 16:48:15.629 | error | at Array.forEach (native)
javascript.1 | 2018-01-06 16:48:15.629 | error | at _observers.forEach (/opt/iobroker/node_modules/iobroker.javascript/node_modules/message-socket/dist/index.js:63:19)
javascript.1 | 2018-01-06 16:48:15.629 | error | at TakeUntilSubscriber.Subscriber.next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/Subscriber.js:90:18)
javascript.1 | 2018-01-06 16:48:15.629 | error | at TakeUntilSubscriber.Subscriber._next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/Subscriber.js:126:26)
javascript.1 | 2018-01-06 16:48:15.629 | error | at FilterSubscriber.Subscriber.next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/Subscriber.js:90:18)
javascript.1 | 2018-01-06 16:48:15.629 | error | at FilterSubscriber._next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/operators/filter.js:89:30)
javascript.1 | 2018-01-06 16:48:15.629 | error | at TakeSubscriber.Subscriber.next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/Subscriber.js:90:18)
javascript.1 | 2018-01-06 16:48:15.629 | error | at TakeSubscriber._next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/operators/take.js:82:30)
javascript.1 | 2018-01-06 16:48:15.629 | error | at InnerSubscriber.Subscriber.next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/Subscriber.js:90:18)
javascript.1 | 2018-01-06 16:48:15.629 | error | at InnerSubscriber._next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/InnerSubscriber.js:23:21)
javascript.1 | 2018-01-06 16:48:15.629 | error | at DeferSubscriber.OuterSubscriber.notifyNext (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/OuterSubscriber.js:19:26)
javascript.1 | 2018-01-06 16:48:15.629 | error | at ExpandSubscriber.Subscriber.next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/Subscriber.js:90:18)
javascript.1 | 2018-01-06 16:48:15.629 | error | at ExpandSubscriber._next (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/operators/expand.js:108:59)
javascript.1 | 2018-01-06 16:48:15.629 | error | at tryCatcher (/opt/iobroker/node_modules/iobroker.javascript/node_modules/rxjs/util/tryCatch.js:6:31)
javascript.1 | 2018-01-06 16:48:15.629 | error | at /opt/iobroker/node_modules/iobroker.javascript/node_modules/hap-client/dist/HapClient.js:117:47
javascript.1 | 2018-01-06 16:48:15.629 | error | Error: Bad status: 429 Too Many Requests
javascript.1 | 2018-01-06 16:48:15.628 | error | uncaught exception: Bad status: 429 Too Many Requests

I tried restarting the hub and ensuring that no other requests are sent but I still get this error.

The environment is Node v6.12.2 on a Raspberry Pi Stretch (headless setup) within the javascript adapter of iobroker.

I already had a hard time to get the dependency to sodium working. For the keytar dependency I get a runtime error when connecting to the dbus so until I get this working I replaced Keytar with a dummy implementation which stores the secrets in memory.

Any help is appreciated as I would really like to get this running to get async notifications not available by the Hue REST api.

Thanks.

sgarciahelguera commented 6 years ago

I had the same issue and it was an already paired apple controller. From Hue app you can reset Homekit pairings from settings. I am still trying to figure out what is failing now but no longer get a 429.