{"record":{"id":"5367e8b69bfd3987","repo":"dotnet/aspnetcore","slug":"binary-protocols-over-xmlhttprequest-not-implement","errorCode":null,"errorMessage":"Binary protocols over XmlHttpRequest not implementing advanced features are not supported.","messagePattern":"Binary protocols over XmlHttpRequest not implementing advanced features are not supported\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr/src/LongPollingTransport.ts","lineNumber":57,"sourceCode":"        this._running = false;\n\n        this.onreceive = null;\n        this.onclose = null;\n    }\n\n    public async connect(url: string, transferFormat: TransferFormat): Promise<void> {\n        Arg.isRequired(url, \"url\");\n        Arg.isRequired(transferFormat, \"transferFormat\");\n        Arg.isIn(transferFormat, TransferFormat, \"transferFormat\");\n\n        this._url = url;\n\n        this._logger.log(LogLevel.Trace, \"(LongPolling transport) Connecting.\");\n\n        // Allow binary format on Node and Browsers that support binary content (indicated by the presence of responseType property)\n        if (transferFormat === TransferFormat.Binary &&\n            (typeof XMLHttpRequest !== \"undefined\" && typeof new XMLHttpRequest().responseType !== \"string\")) {\n            throw new Error(\"Binary protocols over XmlHttpRequest not implementing advanced features are not supported.\");\n        }\n\n        const [name, value] = getUserAgentHeader();\n        const headers = { [name]: value, ...this._options.headers };\n\n        const pollOptions: HttpRequest = {\n            abortSignal: this._pollAbort.signal,\n            headers,\n            timeout: 100000,\n            withCredentials: this._options.withCredentials,\n        };\n\n        if (transferFormat === TransferFormat.Binary) {\n            pollOptions.responseType = \"arraybuffer\";\n        }\n\n        // Make initial long polling request\n        // Server uses first long polling request to finish initializing connection and it returns without data","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/92f07e298d5c5a629385b8b0a32d7164b1b53906/src/SignalR/clients/ts/signalr/src/LongPollingTransport.ts#L39-L75","documentation":"Thrown by LongPollingTransport.connect() when a binary transfer format is requested but the environment's XMLHttpRequest does not support the responseType property (needed for binary long-polling). The long-polling transport cannot reliably receive binary data over a basic XHR, so it refuses to connect rather than corrupt frames.","triggerScenarios":"Selecting a binary hub protocol (e.g. MessagePack) together with LongPolling transport in an old browser/runtime where XMLHttpRequest lacks responseType support. Forced via withUrl(url, { transport: HttpTransportType.LongPolling }) combined with a binary protocol.","commonSituations":"Old browsers (legacy IE or embedded webviews); an environment shimming XMLHttpRequest incompletely; explicitly forcing LongPolling transport while using MessagePack.","solutions":["Allow the client to auto-select a transport (WebSockets/SSE handle binary) instead of forcing LongPolling.","Use the JSON (text) hub protocol instead of a binary one when LongPolling is required.","Upgrade or polyfill the runtime's XMLHttpRequest to support responseType.","If you must force LongPolling, ensure the protocol's transferFormat is Text."],"exampleFix":"// before\nbuilder.withUrl(hubUrl, { transport: HttpTransportType.LongPolling }).withHubProtocol(new MessagePackHubProtocol());\n// after - let transport auto-negotiate, or use JSON protocol\nbuilder.withUrl(hubUrl).withHubProtocol(new MessagePackHubProtocol());","handlingStrategy":"validation","validationCode":"const supportsBinaryXHR = typeof XMLHttpRequest === 'undefined' || typeof new XMLHttpRequest().responseType === 'string';\nif (useBinaryProtocol && forceLongPolling && supportsBinaryXHR) {\n  throw new Error('Binary + LongPolling not supported in this browser; use auto transport or JSON protocol');\n}","typeGuard":"function canBinaryLongPoll(): boolean {\n  return typeof XMLHttpRequest !== 'undefined' && typeof new XMLHttpRequest().responseType !== 'string';\n}","tryCatchPattern":null,"preventionTips":["Do not force LongPolling transport with a binary protocol in old browsers.","Let the client auto-negotiate transport when using MessagePack.","Use the JSON (text) protocol if LongPolling is mandatory."],"tags":["transport","long-polling","binary","browser","typescript"],"analyzedSha":"92f07e298d5c5a629385b8b0a32d7164b1b53906","analyzedAt":"2026-08-07T06:05:17.747Z","schemaVersion":2},"datasetVersion":"2026-08-07T15:17:06.553Z"}