diff --git a/lib/coreClient.js b/lib/coreClient.js index 7eae0f1..57244dc 100644 --- a/lib/coreClient.js +++ b/lib/coreClient.js @@ -252,7 +252,7 @@ CoreClient.BuildConnectionDict = function(options, ws) { if (options.connSsl) { ws_opts.rejectUnauthorized = false; } - connectionDict.connection_details = ws(CoreClient.BuildWebSocketConnString(options), ['binary', 'AMQPWSB10', 'amqp'], ws_opts); + connectionDict.connection_details = ws(CoreClient.BuildWebSocketConnString(options), options.WSProtocols, ws_opts); } else if(options.connUrls) { //failover connectionDict.connection_details = CoreClient.BuildFailoverHandler(options); diff --git a/lib/optionsParser.js b/lib/optionsParser.js index f784985..76ef853 100644 --- a/lib/optionsParser.js +++ b/lib/optionsParser.js @@ -161,7 +161,8 @@ ConnectionOptions.prototype.ParseConnectionOptions = function(listArgs) { 'conn-ssl-verify-peer': { default: false, describe: 'verifies server certificate, conn-ssl-certificate and trusted db path needs to be specified (PEM format)', type: 'boolean'}, 'conn-ssl-verify-peer-name': { default: false, describe: 'verifies connection url against server hostname', type: 'boolean'}, 'conn-max-frame-size': { default: undefined, describe: 'defines max frame size for connection', type: 'uint'}, - 'conn-web-socket': { default: false, describe: 'use websocket as transport layer', type: ['boolean', 'string']}, + 'conn-web-socket': { alias: 'conn-ws', default: false, describe: 'use websocket as transport layer', type: ['boolean', 'string']}, + 'conn-web-socket-protocols': { alias: 'conn-ws-protocols', describe: 'protocol for ws connection', type: 'array', deafult: ['binary', 'AMQPWSB10', 'amqp']}, 'conn-property': { describe: 'Sets connection property map item'}, }) .strict() @@ -184,6 +185,7 @@ ConnectionOptions.prototype.ParseConnectionOptions = function(listArgs) { this.frameSize = args['conn-max-frame-size']; this.websocket = castBoolProperty(args['conn-web-socket']); this.connSsl = castBoolProperty(args['conn-ssl']); + this.WSProtocols = args['conn-ws-protocols']; this.connProperties = castMapProperty(args['conn-property']); }; diff --git a/package.json b/package.json index 846d342..3492a45 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cli-rhea", - "version": "2.0.1", + "version": "2.0.2", "description": "Client interface built on amqp/rhea lib", "scripts": { "test": "mocha test/**.spec.js", diff --git a/test/cli-client.spec.js b/test/cli-client.spec.js index c422c03..3ab6177 100644 --- a/test/cli-client.spec.js +++ b/test/cli-client.spec.js @@ -191,6 +191,9 @@ describe('Running bin cmd client', function() { it('Send message with reconnect enabled over websocket', function(done) { verify(done, [example('../bin/sender-client.js', ['--address', 'reconnect_queue', '--count', 5, '--conn-reconnect', '--conn-web-socket', '--conn-reconnect-limit', 10, '--conn-reconnect-interval', '1', '--conn-heartbeat', '1'])], 0); }); + it('Send message with reconnect enabled over websocket with specified protocol', function(done) { + verify(done, [example('../bin/sender-client.js', ['--address', 'reconnect_queue', '--count', 5, '--conn-reconnect', '--conn-web-socket', '--conn-reconnect-limit', 10, '--conn-reconnect-interval', '1', '--conn-heartbeat', '1', '--conn-ws-protocols', 'binary', 'amqp'])], 0); + }); it('Send with timeout', function(done) { verify(done, [example('../bin/sender-client.js', ['--address', 'timeout_queue', '--count', 5, '--timeout', 1])], 0); });