diff --git a/lib/adapters/http.js b/lib/adapters/http.js index a39773f9f7..98ab7d89a1 100755 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -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.