2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-08 17:22:34 +03:00

Adding a socket handler for keep TCP connection (#3422)

This is not http keepalive option it is TCP level
which is lower than HTTP.

It will send meanless ack flag packet to server.
so it woudn't be drop TCP connection by server side
like Firewall, Loadbalancer, Nginx etc.

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Doowonee
2021-12-23 03:56:14 +09:00
committed by GitHub
parent ebedf6b653
commit 55e6577b75
+6
View File
@@ -313,6 +313,12 @@ module.exports = function httpAdapter(config) {
reject(enhanceError(err, config, null, req));
});
// set tcp keep alive to prevent drop connection by peer
req.on('socket', function handleRequestSocket(socket) {
// default interval of sending ack packet is 1 minute
socket.setKeepAlive(true, 1000 * 60);
});
// Handle request timeout
if (config.timeout) {
// This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.