question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onclose behaviour has changed -- was it intentional?

See original GitHub issue

I noticed my application was failing to reconnect after the reconnecting-websocket rewrite. Upon investigation, I realised this seems to be because this library no longer reconnects when a websocket is intentionally closed by the server – a close event is triggered but nothing else happens.

Previously, a graceful server-side close event would trigger a reconnect: https://github.com/pladaria/reconnecting-websocket/blob/e79fba552f236463adac04e1872f5e20e37d66a1/index.ts#L141

…but now the reconnect is not triggered: https://github.com/pladaria/reconnecting-websocket/blob/2e5d6f0406784da357e3213506c9b508c2b32991/reconnecting-websocket.ts#L392

The reconnect mechanism is triggered on error so I suspect this is an intentional change.

What do you think about adding a reconnectOnClose option, on by default?

Alternatively the docs could be updated to clarify this behaviour, and perhaps suggest manually binding a reconnect such as:

rws.addEventListener('close', () => rws.reconnect());

Although that seems to cause thrashing if the connection cannot be established, as reconnect calls _disconnect which calls the handlers again.

Thanks for the well written library.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:24 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
haizzcommented, Jun 25, 2018

Is there any progress on this? Not reconnecting after server dropout totally devalues this library.

6reactions
ernierastacommented, Jun 8, 2018

The same here, v3.2.2 behaves how most of us wants. @usefulthink has a good idea. Or maybe even better - old behavior should be preserved. At the end - that is a reason why most of us use this library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[SOLVED] MessageBox.Show – behaviour changed – Wisej.com
My question is whether it's changed intentionally and will be so or it's a bug and will be fixed soon? Regards,. Michael. Bugs....
Read more >
Intentional and unintentional non-adherence to social ... - NCBI
[13] the notions of intentional/unintentional non-adherence and argued that non-adherence behaviours to SD measures could be identified as intentional (i.e. ...
Read more >
Gaze behavior during incidental and intentional navigation in ...
In this case, we hypothesize that the gaze focus during incidental learning may instead be biased towards the visual salience of landmarks.
Read more >
SQL Server on Linux: How is Delete-On-Close Handled ...
Intentionally, the Host Extension does not open the file and then invoke unlink or remove. Linux allows a file open syscall, followed by...
Read more >
Handling connection loss with websockets - Stack Overflow
and also change these parameters by specifying the branch & preference along ... If the connection is lost, the onclose event is triggered...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found