spdy-http2 / node-spdy

SPDY server on Node.js
2.81k stars 196 forks source link

Handling ping frames within the server #331

Open AdamMagaluk opened 6 years ago

AdamMagaluk commented 6 years ago

tl;dr: Is there a way to listen for http2/spdy ping frames in the context of the server and if not would you accept a PR to expose this functionality.

As a user of your library it would be helpful in some cases to listen for ping frames from the context of the server. Something of the order:

var server = spdy.createServer(options, function(req, res) {
  res.writeHead(200);
  res.end('hello world!');
});

// Listen for all spdy/h2 pings on all connections
server.on('ping', function(connection) {
  // do some logic...
});

server.listen(3000);

A little background on my use case, I maintain an open source IoT framework written in Node.js called Zetta and have been using this library as a core part of our Z2Z Peering protocol. One piece of it relies on the server listening for ping requests on the connection, we were able to do this in a very hacky way for years using the 1.8x version. We are in the process (https://github.com/zettajs/zetta/pull/360 https://github.com/zettajs/zetta/issues/336) of upgrading to the latest spdy version but this is one area that is stopping us and ideally we don't want to use a forked version with just that change.

Any thoughts on how we could do it without any changes? And if not would you accept a PR to expose this functionality? Thanks.