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 f65138c5..23667765 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); } @@ -227,7 +227,7 @@ C.open = function(allFields, openCallback0) { tunedOptions.channelMax = negotiate(fields.channelMax, allFields.channelMax); tunedOptions.heartbeat = - negotiate(fields.heartbeat, allFields.heartbeat); + allFields.heartbeat === null ? fields.heartbeat : allFields.heartbeat send(defs.ConnectionTuneOk); send(defs.ConnectionOpen); expect(defs.ConnectionOpenOk, onOpenOk);