From 26b8fa38cc311eb9ed5421a163b3873c7781bd97 Mon Sep 17 00:00:00 2001 From: Vlad Lasky Date: Mon, 9 Jan 2023 19:51:10 +1100 Subject: [PATCH] Enable TCP_NODELAY flag on TCP socket (disable Nagle's algorithm). This ensures packets are sent as soon as they're ready, lowering latency. --- lib/Connection.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Connection.js b/lib/Connection.js index 76fcbb049..0112cbe9e 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -429,6 +429,7 @@ Connection.prototype._handleProtocolDrain = function() { Connection.prototype._handleProtocolConnect = function() { this.state = 'connected'; + this._socket.setNoDelay(true); this.emit('connect'); };