Skip to content

Add maximum retries to polling after network error. #472

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add maximum retries to polling after network error.
  • Loading branch information
Víctor Oliva committed Feb 13, 2019
commit 059c677eef10f427ff3afed1d5a9887d530e4aef
7 changes: 6 additions & 1 deletion lib/transport/lib/polling.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function Polling(Receiver, receiveUrl, AjaxObject) {
this.Receiver = Receiver;
this.receiveUrl = receiveUrl;
this.AjaxObject = AjaxObject;
this.networkRetries = 0;
this._scheduleReceiver();
}

Expand All @@ -26,6 +27,7 @@ Polling.prototype._scheduleReceiver = function() {
var poll = this.poll = new this.Receiver(this.receiveUrl, this.AjaxObject);

poll.on('message', function(msg) {
self.networkRetries = 0;
debug('message', msg);
self.emit('message', msg);
});
Expand All @@ -35,7 +37,8 @@ Polling.prototype._scheduleReceiver = function() {
self.poll = poll = null;

if (!self.pollIsClosing) {
if (reason === 'network') {
if (reason === 'network' && self.networkRetries < Polling.NETWORK_RETRIES) {
self.networkRetries++;
self._scheduleReceiver();
} else {
self.emit('close', code || 1006, reason);
Expand All @@ -54,4 +57,6 @@ Polling.prototype.abort = function() {
}
};

Polling.NETWORK_RETRIES = 3;

module.exports = Polling;
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy