appuri / robust-websocket

A robust reconnecting WebSocket client for the browser
ISC License
201 stars 19 forks source link

0.2.0 no longer works for me #3

Closed dubiousdavid closed 7 years ago

dubiousdavid commented 7 years ago

0.1.0 works great, but 0.2.0 is not reconnecting for me. Here is my logic (uses Kefir FRP):

import WebSocket from 'robust-websocket'
let ws = new WebSocket('wss://echo.websocket.org')

let online$ = Kefir.fromPoll(500, () => navigator.onLine).skipDuplicates()

let socketConnected$ = Kefir.stream(emitter => {
  ws.onopen = () => emitter.emit(true)
  ws.onclose = () => emitter.emit(false)
})

let connected$ = socketConnected$
  .combine(online$, (connected, online) => connected && online)
  .toProperty(() => false)
nathanboktae commented 7 years ago

Don't you mean new RobustWebSocket? Also if you use wss are you also connecting from a page on |hyyps`?

dubiousdavid commented 7 years ago

Sorry, I updated the code sample. I'm doing an ES6 import earlier in the code.

dubiousdavid commented 7 years ago

Yes, it's connecting from an https page: https://dubiousdavid.github.io/muv.js/examples/websocket/

nathanboktae commented 7 years ago

That example uses ReconnectingWebSocket not RobustWebSocket. See line 4472.

A vanilla JS example (not babel, not using a framework) would help.

nathanboktae commented 7 years ago

Here's my working codepen of 0.2.0. Reopen if you have more insights.