From fefa9e2e3a2b9d071b53df0b8b6b86f34ed36500 Mon Sep 17 00:00:00 2001 From: "soroush.asadi" Date: Mon, 15 Jun 2026 22:37:04 +0330 Subject: [PATCH] fix(signalr): force Long-Polling transport so the hub connects through nginx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Server logs showed REST working but ZERO hub activity — the SignalR WebSocket upgrade isn't getting through the nginx/CDN stack and auto-fallback wasn't recovering, so StartMatchmaking never reached the server (matchmaking spun forever). Force the HttpTransportType.LongPolling transport — plain HTTP that already works (same path as REST); SignalR holds the poll open so it's effectively real-time for a turn-based game. Revertable once the api block proxies WS upgrades. Co-Authored-By: Claude Opus 4.8 --- src/lib/online/signalr-service.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib/online/signalr-service.ts b/src/lib/online/signalr-service.ts index 88c78cb..2b06e55 100644 --- a/src/lib/online/signalr-service.ts +++ b/src/lib/online/signalr-service.ts @@ -141,10 +141,15 @@ export class SignalrService implements OnlineService { private async connect(): Promise { if (this.conn || !this.token) return; const conn = new signalR.HubConnectionBuilder() - // Normal negotiate flow → auto-picks the best transport (WS, else SSE / - // long-poll). Requires api.bargevasat.ir to BYPASS the CDN (WCDN 404s the - // negotiate POST); with the CDN bypassed this is the most robust path. - .withUrl(`${SERVER}/hub/game`, { accessTokenFactory: () => this.token ?? "" }) + // Force Long-Polling: plain HTTP POST/GET that works through the existing + // nginx/CDN (same path REST already uses) without needing WebSocket-upgrade + // headers. SignalR holds the poll open, so for a turn-based game it's + // effectively real-time. Switch back to default transports once the api + // server block proxies WS upgrades. + .withUrl(`${SERVER}/hub/game`, { + accessTokenFactory: () => this.token ?? "", + transport: signalR.HttpTransportType.LongPolling, + }) .withAutomaticReconnect() .configureLogging(signalR.LogLevel.Warning) .build();