Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reconnect handling #2

Open
ib1987 opened this issue Apr 13, 2017 · 2 comments
Open

Reconnect handling #2

ib1987 opened this issue Apr 13, 2017 · 2 comments

Comments

@ib1987
Copy link

ib1987 commented Apr 13, 2017

Hi @devsullo,

this module is really useful, thanks for it.
Please help me, how can i handle the reconnect situation?
My client lifecycle:

  1. connect
  2. subscribe
  3. connection lost (e.g.: backend error)
  4. reconnect
  5. -> and at this point i need to subscribe again.

--Ben

@devsullo
Copy link
Owner

Hi, Thank you @ib1987

I think one way to do it is to pass 'subscribe' to onConnect method and every time when connection is no longer available module will try to reconnect and when connection established every 'subscribe' what we passed will happened inside onConnect method

@Xenoage
Copy link

Xenoage commented Jun 29, 2017

I had the same problem. This was my old code, where after reconnection the subscriptions were lost:

stomp.startConnect().then(() => {
  stomp.done('init')
  stomp.subscribe( ... )
})

And this is the new working code: The subscriptions are renewed each time an onConnect event is received:

let originalOnConnect = stomp.onConnect
stomp.onConnect = (frame: any) => {
  originalOnConnect(frame)
  stomp.subscribe( ... )
}
stomp.startConnect().then(() => {
  stomp.done('init')
})`

Feature request: It would be great if the library could manage the subscriptions automatically 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants