Skip to content

Commit

Permalink
[NEW] Added option for maxControlLineSize, by default it is 1024 byte…
Browse files Browse the repository at this point in the history
…s to match server default.
  • Loading branch information
Alberto Ricart committed Oct 24, 2017
1 parent cc52314 commit b497fc3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/nats.js
Expand Up @@ -21,7 +21,7 @@ var net = require('net'),
/**
* Constants
*/
var VERSION = '0.7.24',
var VERSION = '0.7.26',

DEFAULT_PORT = 4222,
DEFAULT_PRE = 'nats://localhost:',
Expand Down Expand Up @@ -214,6 +214,7 @@ Client.prototype.parseOptions = function(opts) {
'encoding': 'utf8',
'tls': false,
'waitOnFirstConnect': false,
'maxControlLineSize': MAX_CONTROL_LINE_SIZE
};

if (undefined === opts) {
Expand Down Expand Up @@ -252,6 +253,7 @@ Client.prototype.parseOptions = function(opts) {
this.assignOption(opts, 'waitOnFirstConnect');
this.assignOption(opts, 'json');
this.assignOption(opts, 'preserveBuffers');
this.assignOption(opts, 'maxControlLineSize');
}

var client = this;
Expand Down Expand Up @@ -764,7 +766,7 @@ Client.prototype.processInbound = function() {
case AWAITING_CONTROL:
// Regex only works on strings, so convert once to be more efficient.
// Long term answer is a hand rolled parser, not regex.
var buf = client.inbound.toString('binary', 0, MAX_CONTROL_LINE_SIZE);
var buf = client.inbound.toString('binary', 0, client.options.maxControlLineSize);
if ((m = MSG.exec(buf)) !== null) {
client.payload = {
subj: m[1],
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "nats",
"version": "0.7.24",
"version": "0.7.26",
"description": "Node.js client for NATS, a lightweight, high-performance cloud native messaging system",
"keywords": [
"nats",
Expand Down

0 comments on commit b497fc3

Please sign in to comment.