Skip to content

Should getDataStream.subscribe continue to fire after re-connection? #78

@NadavK

Description

@NadavK

I create a $websocket instance with the reconnect param: {"reconnectIfNotNormalClose": true} and the stream nicely reconnects on failures.

I have a problem with incoming messages:
ws.getDataStream().subscribe correctly fires on incoming messages until the websocket reconnects, after which it stops firing.

Am I missing a step so ws.getDataStream().subscribe continues firing after an automatic reconnection?

here is the code (comments welcome, I am new to js):

this.ws = new $WebSocket('wss://...', null, JSON.parse('{"reconnectIfNotNormalClose": true}'));
this.ws.getDataStream().subscribe(
  (msg: MessageEvent) => console.log('message received: ', msg),
  (err) => console.log('incoming websocket err', err),
  () => console.log('incoming websocket complete')
);

I also tried moving the subscribe into the stream's onOpen, but it behaves the same as above (fires only for the initial connection):

this.ws = new $WebSocket('wss://...', null, JSON.parse('{"reconnectIfNotNormalClose": true}'));
this.stream.onOpen(
  this.ws.getDataStream().subscribe(
    (msg: MessageEvent) => console.log('message received: ', msg),
    (err) => console.log('incoming websocket err', err),
    () => console.log('incoming websocket complete')
  )
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions