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> {
|
private async connect(): Promise<void> {
|
||||||
if (this.conn || !this.token) return;
|
if (this.conn || !this.token) return;
|
||||||
const conn = new signalR.HubConnectionBuilder()
|
const conn = new signalR.HubConnectionBuilder()
|
||||||
// Connect straight over WebSockets and SKIP the negotiate POST — some CDNs
|
// Normal negotiate flow → auto-picks the best transport (WS, else SSE /
|
||||||
// (WCDN) 404 the negotiate POST by method. The JWT rides the WS query
|
// long-poll). Requires api.bargevasat.ir to BYPASS the CDN (WCDN 404s the
|
||||||
// string (server reads ?access_token for /hub). Real fix is to bypass the
|
// negotiate POST); with the CDN bypassed this is the most robust path.
|
||||||
// CDN for api.bargevasat.ir; this is a best-effort fallback.
|
.withUrl(`${SERVER}/hub/game`, { accessTokenFactory: () => this.token ?? "" })
|
||||||
.withUrl(`${SERVER}/hub/game`, {
|
|
||||||
accessTokenFactory: () => this.token ?? "",
|
|
||||||
skipNegotiation: true,
|
|
||||||
transport: signalR.HttpTransportType.WebSockets,
|
|
||||||
})
|
|
||||||
.withAutomaticReconnect()
|
.withAutomaticReconnect()
|
||||||
.configureLogging(signalR.LogLevel.Warning)
|
.configureLogging(signalR.LogLevel.Warning)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
Reference in New Issue
Block a user