Task: Updated the tunnel models request and response in http tunnel client
This commit is contained in:
parent
573135545c
commit
34bb3bf730
14
client.js
14
client.js
@ -77,6 +77,7 @@ function initClient(options) {
|
|||||||
...defaultParams,
|
...defaultParams,
|
||||||
os: osInfo,
|
os: osInfo,
|
||||||
},
|
},
|
||||||
|
// reconnection: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const http_proxy = process.env.https_proxy || process.env.http_proxy;
|
const http_proxy = process.env.https_proxy || process.env.http_proxy;
|
||||||
@ -196,6 +197,19 @@ function initClient(options) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// reconnect manually
|
||||||
|
const tryReconnect = () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
socket.io.open((err) => {
|
||||||
|
if (err) {
|
||||||
|
tryReconnect();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 2000);
|
||||||
|
};
|
||||||
|
|
||||||
|
// socket.io.on("close", tryReconnect);
|
||||||
|
|
||||||
keepAlive();
|
keepAlive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
lib.js
4
lib.js
@ -7,12 +7,14 @@ class TunnelRequest extends stream.Readable {
|
|||||||
this._requestId = requestId;
|
this._requestId = requestId;
|
||||||
|
|
||||||
const onRequestPipe = (requestId, data) => {
|
const onRequestPipe = (requestId, data) => {
|
||||||
|
console.log("Res pipe size", data.length)
|
||||||
if (this._requestId === requestId) {
|
if (this._requestId === requestId) {
|
||||||
this.push(data);
|
this.push(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onRequestPipes = (requestId, data) => {
|
const onRequestPipes = (requestId, data) => {
|
||||||
|
console.log("Res pipes size", data.length)
|
||||||
if (this._requestId === requestId) {
|
if (this._requestId === requestId) {
|
||||||
data.forEach((chunk) => {
|
data.forEach((chunk) => {
|
||||||
this.push(chunk);
|
this.push(chunk);
|
||||||
@ -61,6 +63,7 @@ class TunnelResponse extends stream.Duplex {
|
|||||||
if (duplex) {
|
if (duplex) {
|
||||||
// for websocket request: bidirection
|
// for websocket request: bidirection
|
||||||
const onResponsePipe = (responseId, data) => {
|
const onResponsePipe = (responseId, data) => {
|
||||||
|
console.log("Res pipe: ", data.toString());
|
||||||
if (this._responseId === responseId) {
|
if (this._responseId === responseId) {
|
||||||
this.push(data);
|
this.push(data);
|
||||||
}
|
}
|
||||||
@ -105,6 +108,7 @@ class TunnelResponse extends stream.Duplex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_write(chunk, encoding, callback) {
|
_write(chunk, encoding, callback) {
|
||||||
|
console.log("Res Write Chunk: ", chunk.length);
|
||||||
this._socket.emit("response-pipe", this._responseId, chunk);
|
this._socket.emit("response-pipe", this._responseId, chunk);
|
||||||
this._socket.io.engine.once("drain", () => {
|
this._socket.io.engine.once("drain", () => {
|
||||||
callback();
|
callback();
|
||||||
|
Loading…
Reference in New Issue
Block a user