added option for eventlistenerCount(max)

This commit is contained in:
vinodsr 2013-05-31 07:02:32 +05:30 committed by indexzero
parent 1333c0cc62
commit 8eb6780f87

View File

@ -103,6 +103,9 @@ var HttpProxy = exports.HttpProxy = function (options) {
? this.enable.xforward
: true;
// if event listener is set then use it else unlimited.
this.eventListenerCount = typeof options.eventListenerCount === 'number'? options.eventListenerCount : 0 ;
//
// Setup additional options for WebSocket proxying. When forcing
// the WebSocket handshake to change the `sec-websocket-location`
@ -371,10 +374,9 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
res.on('drain', ondrain);
});
// allow unlimited listeners ...
reverseProxy.setMaxListeners(0);
reverseProxy.setMaxListeners(this.eventListenerCount);
//
// Handle 'error' events from the `reverseProxy`. Setup timeout override if needed
//