'why nodejs cannot close tcp connection?


this is my client.js code
const http = require('http')
const axios = require('axios')
http.globalAgent.keepAlive = true
http.globalAgent.maxFreeSockets = 700
const test = async () => {
const ret = await axios.post('http://localhost:9000/test')
console.log('============ret', ret)
for (let i = 0; i < 10000000; i++) {
console.log(i)
}
}
test()
this is my server.js code.
const express = require('express')
const http = require('http')
// set globalAgent
http.globalAgent.keepAlive = true
http.globalAgent.maxFreeSockets = 700
const PORT = 9000
const app = express()
app.post('/test', (req, res, next) => {
res.send('hello')
})
// start server
const server = app.listen(PORT)
server.keepAliveTimeout = 60 * 1000
this is package.json,rely on [email protected] [email protected]
{
"dependencies": {
"axios": "^0.26.1",
"express": "^4.17.3"
}
}
nodejs version v16.13.0
Wireshark version 3.6.3
my expected is

// 2022-04-08 update
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
