pladaria / reconnecting-websocket

Reconnecting WebSocket. For Web, React Native, cli (Node.js)
MIT License
1.22k stars 197 forks source link

Does not work with w3cwebsocket from websocket-node #116

Open she11sh0cked opened 4 years ago

she11sh0cked commented 4 years ago

Should reconnectingWebsocket work with this library? https://github.com/theturtle32/WebSocket-Node

ReconnectingWebSocket gives an UnhandledPromiseRejectionWarning when using websocket-node's w3cwebsocket

Reproducing

websocket version used: 1.0.31

import { w3cwebsocket } from 'websocket'

const rws = new ReconnectingWebSocket(process.env.WS_URI, [], {
    WebSocket: w3cwebsocket,
})

Error

(node:27388) UnhandledPromiseRejectionWarning: SyntaxError: just "arraybuffer" type allowed for "binaryType" attribute
    at W3CWebSocket.set (D:\Projects\example\node_modules\websocket\lib\W3CWebSocket.js:85:23)
    at D:\Projects\example\node_modules\reconnecting-websocket\dist\reconnecting-websocket-cjs.js:487:34
(node:27388) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27388) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
nicofrand commented 2 years ago

Hi,

the message is quite clear: you need to define the binaryType to "arraybuffer": ws.binaryType ="arraybuffer";