sibartlett / homebridge-wink3

Homebridge plugin for wink.com
https://sibartlett.github.io/homebridge-wink3
ISC License
54 stars 20 forks source link

StatusCodeError: 429 "You have been throttled. Please try again later" #46

Open bernesto opened 7 years ago

bernesto commented 7 years ago

When launching Homebridge with Wink 3 I get a throttling error after checking if a hub is reachable locally. It seems to eventually work fine with HomeKit.

[9/24/2017, 12:17:27 PM] [Wink] Could not authenticate with local hub (Bedroom Hub, 192.168.1.240) { StatusCodeError: 429 - {"data":null,"errors":["You have been throttled. Please try again later."],"pagination":{}} at new StatusCodeError (/usr/local/lib/node_modules/homebridge-wink3/node_modules/request-promise-core/lib/errors.js:32:15) at Request.plumbing.callback (/usr/local/lib/node_modules/homebridge-wink3/node_modules/request-promise-core/lib/plumbing.js:104:33) at Request.RP$callback [as _callback] (/usr/local/lib/node_modules/homebridge-wink3/node_modules/request-promise-core/lib/plumbing.js:46:31) at Request.self.callback (/usr/local/lib/node_modules/homebridge-wink3/node_modules/request/request.js:186:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request. (/usr/local/lib/node_modules/homebridge-wink3/node_modules/request/request.js:1163:10) at emitOne (events.js:96:13) at Request.emit (events.js:188:7) at IncomingMessage. (/usr/local/lib/node_modules/homebridge-wink3/node_modules/request/request.js:1085:12) at IncomingMessage.g (events.js:292:16) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9) name: 'StatusCodeError', statusCode: 429, message: '429 - {"data":null,"errors":["You have been throttled. Please try again later."],"pagination":{}}', error: { data: null, errors: [ 'You have been throttled. Please try again later.' ], pagination: {} }, options: { baseUrl: 'https://api.wink.com', strictSSL: true, json: true, method: 'POST', uri: '/oauth2/token', body: { local_control_id: 'XXXX', scope: 'local_control', grant_type: 'refresh_token', refresh_token: 'XXXX', client_id: 'XXXX', client_secret: 'XXXX' }, headers: { 'User-Agent': 'Manufacturer/Apple-iPhone8_1 iOS/10.3.1 WinkiOS/5.8.0.27-production-release (Scale/2.00)' }, callback: [Function: RP$callback], transform: undefined, simple: true, resolveWithFullResponse: false, transform2xxOnly: false }, response: IncomingMessage { _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: [Object], length: 0, pipes: null, pipesCount: 0, flowing: true, ended: true, endEmitted: true, reading: false, sync: true, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, defaultEncoding: 'utf8', ranOut: false, awaitDrain: 0, readingMore: false, decoder: null, encoding: null }, readable: false, domain: null, _events: { end: [Object], close: [Object], data: [Function], error: [Function] }, _eventsCount: 4, _maxListeners: undefined, socket: TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: null, npnProtocol: false, alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: [Object], _eventsCount: 9, connecting: false, _hadError: false, _handle: null, _parent: null, _host: 'api.wink.com', _readableState: [Object], readable: false, domain: null, _maxListeners: undefined, _writableState: [Object], writable: false, allowHalfOpen: false, destroyed: true, _bytesDispatched: 512, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: null, _requestCert: true, _rejectUnauthorized: true, parser: null, _httpMessage: [Object], read: [Function], _consuming: true, _idleNext: null, _idlePrev: null, _idleTimeout: -1 }, connection: TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: null, npnProtocol: false, alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: [Object], _eventsCount: 9, connecting: false, _hadError: false, _handle: null, _parent: null, _host: 'api.wink.com', _readableState: [Object], readable: false, domain: null, _maxListeners: undefined, _writableState: [Object], writable: false, allowHalfOpen: false, destroyed: true, _bytesDispatched: 512, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: null, _requestCert: true, _rejectUnauthorized: true, parser: null, _httpMessage: [Object], read: [Function], _consuming: true, _idleNext: null, _idlePrev: null, _idleTimeout: -1 }, httpVersionMajor: 1, httpVersionMinor: 1, httpVersion: '1.1', complete: true, headers: { 'cache-control': 'no-cache', 'content-type': 'application/json', 'retry-after': '13', 'strict-transport-security': 'max-age=31536000', via: '1.1 spaces-router (3979283aa3db)', 'x-ratelimit-limit': '5', 'x-ratelimit-remaining': '0', 'x-ratelimit-reset': '2017-09-24T18:17:40Z', 'x-request-id': 'XXXX', 'x-runtime': '0.040081', date: 'Sun, 24 Sep 2017 18:17:27 GMT', 'content-length': '91', connection: 'close' }, rawHeaders: [ 'Cache-Control', 'no-cache', 'Content-Type', 'application/json', 'Retry-After', '13', 'Strict-Transport-Security', 'max-age=31536000', 'Via', '1.1 spaces-router (3979283aa3db)', 'X-Ratelimit-Limit', '5', 'X-Ratelimit-Remaining', '0', 'X-Ratelimit-Reset', '2017-09-24T18:17:40Z', 'X-Request-Id', 'XXXX', 'X-Runtime', '0.040081', 'Date', 'Sun, 24 Sep 2017 18:17:27 GMT', 'Content-Length', '91', 'Connection', 'close' ], trailers: {}, rawTrailers: [], upgrade: false, url: '', method: null, statusCode: 429, statusMessage: 'Too Many Requests', client: TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: null, npnProtocol: false, alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: [Object], _eventsCount: 9, connecting: false, _hadError: false, _handle: null, _parent: null, _host: 'api.wink.com', _readableState: [Object], readable: false, domain: null, _maxListeners: undefined, _writableState: [Object], writable: false, allowHalfOpen: false, destroyed: true, _bytesDispatched: 512, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: null, _requestCert: true, _rejectUnauthorized: true, parser: null, _httpMessage: [Object], read: [Function], _consuming: true, _idleNext: null, _idlePrev: null, _idleTimeout: -1 }, _consuming: true, _dumped: false, req: ClientRequest { domain: null, _events: [Object], _eventsCount: 5, _maxListeners: undefined, output: [], outputEncodings: [], outputCallbacks: [], outputSize: 0, writable: true, _last: true, upgrading: false, chunkedEncoding: false, shouldKeepAlive: false, useChunkedEncodingByDefault: true, sendDate: false, _removedHeader: [Object], _contentLength: null, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: [Object], connection: [Object], _header: 'POST /oauth2/token HTTP/1.1\r\nUser-Agent: Manufacturer/Apple-iPhone8_1 iOS/10.3.1 WinkiOS/5.8.0.27-production-release (Scale/2.00)\r\nhost: api.wink.com\r\naccept: application/json\r\ncontent-type: application/json\r\ncontent-length: 261\r\nConnection: close\r\n\r\n', _headers: [Object], _headerNames: [Object], _onPendingData: null, agent: [Object], socketPath: undefined, timeout: undefined, method: 'POST', path: '/oauth2/token', _ended: true, parser: null, res: [Circular] }, request: Request { domain: null, _events: [Object], _eventsCount: 5, _maxListeners: undefined, strictSSL: true, method: 'POST', uri: [Object], body: '{"local_control_id":"XXXX","scope":"local_control","grant_type":"refresh_token","refresh_token":"XXXX","client_id":"XXXX","client_secret":"XXXX"}', headers: [Object], readable: true, writable: true, explicitMethod: true, _qs: [Object], _auth: [Object], _oauth: [Object], _multipart: [Object], _redirect: [Object], _tunnel: [Object], _rp_resolve: [Function: s], _rp_reject: [Function: t], _rp_promise: [Object], _rp_callbackOrig: undefined, callback: [Function], _rp_options: [Object], setHeader: [Function], hasHeader: [Function], getHeader: [Function], removeHeader: [Function], localAddress: undefined, pool: [Object], dests: [], __isRequestRequest: true, _callback: [Function: RP$callback], proxy: null, tunnel: true, setHost: true, originalCookieHeader: undefined, _disableCookies: true, _jar: undefined, port: 443, host: 'api.wink.com', path: '/oauth2/token', _json: true, httpModule: [Object], agentClass: [Object], agent: [Object], _started: true, href: 'https://api.wink.com/oauth2/token', req: [Object], ntick: true, response: [Circular], originalHost: 'api.wink.com', originalHostHeaderName: 'host', responseContent: [Circular], _destdata: true, _ended: true, _callbackCalled: true }, toJSON: [Function: responseToJSON], caseless: Caseless { dict: [Object] }, read: [Function], body: { data: null, errors: [Object], pagination: {} } } }

sibartlett commented 7 years ago

Have you got the latest version of homebridge-wink3 installed?

bernesto commented 7 years ago

I think so. Just installed this week.

sibartlett commented 7 years ago

Ok, I just looked at the error you posted again - and I think I have enough information there. Probably won’t have a fix for at least a week, as I’m traveling.

bernesto commented 7 years ago

Okay, no problem. I'll post any other issues I see.

djmcp commented 6 years ago

I just noticed that I started receiving this exact same error - throttling because of too many requests. Was anything corrected or a workaround provided? Thanks.

rshim630 commented 6 years ago

Same problem.

rshim630 commented 6 years ago

[7/12/2018, 11:18:16 PM] [Wink] Could not authenticate with local hub (Hub, 192.168.0.6) { StatusCodeError: 429 - {"data":null,"errors":["You have been throttled. Please try again later."],"pagination":{}} at new StatusCodeError (/usr/local/lib/node_modules/homebridge-wink3/node_modules/request-promise-core/lib/errors.js:32:15) at Request.plumbing.callback (/usr/local/lib/node_modules/homebridge-wink3/node_modules/request-promise-core/lib/plumbing.js:104:33) at Request.RP$callback [as _callback] (/usr/local/lib/node_modules/homebridge-wink3/node_modules/request-promise-core/lib/plumbing.js:46:31) at Request.self.callback (/usr/local/lib/node_modules/homebridge-wink3/node_modules/request/request.js:185:22) at Request.emit (events.js:182:13) at Request. (/usr/local/lib/node_modules/homebridge-wink3/node_modules/request/request.js:1157:10) at Request.emit (events.js:182:13) at IncomingMessage. (/usr/local/lib/node_modules/homebridge-wink3/node_modules/request/request.js:1079:12) at Object.onceWrapper (events.js:273:13) at IncomingMessage.emit (events.js:187:15) name: 'StatusCodeError', statusCode: 429, message: '429 - {"data":null,"errors":["You have been throttled. Please try again later."],"pagination":{}}', error: { data: null, errors: [ 'You have been throttled. Please try again later.' ], pagination: {} }, options: { baseUrl: 'https://api.wink.com', strictSSL: true, json: true, method: 'POST', uri: '/oauth2/token', body: { local_control_id: 'xxxxxxxxxxxxxxxxxxxxxxxx', scope: 'local_control', grant_type: 'refresh_token', refresh_token: 'xxxxxxxxxxxxxxxxxxxxxxxx', client_id: 'xxxxxxxxxxxxxxxxxxxxxxxx', client_secret: 'xxxxxxxxxxxxxxxxxxxxxxxx' }, headers: { 'User-Agent': 'Manufacturer/Apple-iPhone10_1 iOS/11.2.6 WinkiOS/6.7.0.19-production-release (Scale/2.00)' }, callback: [Function: RP$callback], transform: undefined, simple: true, resolveWithFullResponse: false, transform2xxOnly: false }, response: IncomingMessage { _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { length: 0 }, length: 0, pipes: null, pipesCount: 0, flowing: true, ended: true, endEmitted: true, reading: false, sync: true, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, emitClose: true, destroyed: false, defaultEncoding: 'utf8', awaitDrain: 0, readingMore: true, decoder: null, encoding: null }, readable: false, _events: { end: [Array], close: [Array], data: [Function], error: [Function] }, _eventsCount: 4, _maxListeners: undefined, socket: TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: 'api.wink.com', alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: [Object], _eventsCount: 8, connecting: false, _hadError: false, _handle: [TLSWrap], _parent: null, _host: 'api.wink.com', _readableState: [ReadableState], readable: true, _maxListeners: undefined, _writableState: [WritableState], writable: false, allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: [TLSWrap], _requestCert: true, _rejectUnauthorized: true, parser: null, _httpMessage: [ClientRequest],

    [Symbol(asyncId)]: 856,
    [Symbol(lastWriteQueueSize)]: 0,
    [Symbol(timeout)]: null,
    [Symbol(kBytesRead)]: 0,
    [Symbol(kBytesWritten)]: 0,
    [Symbol(connect-options)]: [Object] },
 connection:
  TLSSocket {
    _tlsOptions: [Object],
    _secureEstablished: true,
    _securePending: false,
    _newSessionPending: false,
    _controlReleased: true,
    _SNICallback: null,
    servername: 'api.wink.com',
    alpnProtocol: false,
    authorized: true,
    authorizationError: null,
    encrypted: true,
    _events: [Object],
    _eventsCount: 8,
    connecting: false,
    _hadError: false,
    _handle: [TLSWrap],
    _parent: null,
    _host: 'api.wink.com',
    _readableState: [ReadableState],
    readable: true,
    _maxListeners: undefined,
    _writableState: [WritableState],
    writable: false,
    allowHalfOpen: false,
    _sockname: null,
    _pendingData: null,
    _pendingEncoding: '',
    server: undefined,
    _server: null,
    ssl: [TLSWrap],
    _requestCert: true,
    _rejectUnauthorized: true,
    parser: null,
    _httpMessage: [ClientRequest],
    [Symbol(res)]: [TLSWrap],
    [Symbol(asyncId)]: 856,
    [Symbol(lastWriteQueueSize)]: 0,
    [Symbol(timeout)]: null,
    [Symbol(kBytesRead)]: 0,
    [Symbol(kBytesWritten)]: 0,
    [Symbol(connect-options)]: [Object] },
 httpVersionMajor: 1,
 httpVersionMinor: 1,
 httpVersion: '1.1',
 complete: true,
 headers:
  { 'cache-control': 'no-cache',
    'content-type': 'application/json',
    'retry-after': '104',
    'strict-transport-security': 'max-age=31536000',
    vary: 'Accept-Encoding',
    **'x-ratelimit-limit': '50',
    'x-ratelimit-remaining': '0',
    'x-ratelimit-reset': '2018-07-13T03:20:00Z',**
    'x-request-id': 'd6e8343d-5b3d-41e0-265c-9377bf671326',
    'x-runtime': '0.013486',
    'content-length': '91',
    connection: 'Close' },
 rawHeaders:
  [ 'Cache-Control',
    'no-cache',
    'Content-Type',
    'application/json',
    'Retry-after',
    '104',
    'Strict-Transport-Security',
    'max-age=31536000',
    'Vary',
    'Accept-Encoding',
    **'X-RateLimit-Limit',
    '50',
    'X-RateLimit-Remaining',
    '0',
    'X-RateLimit-Reset',
    '2018-07-13T03:20:00Z',**
    'X-Request-Id',
    'd6e8343d-5b3d-41e0-265c-9377bf671326',
    'X-Runtime',
    '0.013486',
    'Content-Length',
    '91',
    'Connection',
    'Close' ],
 trailers: {},
 rawTrailers: [],
 aborted: false,
 upgrade: false,
 url: '',
 method: null,
 statusCode: 429,
 statusMessage: '**Too Many Requests'**,
 client:
  TLSSocket {
    _tlsOptions: [Object],
    _secureEstablished: true,
    _securePending: false,
    _newSessionPending: false,
    _controlReleased: true,
    _SNICallback: null,
    servername: 'api.wink.com',
    alpnProtocol: false,
    authorized: true,
    authorizationError: null,
    encrypted: true,
    _events: [Object],
    _eventsCount: 8,
    connecting: false,
    _hadError: false,
    _handle: [TLSWrap],
    _parent: null,
    _host: 'api.wink.com',
    _readableState: [ReadableState],
    readable: true,
    _maxListeners: undefined,
    _writableState: [WritableState],
    writable: false,
    allowHalfOpen: false,
    _sockname: null,
    _pendingData: null,
    _pendingEncoding: '',
    server: undefined,
    _server: null,
    ssl: [TLSWrap],
    _requestCert: true,
    _rejectUnauthorized: true,
    parser: null,
    _httpMessage: [ClientRequest],
    [Symbol(res)]: [TLSWrap],
    [Symbol(asyncId)]: 856,
    [Symbol(lastWriteQueueSize)]: 0,
    [Symbol(timeout)]: null,
    [Symbol(kBytesRead)]: 0,
    [Symbol(kBytesWritten)]: 0,
    [Symbol(connect-options)]: [Object] },
 _consuming: false,
 _dumped: false,
 req:
  ClientRequest {
    _events: [Object],
    _eventsCount: 5,
    _maxListeners: undefined,
    output: [],
    outputEncodings: [],
    outputCallbacks: [],
    outputSize: 0,
    writable: true,
    _last: true,
    chunkedEncoding: false,
    shouldKeepAlive: false,
    useChunkedEncodingByDefault: true,
    sendDate: false,
    _removedConnection: false,
    _removedContLen: false,
    _removedTE: false,
    _contentLength: null,
    _hasBody: true,
    _trailer: '',
    finished: true,
    _headerSent: true,
    socket: [TLSSocket],
    connection: [TLSSocket],
    _header:
     'POST /oauth2/token HTTP/1.1\r\nUser-Agent: Manufacturer/Apple-iPhone10_1 iOS/11.2.6 WinkiOS/6.7.0.19-production-release (Scale/2.00)\r\nhost: api.wink.com\r\naccept: application/json\r\ncontent-type: application/json\r\ncontent-length: 261\r\nConnection: close\r\n\r\n',
    _onPendingData: [Function: noopPendingOutput],
    agent: [Agent],
    socketPath: undefined,
    timeout: undefined,
    method: 'POST',
    path: '/oauth2/token',
    _ended: true,
    res: [Circular],
    aborted: undefined,
    timeoutCb: null,
    upgradeOrConnect: false,
    parser: null,
    maxHeadersCount: null,
    [Symbol(isCorked)]: false,
    [Symbol(outHeadersKey)]: [Object] },
 request:
  Request {
    _events: [Object],
    _eventsCount: 5,
    _maxListeners: undefined,
    strictSSL: true,
    method: 'POST',
    uri: [Url],
    body:
     '{"local_control_id":"xxxxxxxxxxxxxxxxxxxxxxxx","scope":"local_control","grant_type":"refresh_token","refresh_token":"xxxxxxxxxxxxxxxxxxxxxxxx","client_id":"xxxxxxxxxxxxxxxxxxxxxxxx","client_secret":"xxxxxxxxxxxxxxxxxxxxxxxx"}',
    headers: [Object],
    readable: true,
    writable: true,
    explicitMethod: true,
    _qs: [Querystring],
    _auth: [Auth],
    _oauth: [OAuth],
    _multipart: [Multipart],
    _redirect: [Redirect],
    _tunnel: [Tunnel],
    _rp_resolve: [Function],
    _rp_reject: [Function],
    _rp_promise: [Promise],
    _rp_callbackOrig: undefined,
    callback: [Function],
    _rp_options: [Object],
    setHeader: [Function],
    hasHeader: [Function],
    getHeader: [Function],
    removeHeader: [Function],
    localAddress: undefined,
    pool: [Object],
    dests: [],
    __isRequestRequest: true,
    _callback: [Function: RP$callback],
    proxy: null,
    tunnel: true,
    setHost: true,
    originalCookieHeader: undefined,
    _disableCookies: true,
    _jar: undefined,
    port: 443,
    host: 'api.wink.com',
    path: '/oauth2/token',
    _json: true,
    httpModule: [Object],
    agentClass: [Function],
    agent: [Agent],
    _started: true,
    href: 'https://api.wink.com/oauth2/token',
    req: [ClientRequest],
    ntick: true,
    response: [Circular],
    originalHost: 'api.wink.com',
    originalHostHeaderName: 'host',
    responseContent: [Circular],
    _destdata: true,
    _ended: true,
    _callbackCalled: true },
 toJSON: [Function: responseToJSON],
 caseless: Caseless { dict: [Object] },
 body: { data: null, errors: [Array], pagination: {} } } }
rshim630 commented 6 years ago

Seems like try starting up and get this error, you will keep getting it unless you stop and wait for the rate limit to reset.

In the output, look for "x-ratelimit-reset> That date-time is in UTC and should only be a few minutes in the future. Quit HomeBridge and wait for the specified time in local time and then start again.