node-http2 icon indicating copy to clipboard operation
node-http2 copied to clipboard

getConnections() api missing

Open trading-peter opened this issue 9 years ago • 0 comments

The good plugin of hapijs uses getConnections which isn't implemented afaik. https://nodejs.org/api/net.html#net_server_getconnections_callback

/Users/xx/xxx/node_modules/good/lib/network.js:84
        connection.listener.getConnections(function (err, count) {
                            ^

TypeError: connection.listener.getConnections is not a function
    at /Users/xx/xxx/node_modules/good/lib/network.js:84:29
    at iterate (/Users/xx/xxx/node_modules/items/lib/index.js:35:13)
    at Object.exports.serial (/Users/xx/xxx/node_modules/items/lib/index.js:38:9)
    at internals.NetworkMonitor.concurrents (/Users/xx/xxx/node_modules/good/lib/network.js:82:11)
    at Function.exports.parallel.execute (/Users/xx/xxx/node_modules/items/lib/index.js:114:23)
    at null._repeat (/Users/xx/xxx/node_modules/good/lib/monitor.js:110:28)
    at wrapper [as _onTimeout] (timers.js:275:11)
    at Timer.listOnTimeout (timers.js:92:15)

I managed to make the 'good' plugin work with the following patch and it seems to work correctly:

const listener = Http2.createServer({
  key: Fs.readFileSync(ServerConfig.tls.key),
  cert: Fs.readFileSync(ServerConfig.tls.cert)
});

listener.getConnections = function(cb) {
  process.nextTick(() => {
    cb(null, this._server._connections);
  });
};

My question now is: Is _connections the right property? Is this something that should be implemented in to node-http2?

Thanks for this awesome project!

trading-peter avatar Jun 08 '16 17:06 trading-peter