1'use strict'; 2const common = require('../common'); 3const fixtures = require('../common/fixtures'); 4 5// This test verifies that when a server receives an unknownProtocol it will 6// not leave the socket open if the client does not close it. 7 8if (!common.hasCrypto) 9 common.skip('missing crypto'); 10 11const h2 = require('http2'); 12const tls = require('tls'); 13 14const server = h2.createSecureServer({ 15 key: fixtures.readKey('rsa_private.pem'), 16 cert: fixtures.readKey('rsa_cert.crt'), 17 unknownProtocolTimeout: 500, 18 allowHalfOpen: true 19}); 20 21server.on('connection', (socket) => { 22 socket.on('close', common.mustCall(() => { 23 server.close(); 24 })); 25}); 26 27server.listen(0, function() { 28 tls.connect({ 29 port: server.address().port, 30 rejectUnauthorized: false, 31 ALPNProtocols: ['bogus'] 32 }); 33}); 34