Skip to content

Commit

Permalink
NEW args for ws protocols (#5)
Browse files Browse the repository at this point in the history
* NEW agrs for ws protocols

* Fix revert entrypoint.sh

* Added test for conn-ws-protocols
  • Loading branch information
kornys authored Jun 8, 2018
1 parent e0ca395 commit 8d7013d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/coreClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion lib/optionsParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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']);
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 3 additions & 0 deletions test/cli-client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 8d7013d

Please sign in to comment.