diff --git a/docs/WebSocketServer.md b/docs/WebSocketServer.md index e0ea60c6..77f9eb66 100644 --- a/docs/WebSocketServer.md +++ b/docs/WebSocketServer.md @@ -58,6 +58,9 @@ If true, the server will automatically send a ping to all clients every `keepali **keepaliveInterval** - uint - *Default: 20000* The interval in milliseconds to send keepalive pings to connected clients. +**keepaliveForce** - boolean - *Default: false* +if true, the server will not reset the keepalive timer when any data is received from the client, forcing to send the ping on the Interval. + **dropConnectionOnKeepaliveTimeout** - boolean - *Default: true* If true, the server will consider any connection that has not received any data within the amount of time specified by `keepaliveGracePeriod` after a keepalive ping has been sent. Ignored if `keepalive` is false. diff --git a/lib/WebSocketConnection.js b/lib/WebSocketConnection.js index 219de631..6b3e274a 100644 --- a/lib/WebSocketConnection.js +++ b/lib/WebSocketConnection.js @@ -262,7 +262,9 @@ WebSocketConnection.prototype.handleGracePeriodTimer = function() { WebSocketConnection.prototype.handleSocketData = function(data) { this._debug('handleSocketData'); // Reset the keepalive timer when receiving data of any kind. - this.setKeepaliveTimer(); + if (!this.config.keepaliveForce) { + this.setKeepaliveTimer(); + } // Add received data to our bufferList, which efficiently holds received // data chunks in a linked list of Buffer objects.