Repository: node
Issue: Keep Alive option is not working on https.agent 
Labels: tls,https

### Version

v18.15.0 

### Platform

mac

### Subsystem

_No response_

### What steps will reproduce the bug?

- Create a web server that handle requests through https protocol. 
Note: this step is just if you do not have a web server already set up
    - In my case I used an ec2 instance, with a public Ip, and python along with flask as follow:
        - Set up an ec2 install with linux
        - Make sure the security group attached to the instance allows http and https traffic. 
        - Install python3 if not installed
        - Create a self signed ssl:
            - ``` openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365 ```
        - Install the python3 needed dependencies:
            - ``` pip3 install flask ```
            - ``` pip3 install pyopenssl```
            - create a python file ``` touch server.py ``` and paste the following code:
            ``` python
            from flask import Flask
            import time
            import json

            app = Flask(__name__)

            @app.route('/sleep/<int:secs>')
            def sleep(secs):
                time.sleep(secs)

                return ({
                   'message': 'Function sleep for ' + str(secs) + ' seconds!'
                })

            if __name__ == '__main__':
                app.run(port=443, host='0.0.0.0', ssl_context=('cert.pem', 'key.pem')

            ```
        - Then, start the server ``` python3 server.py ```
- Then, at client side install wireshark to monitor network traffic. In my case I use brew from a mac ``` brew install --cask wireshark ``` 
- Then, set up a nodejs environment, if does not have nodejs make sure you install it. In my case I use nvm, but also need to install nvm before hands.
- Then, create a js file ``` touch index.js ```
- Then, copy and paste the code below:
```js
import { Agent as HAgent, request as HRequest } from "https";
const serverPort = 443;
const serverHost = 'YOUR WEB SERVER HOST, IN MY CASE I USED MY EC2 INSTANCE PUBLIC IP';
const agent = new HAgent({
    keepAlive: true,
    keepAliveMsecs: 10 * 1000,
    maxSockets: 100,
    maxTotalSockets: 100,
    maxFreeSockets: 256,
    timeout: 2000,
    scheduling: "fifo",
    port: serverPort,
    host: serverHost,

});
const handleRequest = (response) => {
    let data = '';
    response.on('data', (chunk) => {
        data += Buffer.from(chunk).toString('utf-8');
    })
    response.on('end', () => {
        console.log('Response: ', data);
    })
}
const reqFunc = HRequest({
    protocol: 'https:',
    headers: {},
    host: serverHost,
    method: 'GET',
    agent: agent,
    path: 'sleep/100',
    port: serverPort,
}, (res) => handleRequest(res));
reqFunc.on('error', (err) => {
    console.log('Error: ', err)
} )
reqFunc.end()
```
- Then, open wireshark and set a filter to monitor the interface the host machine you are on is using. If you do not know which host machine is yours you could do ``` route get 10.10.10.10 ``` and you will see the interface there:
![Screenshot 2023-03-17 at 6 41 33 AM](https://user-images.githubusercontent.com/47982775/225922137-4aa62b67-1094-4d75-8c31-4f8a84aecbf9.png)
- Then, set another filter that just shows the traffic where the destination IP is the IP of your web server. 
- Then, just run the  nodejs script to start having some traffic.
- And, based on the configuration of my agent, we should have a keep alive packet going out every 10 seconds, but it will never happen:
![Screenshot 2023-03-17 at 6 47 55 AM(1)](https://user-images.githubusercontent.com/47982775/225924070-b8b43e92-f87a-4a2f-af22-ffd7e70ee64f.png)

- But If instead of using a https agent I use http then, I can see the keep alive packets going:
![Untitled Diagram drawio](https://user-images.githubusercontent.com/47982775/225927695-3055292a-a048-4590-b437-34839fea3046.png)



### How often does it reproduce? Is there a required condition?

It is always reproducible as soon as you use https.Agent

### What is the expected behavior? Why is that the expected behavior?

When keep alive is set to true then it should be honored and keep-alive packets should be going out.

### What do you see instead?

Not keep-alive packets going out.

### Additional information

_No response_