Skip to content

Instantly share code, notes, and snippets.

@apapirovski
Created September 15, 2017 09:08
Show Gist options
  • Save apapirovski/fa1da19f0c88ea45cc317c40760e51e0 to your computer and use it in GitHub Desktop.
Save apapirovski/fa1da19f0c88ea45cc317c40760e51e0 to your computer and use it in GitHub Desktop.
'use strict';
const h2 = require('http2');
const server = h2.createServer();
server.on('request', (req, res) => res.end());
server.on('timeout', () => console.log('timeout'));
server.listen(0, () => {
const port = server.address().port;
const url = `http://localhost:${port}`;
const client = h2.connect(url);
makeReq();
function makeReq() {
console.log('heartbeat');
const request = client.request({
':path': '/foobar',
':method': 'GET',
':scheme': 'http',
':authority': `localhost:${port}`,
});
request.end();
setTimeout(makeReq, 60000);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment