11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// This test verifies that when a server receives an unknownProtocol it will 61cb0ef41Sopenharmony_ci// not leave the socket open if the client does not close it. 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciif (!common.hasCrypto) 91cb0ef41Sopenharmony_ci common.skip('missing crypto'); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst h2 = require('http2'); 121cb0ef41Sopenharmony_ciconst tls = require('tls'); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst server = h2.createSecureServer({ 151cb0ef41Sopenharmony_ci key: fixtures.readKey('rsa_private.pem'), 161cb0ef41Sopenharmony_ci cert: fixtures.readKey('rsa_cert.crt'), 171cb0ef41Sopenharmony_ci unknownProtocolTimeout: 500, 181cb0ef41Sopenharmony_ci allowHalfOpen: true 191cb0ef41Sopenharmony_ci}); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciserver.on('connection', (socket) => { 221cb0ef41Sopenharmony_ci socket.on('close', common.mustCall(() => { 231cb0ef41Sopenharmony_ci server.close(); 241cb0ef41Sopenharmony_ci })); 251cb0ef41Sopenharmony_ci}); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ciserver.listen(0, function() { 281cb0ef41Sopenharmony_ci tls.connect({ 291cb0ef41Sopenharmony_ci port: server.address().port, 301cb0ef41Sopenharmony_ci rejectUnauthorized: false, 311cb0ef41Sopenharmony_ci ALPNProtocols: ['bogus'] 321cb0ef41Sopenharmony_ci }); 331cb0ef41Sopenharmony_ci}); 34