alladdin / node-lox-ws-api

Node JS WebSocket Loxone™ API
MIT License
32 stars 23 forks source link

Out of range RangeError on node v10 #17

Closed andrasg closed 5 years ago

andrasg commented 5 years ago

Opening a connection on node v10 results in a RangeError:

internal/buffer.js:35
    throw new ERR_OUT_OF_RANGE('value', `>= ${min} and <= ${max}`, value);
    ^

RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received -226321205
    at checkInt (internal/buffer.js:35:11)
    at writeU_Int32BE (internal/buffer.js:623:3)
    at Buffer.writeUInt32BE (internal/buffer.js:636:10)
    at WebSocketFrame.toBuffer (/home/pi/Documents/loxone-influx/node_modules/websocket/lib/WebSocketFrame.js:257:24)
    at WebSocketConnection.sendFrame (/home/pi/Documents/loxone-influx/node_modules/websocket/lib/WebSocketConnection.js:857:43)
    at WebSocketConnection.fragmentAndSend (/home/pi/Documents/loxone-influx/node_modules/websocket/lib/WebSocketConnection.js:793:14)
    at WebSocketConnection.sendUTF (/home/pi/Documents/loxone-influx/node_modules/websocket/lib/WebSocketConnection.js:733:10)
    at Connection.send (/home/pi/Documents/loxone-influx/node_modules/node-lox-ws-api/lib/Connection.js:110:29)
    at TokenEnc._generate_session_key (/home/pi/Documents/loxone-influx/node_modules/node-lox-ws-api/lib/Auth/Token-Enc.js:114:22)
    at IncomingMessage.res.on (/home/pi/Documents/loxone-influx/node_modules/node-lox-ws-api/lib/Auth/Token-Enc.js:92:18)

Works perfectly on node v8.

codmpm commented 5 years ago

Can confirm... node-red-contrib-loxone will thus not run with node 10.x

RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received -298553816
    at checkInt (internal/buffer.js:35:11)

nodejs v10.13.0
node-lox-ws-api 0.4.3
alladdin commented 5 years ago

It's caused by old version of websocket package - fixed

andrasg commented 5 years ago

Commit that fixes the issue for reference:

https://github.com/alladdin/node-lox-ws-api/commit/5a2b8f52e7ef24dfee7fc9f70e286da4bc31fcfd