From ff660b44a99ac5dd98894973b2476516b6291109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20Ho=CC=88rberg?= Date: Wed, 17 Oct 2018 15:41:46 +0200 Subject: [PATCH 1/3] disable heartbeats if hearbeat set to 0 --- lib/connection.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/connection.js b/lib/connection.js index f65138c5..9c9e8870 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -227,7 +227,8 @@ C.open = function(allFields, openCallback0) { tunedOptions.channelMax = negotiate(fields.channelMax, allFields.channelMax); tunedOptions.heartbeat = - negotiate(fields.heartbeat, allFields.heartbeat); + allFields.heartbeat === 0 ? + 0 : negotiate(fields.heartbeat, allFields.heartbeat); send(defs.ConnectionTuneOk); send(defs.ConnectionOpen); expect(defs.ConnectionOpenOk, onOpenOk); From 8268eb4d867458b222cd2fccb045135293f61e73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20Ho=CC=88rberg?= Date: Wed, 24 Oct 2018 01:29:34 +0200 Subject: [PATCH 2/3] default heartbeat to null, which means use servers value --- lib/connect.js | 2 +- lib/connection.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/connect.js b/lib/connect.js index 603f1981..187a6d99 100644 --- a/lib/connect.js +++ b/lib/connect.js @@ -67,7 +67,7 @@ function openFrames(vhost, query, credentials, extraClientProperties) { // tune-ok 'channelMax': intOrDefault(query.channelMax, 0), 'frameMax': intOrDefault(query.frameMax, 0x1000), - 'heartbeat': intOrDefault(query.heartbeat, 0), + 'heartbeat': intOrDefault(query.heartbeat, null), // open 'virtualHost': vhost, diff --git a/lib/connection.js b/lib/connection.js index 9c9e8870..e8260b07 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -189,7 +189,7 @@ C.open = function(allFields, openCallback0) { // frameMax, but we'll leave that to the server to enforce). In // all cases, `0` really means "no limit", or rather the highest // value in the encoding, e.g., unsigned short for channelMax. - if (server === 0 || desired === 0) { + if (server === 0 || desired === 0 || desired === null) { // i.e., whichever places a limit, if either return Math.max(server, desired); } From 481b0629f16733a3ab3b3f529ef123b3fdc62f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20Ho=CC=88rberg?= Date: Mon, 10 Dec 2018 14:43:27 +0100 Subject: [PATCH 3/3] if heartbeat is set client side then always use that value --- lib/connection.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/connection.js b/lib/connection.js index e8260b07..23667765 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -227,8 +227,7 @@ C.open = function(allFields, openCallback0) { tunedOptions.channelMax = negotiate(fields.channelMax, allFields.channelMax); tunedOptions.heartbeat = - allFields.heartbeat === 0 ? - 0 : negotiate(fields.heartbeat, allFields.heartbeat); + allFields.heartbeat === null ? fields.heartbeat : allFields.heartbeat send(defs.ConnectionTuneOk); send(defs.ConnectionOpen); expect(defs.ConnectionOpenOk, onOpenOk);