faye/websocket-driver-node

_handshakeSignature() throwing "TypeError: value is out of bounds" error

Closed this issue · 8 comments

Sometimes our server crashes running the following code in the draft76.js file:

buffer.writeUInt32BE(value1, 0); // <-- (line 69): sometimes it crashes here
buffer.writeUInt32BE(value2, 4); // <-- (line 70): other times it crashes here

Any idea about what is causing this? A simple try/catch hack avoids the crash but it's far from ideal ...

Can you log the values of the headers and body in these variables when the error happens, and share the results here? I currently have no data that reproduces this error.

https://github.com/faye/websocket-driver-node/blob/master/lib/websocket/driver/draft76.js#L61-L67

Hope this helps:

this._body: [ 153, 87, 142, 63, 2, 1, 123, 177 ]
this.BODY_SIZE: 8

headers: { upgrade: 'WebSocket',
connection: 'Upgrade',
host: 'server-domain.com',
origin: 'http://client-domain.com',
'sec-websocket-key1': '2 L785 8o% s9Sy9@V. 4<1P5',
'sec-websocket-key2': '"yw * K=2 3 : 5 D 3 85^5;0\7 5',
'x-forwarded-for': '1.2.3.4' }

key1: 2 L785 8o% s9Sy9@V. 4<1P5
value1: 696474853.75

key2: "yw * K=2 3 : 5 D 3 85^5;0\7 5
value2: 261539452.7777778

Thanks, this is now fixed in 68990a2.

Thanks @jcoglan. When can we expect a version bump (to npm)?

As soon as I've rounded up the remaining pending issues on the faye websocket modules and gone through the pre-release tests. Running these tests takes pretty much a whole day so I try to clear my backlog before spending the time to get a release done.

I understand. Are we talking about a few days or weeks?

Looking at my calender I wouldn't expect a new release round until later this month.

Cool, we'll patch it in the meanwhile. Thanks for the help.