Bug report: If websocket fails to open or anomalously closes before terminated, sample will still try send message.
yehudacohen opened this issue · 1 comments
yehudacohen commented
var socket = new WebSocket(...)
if (socket.OPEN) {
// doStuff
}
will always evaluate to true. socket.OPEN is a constant that evaluates to 1 even when the socket is closed. To test correctly for whether a socket is open, use:
var socket = new WebSocket(...)
if (socket.OPEN === socket.readyState) {
// doStuff
}
I'll submit a pull request with fixes.
See here for the appropriate API usage:
https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
brandonmwest commented
Thanks!