Skip to content

Instantly share code, notes, and snippets.

@AlexFrazer
Created November 30, 2015 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexFrazer/6e64ae86d2b279f12160 to your computer and use it in GitHub Desktop.
Save AlexFrazer/6e64ae86d2b279f12160 to your computer and use it in GitHub Desktop.
socket.on('close', Meteor.bindEnvironment(hasError => {
let retries = this.collection.findOne({ name: this.name }).connection.retryCount;
if (retries < this.config.maxRetries) {
Meteor.setTimeout(() => {
this.collection.update({ name: this.name }, {
$set: {
'connection.status': 'connecting',
'connection.retryTime': new Date
},
$inc: { 'connection.retryCount': 1 }
});
super.connect(...args);
}, this.config.retryInterval);
} else {
this.removeAllListeners();
this.collection.update({ name: this.name }, {
$set: {
'connection.status': 'failed',
'connection.reason': 'Max retries exceeded'
}
});
this.end();
}
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment