From 0c7a4919586e0d95581754363514833dc7d448d4 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Sun, 26 Jul 2020 17:34:36 +0530 Subject: [PATCH 1/2] Update active version --- distributor/web/{active-2020-07-25 => active-2020-07-26} | 0 distributor/web/info.txt | 6 +++--- subscriber/src/subscriber/subscriber.bal | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename distributor/web/{active-2020-07-25 => active-2020-07-26} (100%) diff --git a/distributor/web/active-2020-07-25 b/distributor/web/active-2020-07-26 similarity index 100% rename from distributor/web/active-2020-07-25 rename to distributor/web/active-2020-07-26 diff --git a/distributor/web/info.txt b/distributor/web/info.txt index 46d4394..7bba3ec 100644 --- a/distributor/web/info.txt +++ b/distributor/web/info.txt @@ -2,15 +2,15 @@ ****** IMPORTANT ******* ** -** The latest version of the subscriber JAR is subscriber-20200725.jar +** The latest version of the subscriber JAR is subscriber-20200726.jar ** -** Available at https://github.com/ECLK/Results-Dist/releases/tag/v2020-07-25 +** Available at https://github.com/ECLK/Results-Dist/releases/tag/v2020-07-26 ** ****** IMPORTANT ******* Run it as follows: -java -jar subscriber-20200725.jar [options] +java -jar subscriber-20200726.jar [options] where options are: -username=name my username for authentication diff --git a/subscriber/src/subscriber/subscriber.bal b/subscriber/src/subscriber/subscriber.bal index 4552e94..0aa6374 100644 --- a/subscriber/src/subscriber/subscriber.bal +++ b/subscriber/src/subscriber/subscriber.bal @@ -8,7 +8,7 @@ import maryamzi/sound; const WANT_IMAGE = "image=true"; const WANT_AWAIT_RESULTS = "await=true"; -const MY_VERSION = "2020-07-25"; +const MY_VERSION = "2020-07-26"; const UNDERSOCRE = "_"; const COLON = ":"; From a2729ce769eb000e93f88710ec1981b43b2e8f77 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Sun, 26 Jul 2020 20:04:37 +0530 Subject: [PATCH 2/2] Intro retry config for client and add the onClose resource for callback services --- subscriber/src/subscriber/subscriber.bal | 27 +++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/subscriber/src/subscriber/subscriber.bal b/subscriber/src/subscriber/subscriber.bal index 8b117e7..82a89f7 100644 --- a/subscriber/src/subscriber/subscriber.bal +++ b/subscriber/src/subscriber/subscriber.bal @@ -129,7 +129,16 @@ public function main (string? username = (), // my username headers[http:AUTH_HEADER] = string `Basic ${token}`; } - http:WebSocketClient wsClientEp = new (wsUrl, config = {callbackService: callbackService, customHeaders: headers}); + http:WebSocketClient wsClientEp = new (wsUrl, config = { + callbackService: callbackService, + customHeaders: headers, + retryConfig: { + intervalInMillis: 3000, + maxCount: 10, + backOffFactor: 1.5, + maxWaitIntervalInMillis: 20000 + } + }); if wsClientEp.isOpen() { io:println( @@ -151,6 +160,10 @@ service resultDataOnlyClientService = @http:WebSocketServiceConfig {} service { resource function onError(http:WebSocketClient conn, error err) { log:printError("Error occurred", err); } + + resource function onClose(http:WebSocketClient wsEp, int statusCode, string reason) { + log:printInfo(string `Connection closed: statusCode: ${statusCode}, reason: ${reason}`); + } }; service awaitAndResultDataClientService = @http:WebSocketServiceConfig {} service { @@ -174,6 +187,10 @@ service awaitAndResultDataClientService = @http:WebSocketServiceConfig {} servic resource function onError(http:WebSocketClient conn, error err) { log:printError("Error occurred", err); } + + resource function onClose(http:WebSocketClient wsEp, int statusCode, string reason) { + log:printInfo(string `Connection closed: statusCode: ${statusCode}, reason: ${reason}`); + } }; service imageAndResultDataClientService = @http:WebSocketServiceConfig {} service { @@ -199,6 +216,10 @@ service imageAndResultDataClientService = @http:WebSocketServiceConfig {} servic resource function onError(http:WebSocketClient conn, error err) { log:printError("Error occurred", err); } + + resource function onClose(http:WebSocketClient wsEp, int statusCode, string reason) { + log:printInfo(string `Connection closed: statusCode: ${statusCode}, reason: ${reason}`); + } }; @@ -232,6 +253,10 @@ service allClientService = @http:WebSocketServiceConfig {} service { resource function onError(http:WebSocketClient conn, error err) { log:printError("Error occurred", err); } + + resource function onClose(http:WebSocketClient wsEp, int statusCode, string reason) { + log:printInfo(string `Connection closed: statusCode: ${statusCode}, reason: ${reason}`); + } }; function notifyAwait() {