If the server does not respond within the specified time (it may be a problem with the connection between the networks, or it may be because the server fails or the network firewall blocks the connection between the client and the server), the response times out and http is triggered at the same time. The timeout event of the ServerResponse object.
response.setTimeout(time,[callback]);
You can also not specify the callback function in setTimeout. You can use time monitoring to specify the callback function.
If a timeout callback function is not specified, then a timeout occurs, the socket port connected to the http client will be automatically closed. If a timeout callback function is specified, then a callback function will be called instead of a timeout. The socket port connected to the http client will be automatically closed.
Result of running the code:
After deleting the timeout callback function: