From 7d93b484bd77a5d8a6e94d1601c4b6fb5a55556f Mon Sep 17 00:00:00 2001 From: evanpelle Date: Tue, 17 Jun 2025 09:46:13 -0700 Subject: [PATCH] fix websocket error (#1208) ## Description: When updating tunnel creation, the port was switched to 3000, so it pointed to master, it should be pointed to port 80 (nginx) so that nginx can route requests to the appropriate worker. Also fixed some ws handling. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: DISCORD_USERNAME --- src/server/GameServer.ts | 6 +++--- src/server/Server.ts | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/server/GameServer.ts b/src/server/GameServer.ts index f08dcc5e8..3b538cb32 100644 --- a/src/server/GameServer.ts +++ b/src/server/GameServer.ts @@ -172,7 +172,7 @@ export class GameServer { client.isDisconnected = existing.isDisconnected; client.lastPing = existing.lastPing; - existing.ws.removeAllListeners("message"); + existing.ws.removeAllListeners(); this.activeClients = this.activeClients.filter((c) => c !== existing); } @@ -183,6 +183,8 @@ export class GameServer { this.allClients.set(client.clientID, client); client.ws.removeAllListeners("message"); + client.ws.removeAllListeners("close"); + client.ws.removeAllListeners("error"); client.ws.on( "message", gatekeeper.wsHandler(client.ip, async (message: string) => { @@ -240,7 +242,6 @@ export class GameServer { } }), ); - client.ws.removeAllListeners("close"); client.ws.on("close", () => { this.log.info("client disconnected", { clientID: client.clientID, @@ -250,7 +251,6 @@ export class GameServer { (c) => c.clientID !== client.clientID, ); }); - client.ws.removeAllListeners("error"); client.ws.on("error", (error: Error) => { if ((error as any).code === "WS_ERR_UNEXPECTED_RSV_1") { client.ws.close(1002, "WS_ERR_UNEXPECTED_RSV_1"); diff --git a/src/server/Server.ts b/src/server/Server.ts index 8486f974a..f47fe2fc1 100644 --- a/src/server/Server.ts +++ b/src/server/Server.ts @@ -42,7 +42,8 @@ async function setupTunnels() { const domainToService = new Map().set( config.subdomain(), - `http://localhost:3000`, + // TODO: change to 3000 when we have a proper tunnel setup. + `http://localhost:80`, ); for (let i = 0; i < config.numWorkers(); i++) {