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,
|
||||
os: osInfo,
|
||||
},
|
||||
// reconnection: true,
|
||||
};
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
4
lib.js
4
lib.js
@ -7,12 +7,14 @@ class TunnelRequest extends stream.Readable {
|
||||
this._requestId = requestId;
|
||||
|
||||
const onRequestPipe = (requestId, data) => {
|
||||
console.log("Res pipe size", data.length)
|
||||
if (this._requestId === requestId) {
|
||||
this.push(data);
|
||||
}
|
||||
};
|
||||
|
||||
const onRequestPipes = (requestId, data) => {
|
||||
console.log("Res pipes size", data.length)
|
||||
if (this._requestId === requestId) {
|
||||
data.forEach((chunk) => {
|
||||
this.push(chunk);
|
||||
@ -61,6 +63,7 @@ class TunnelResponse extends stream.Duplex {
|
||||
if (duplex) {
|
||||
// for websocket request: bidirection
|
||||
const onResponsePipe = (responseId, data) => {
|
||||
console.log("Res pipe: ", data.toString());
|
||||
if (this._responseId === responseId) {
|
||||
this.push(data);
|
||||
}
|
||||
@ -105,6 +108,7 @@ class TunnelResponse extends stream.Duplex {
|
||||
}
|
||||
|
||||
_write(chunk, encoding, callback) {
|
||||
console.log("Res Write Chunk: ", chunk.length);
|
||||
this._socket.emit("response-pipe", this._responseId, chunk);
|
||||
this._socket.io.engine.once("drain", () => {
|
||||
callback();
|
||||
|
Loading…
Reference in New Issue
Block a user