Task: Add keep connection setting when start the client and auto closed old connection if duplicated the host for http tunnel client
This commit is contained in:
parent
4d56730241
commit
06d5f0a5bd
18
client.js
18
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 <string>", "setting suffix for client name")
|
||||
.option("-a, --access <string>", "setting access type (FREE)", TOKEN_FREE)
|
||||
.option("-p, --profile <string>", "setting profile name", PROFILE_DEFAULT)
|
||||
.option("-s, --suffix <string>", "suffix for client name")
|
||||
.option(
|
||||
"-k, --keep_connection <boolean>",
|
||||
"keep connection for client and old connection will be closed",
|
||||
true
|
||||
)
|
||||
.option("-a, --access <string>", "access type (FREE)", TOKEN_FREE)
|
||||
.option("-p, --profile <string>", "profile name", PROFILE_DEFAULT)
|
||||
.option("-h, --host <string>", "local host value", "localhost")
|
||||
.option("-o, --origin <string>", "change request origin")
|
||||
.action((port, options) => {
|
||||
|
@ -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": {
|
||||
|
Loading…
Reference in New Issue
Block a user