fix(core): update

This commit is contained in:
Philipp Kunz 2022-07-30 19:28:23 +02:00
parent 0fdd17b430
commit d7765fb5dc
2 changed files with 34 additions and 30 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/smartproxy',
version: '3.0.20',
version: '3.0.21',
description: 'a proxy for handling high workloads of proxying'
}

View File

@ -234,8 +234,11 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer });
wss.on('connection', (ws: plugins.wsDefault) => {
console.log('got connection for wsc');
const wscConnected = plugins.smartpromise.defer();
let wscConnectedDeferred: plugins.smartpromise.Deferred<plugins.wsDefault>;
ws.on('message', async (message) => {
if (!wscConnectedDeferred) {
wscConnectedDeferred = plugins.smartpromise.defer();
const wsc = new plugins.wsDefault(this.router.routeWs(ws), {
headers: {
Host: ws.url,
@ -243,13 +246,11 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
});
wsc.on('open', () => {
wscConnected.resolve();
wscConnectedDeferred.resolve(wsc);
});
ws.on('message', async (message) => {
await wscConnected.promise;
}
const wsc = await wscConnectedDeferred.promise;
wsc.emit('message', message);
});
wsc.on('message', (message) => {
ws.emit('message', message);
});
@ -265,10 +266,13 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
ws.on('close', (message) => {
cleanUp();
});
wsc.on('close', (message) => {
cleanUp();
});
});
});
this.httpsServer.keepAliveTimeout = 61000;
this.httpsServer.headersTimeout = 65000;