Skip to content

Commit 8d7013d

Browse files
authored
NEW args for ws protocols (#5)
* NEW agrs for ws protocols * Fix revert entrypoint.sh * Added test for conn-ws-protocols
1 parent e0ca395 commit 8d7013d

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

lib/coreClient.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ CoreClient.BuildConnectionDict = function(options, ws) {
252252
if (options.connSsl) {
253253
ws_opts.rejectUnauthorized = false;
254254
}
255-
connectionDict.connection_details = ws(CoreClient.BuildWebSocketConnString(options), ['binary', 'AMQPWSB10', 'amqp'], ws_opts);
255+
connectionDict.connection_details = ws(CoreClient.BuildWebSocketConnString(options), options.WSProtocols, ws_opts);
256256
} else if(options.connUrls) {
257257
//failover
258258
connectionDict.connection_details = CoreClient.BuildFailoverHandler(options);

lib/optionsParser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ ConnectionOptions.prototype.ParseConnectionOptions = function(listArgs) {
161161
'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'},
162162
'conn-ssl-verify-peer-name': { default: false, describe: 'verifies connection url against server hostname', type: 'boolean'},
163163
'conn-max-frame-size': { default: undefined, describe: 'defines max frame size for connection', type: 'uint'},
164-
'conn-web-socket': { default: false, describe: 'use websocket as transport layer', type: ['boolean', 'string']},
164+
'conn-web-socket': { alias: 'conn-ws', default: false, describe: 'use websocket as transport layer', type: ['boolean', 'string']},
165+
'conn-web-socket-protocols': { alias: 'conn-ws-protocols', describe: 'protocol for ws connection', type: 'array', deafult: ['binary', 'AMQPWSB10', 'amqp']},
165166
'conn-property': { describe: 'Sets connection property map item'},
166167
})
167168
.strict()
@@ -184,6 +185,7 @@ ConnectionOptions.prototype.ParseConnectionOptions = function(listArgs) {
184185
this.frameSize = args['conn-max-frame-size'];
185186
this.websocket = castBoolProperty(args['conn-web-socket']);
186187
this.connSsl = castBoolProperty(args['conn-ssl']);
188+
this.WSProtocols = args['conn-ws-protocols'];
187189
this.connProperties = castMapProperty(args['conn-property']);
188190
};
189191

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cli-rhea",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "Client interface built on amqp/rhea lib",
55
"scripts": {
66
"test": "mocha test/**.spec.js",

test/cli-client.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ describe('Running bin cmd client', function() {
191191
it('Send message with reconnect enabled over websocket', function(done) {
192192
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);
193193
});
194+
it('Send message with reconnect enabled over websocket with specified protocol', function(done) {
195+
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);
196+
});
194197
it('Send with timeout', function(done) {
195198
verify(done, [example('../bin/sender-client.js', ['--address', 'timeout_queue', '--count', 5, '--timeout', 1])], 0);
196199
});

0 commit comments

Comments
 (0)