revert(signalr): restore negotiate + auto-transport (CDN now bypassed)
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user