fix(core): update
This commit is contained in:
parent
0fdd17b430
commit
d7765fb5dc
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/smartproxy',
|
name: '@pushrocks/smartproxy',
|
||||||
version: '3.0.20',
|
version: '3.0.21',
|
||||||
description: 'a proxy for handling high workloads of proxying'
|
description: 'a proxy for handling high workloads of proxying'
|
||||||
}
|
}
|
||||||
|
@ -234,40 +234,44 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
|||||||
const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer });
|
const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer });
|
||||||
wss.on('connection', (ws: plugins.wsDefault) => {
|
wss.on('connection', (ws: plugins.wsDefault) => {
|
||||||
console.log('got connection for wsc');
|
console.log('got connection for wsc');
|
||||||
const wscConnected = plugins.smartpromise.defer();
|
let wscConnectedDeferred: plugins.smartpromise.Deferred<plugins.wsDefault>;
|
||||||
|
|
||||||
const wsc = new plugins.wsDefault(this.router.routeWs(ws), {
|
|
||||||
headers: {
|
|
||||||
Host: ws.url,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
wsc.on('open', () => {
|
|
||||||
wscConnected.resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
ws.on('message', async (message) => {
|
ws.on('message', async (message) => {
|
||||||
await wscConnected.promise;
|
if (!wscConnectedDeferred) {
|
||||||
|
wscConnectedDeferred = plugins.smartpromise.defer();
|
||||||
|
const wsc = new plugins.wsDefault(this.router.routeWs(ws), {
|
||||||
|
headers: {
|
||||||
|
Host: ws.url,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
wsc.on('open', () => {
|
||||||
|
wscConnectedDeferred.resolve(wsc);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const wsc = await wscConnectedDeferred.promise;
|
||||||
wsc.emit('message', message);
|
wsc.emit('message', message);
|
||||||
});
|
wsc.on('message', (message) => {
|
||||||
wsc.on('message', (message) => {
|
ws.emit('message', message);
|
||||||
ws.emit('message', message);
|
});
|
||||||
});
|
|
||||||
|
// handle closing
|
||||||
|
const cleanUp = () => {
|
||||||
|
ws.close();
|
||||||
|
ws.terminate();
|
||||||
|
wsc.close();
|
||||||
|
wsc.terminate();
|
||||||
|
};
|
||||||
|
|
||||||
|
ws.on('close', (message) => {
|
||||||
|
cleanUp();
|
||||||
|
});
|
||||||
|
|
||||||
// handle closing
|
wsc.on('close', (message) => {
|
||||||
const cleanUp = () => {
|
cleanUp();
|
||||||
ws.close();
|
});
|
||||||
ws.terminate();
|
|
||||||
wsc.close();
|
|
||||||
wsc.terminate();
|
|
||||||
};
|
|
||||||
|
|
||||||
ws.on('close', (message) => {
|
|
||||||
cleanUp();
|
|
||||||
});
|
|
||||||
wsc.on('close', (message) => {
|
|
||||||
cleanUp();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
this.httpsServer.keepAliveTimeout = 61000;
|
this.httpsServer.keepAliveTimeout = 61000;
|
||||||
this.httpsServer.headersTimeout = 65000;
|
this.httpsServer.headersTimeout = 65000;
|
||||||
|
Loading…
Reference in New Issue
Block a user