Skip to content

Conversation

scottinet
Copy link
Contributor

Description

If autoReconnect is true, the SDK tries to reconnect every reconnectionDelay milliseconds.

If executed within a browser, the SDK can know if the browser has access to some kind of network: if it's marked as "offline", then there is no point retrying to connect, and this might even be harmful in some situations. For instance, browsers switch to offline if a laptop lid is closed, or if a mobile phone screen is turned off. So continuing to connect is just a useless consumption of battery power.

This PR stops the reconnection loop and instead waits for the browser to switch to "online" again before resuming its reconnection attempts.

@codecov
Copy link

codecov bot commented Oct 25, 2019

Codecov Report

Merging #455 into 7-dev will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           7-dev     #455      +/-   ##
=========================================
+ Coverage     96%   96.01%   +0.01%     
=========================================
  Files         33       33              
  Lines       1350     1355       +5     
=========================================
+ Hits        1296     1301       +5     
  Misses        54       54
Impacted Files Coverage Δ
src/protocols/abstract/realtime.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a11c5eb...0dc062a. Read the comment docs.

@scottinet scottinet merged commit 4af6751 into 7-dev Nov 7, 2019
@scottinet scottinet deleted the KZL-1401/stop-reconnecting branch November 7, 2019 15:21
@Aschen Aschen mentioned this pull request Nov 20, 2019
Aschen added a commit that referenced this pull request Nov 21, 2019
# [7.0.0](https://github.com/kuzzleio/sdk-javascript/releases/tag/7.0.0) (2019-11-20)


#### Bug fixes

- [ [#464](#464) ] Fix option refresh in queries   ([Yoann-Abbes](https://github.com/Yoann-Abbes))
- [ [#463](#463) ] Fix erroneous error message on browser ws error   ([scottinet](https://github.com/scottinet))

#### Enhancements

- [ [#455](#455) ] Do not try to reconnect if the browser is offline   ([scottinet](https://github.com/scottinet))
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants