revert(signalr): restore negotiate + auto-transport (CDN now bypassed)
CI/CD / CI - API (dotnet build + engine sim) (push) Successful in 42s
CI/CD / CI - Web (tsc + next build) (push) Successful in 1m8s
CI/CD / Deploy - local stack (db + server + web) (push) Successful in 54s

api.bargevasat.ir is now CDN-bypassed (origin answers directly), so the
negotiate POST works again. Drop the WS-only skipNegotiation workaround and use
the standard negotiate flow, which auto-falls back WS → SSE → long-poll if a
WebSocket upgrade isn't available.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-15 18:07:58 +03:30
parent 21fd5c123e
commit 868bef0c56
+4 -9
View File
@@ -141,15 +141,10 @@ export class SignalrService implements OnlineService {
private async connect(): Promise<void> {
if (this.conn || !this.token) return;
const conn = new signalR.HubConnectionBuilder()
// Connect straight over WebSockets and SKIP the negotiate POST — some CDNs
// (WCDN) 404 the negotiate POST by method. The JWT rides the WS query
// string (server reads ?access_token for /hub). Real fix is to bypass the
// CDN for api.bargevasat.ir; this is a best-effort fallback.
.withUrl(`${SERVER}/hub/game`, {
accessTokenFactory: () => this.token ?? "",
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets,
})
// 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 ?? "" })
.withAutomaticReconnect()
.configureLogging(signalR.LogLevel.Warning)
.build();