diff --git a/client.js b/client.js index e6b30c4..277d721 100644 --- a/client.js +++ b/client.js @@ -53,6 +53,7 @@ function initClient(options) { clientEndpoint: clientEndpoint, serverUrl: serverUrl, access: options.access, + keep_connection: options.keep_connection || true, }; const initParams = { @@ -97,6 +98,12 @@ function initClient(options) { console.log(`${clientLogPrefix} disconnected: ${reason}!`); }); + socket.on("disconnect_exit", (reason) => { + console.log(`${clientLogPrefix} disconnected and exited ${reason}!`); + socket.disconnect(); + process.exit(1); + }); + socket.on("request", (requestId, request) => { const isWebSocket = request.headers.upgrade === "websocket"; console.log(`${isWebSocket ? "WS" : request.method}: `, request.path); @@ -278,9 +285,14 @@ program } return port; }) - .option("-s, --suffix ", "setting suffix for client name") - .option("-a, --access ", "setting access type (FREE)", TOKEN_FREE) - .option("-p, --profile ", "setting profile name", PROFILE_DEFAULT) + .option("-s, --suffix ", "suffix for client name") + .option( + "-k, --keep_connection ", + "keep connection for client and old connection will be closed", + true + ) + .option("-a, --access ", "access type (FREE)", TOKEN_FREE) + .option("-p, --profile ", "profile name", PROFILE_DEFAULT) .option("-h, --host ", "local host value", "localhost") .option("-o, --origin ", "change request origin") .action((port, options) => { diff --git a/package.json b/package.json index c17c163..136e8f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cubetiq/hlt", - "version": "0.0.4", + "version": "0.0.5", "description": "A lightweight http tunnel client using nodejs and socket.io client", "main": "client.js", "bin": {