1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Make a new stream on reconnect

This commit is contained in:
Iain Proctor
2014-07-08 21:36:23 +00:00
parent c68b3f7bd3
commit c687d2e4fd

View File

@@ -81,6 +81,14 @@ function RedisClient(stream, options) {
this.old_state = null; this.old_state = null;
this.install_stream_listeners();
events.EventEmitter.call(this);
}
util.inherits(RedisClient, events.EventEmitter);
exports.RedisClient = RedisClient;
RedisClient.prototype.install_stream_listeners = function() {
var self = this; var self = this;
this.stream.on("connect", function () { this.stream.on("connect", function () {
@@ -107,11 +115,7 @@ function RedisClient(stream, options) {
self.should_buffer = false; self.should_buffer = false;
self.emit("drain"); self.emit("drain");
}); });
};
events.EventEmitter.call(this);
}
util.inherits(RedisClient, events.EventEmitter);
exports.RedisClient = RedisClient;
RedisClient.prototype.initialize_retry_vars = function () { RedisClient.prototype.initialize_retry_vars = function () {
this.retry_timer = null; this.retry_timer = null;
@@ -520,7 +524,8 @@ RedisClient.prototype.connection_gone = function (why) {
return; return;
} }
self.stream.connect(self.port, self.host); self.stream = net.createConnection(self.port, self.host);
self.install_stream_listeners();
self.retry_timer = null; self.retry_timer = null;
}, this.retry_delay); }, this.retry_delay);
}; };