Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
632015a7bd | |||
972ee2af54 | |||
9b1ff5eed8 | |||
0739d1093a |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartproxy",
|
"name": "@pushrocks/smartproxy",
|
||||||
"version": "3.0.56",
|
"version": "3.0.58",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a proxy for handling high workloads of proxying",
|
"description": "a proxy for handling high workloads of proxying",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/smartproxy',
|
name: '@pushrocks/smartproxy',
|
||||||
version: '3.0.56',
|
version: '3.0.58',
|
||||||
description: 'a proxy for handling high workloads of proxying'
|
description: 'a proxy for handling high workloads of proxying'
|
||||||
}
|
}
|
||||||
|
@ -250,28 +250,44 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
|||||||
console.log(`wss proxy: got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`);
|
console.log(`wss proxy: got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`);
|
||||||
|
|
||||||
let wsOutgoing: plugins.wsDefault;
|
let wsOutgoing: plugins.wsDefault;
|
||||||
|
|
||||||
|
const outGoingDeferred = plugins.smartpromise.defer();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
wsOutgoing = new plugins.wsDefault(`ws://${this.router.routeReq(reqArg).destinationIp}:${this.router.routeReq(reqArg).destinationPort}${reqArg.url}`);
|
wsOutgoing = new plugins.wsDefault(`ws://${this.router.routeReq(reqArg).destinationIp}:${this.router.routeReq(reqArg).destinationPort}${reqArg.url}`);
|
||||||
console.log('wss proxy: initiated outgoing proxy')
|
console.log('wss proxy: initiated outgoing proxy');
|
||||||
|
wsOutgoing.on('open', async () => {
|
||||||
|
outGoingDeferred.resolve();
|
||||||
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
wsIncoming.terminate();
|
wsIncoming.terminate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wsIncoming.on("message", (message, isBinary) => {
|
wsIncoming.on("message", async (message, isBinary) => {
|
||||||
|
await outGoingDeferred.promise;
|
||||||
// console.log("client to upstream", message);
|
// console.log("client to upstream", message);
|
||||||
wsOutgoing.send(message, { binary: isBinary });
|
wsOutgoing.send(message, { binary: isBinary });
|
||||||
});
|
});
|
||||||
|
|
||||||
wsOutgoing.on("message", (message, isBinary) => {
|
wsOutgoing.on("message", async (message, isBinary) => {
|
||||||
// console.log("upstream to client", message);
|
// console.log("upstream to client", message);
|
||||||
wsIncoming.send(message, { binary: isBinary });
|
wsIncoming.send(message, { binary: isBinary });
|
||||||
});
|
});
|
||||||
wsIncoming.on("error", () => wsOutgoing.terminate());
|
const terminateWsOutgoing = () => {
|
||||||
wsOutgoing.on("error", () => wsIncoming.terminate());
|
wsOutgoing.terminate();
|
||||||
wsIncoming.on("close", () => wsOutgoing.terminate());
|
console.log('terminated outgoing ws.');
|
||||||
wsOutgoing.on("close", () => wsIncoming.terminate());
|
}
|
||||||
|
wsIncoming.on("error", () => terminateWsOutgoing());
|
||||||
|
wsIncoming.on("close", () => terminateWsOutgoing());
|
||||||
|
|
||||||
|
const terminateWsIncoming = () => {
|
||||||
|
wsIncoming.terminate();
|
||||||
|
console.log('terminated incoming ws.');
|
||||||
|
}
|
||||||
|
wsOutgoing.on("error", () => terminateWsIncoming());
|
||||||
|
wsOutgoing.on("close", () => terminateWsIncoming());
|
||||||
|
|
||||||
});
|
});
|
||||||
this.httpsServer.keepAliveTimeout = 600 * 1000;
|
this.httpsServer.keepAliveTimeout = 600 * 1000;
|
||||||
|
Reference in New Issue
Block a user