{"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":"exception","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/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/SignalR/clients/ts/signalr/src/LongPollingTransport.ts#L39-L75","documentation":"Thrown by LongPollingTransport.connect when binary transfer format is requested but the environment's XMLHttpRequest lacks advanced features — specifically when `new XMLHttpRequest().responseType` is not a string property (i.e. the browser/XHR implementation is too old to support binary response types). LongPolling cannot receive binary frames without XHR responseType support, so the connect is refused up front.","triggerScenarios":"Configuring a connection that negotiates LongPolling as the transport with a binary hub protocol (e.g. MessagePack), in a browser/runtime where XMLHttpRequest does not implement responseType. The check fires only when transferFormat === Binary.","commonSituations":"Legacy browser (old IE, embedded WebViews, or a polyfilled XHR that omits responseType), or running in an unusual JS runtime where the global XMLHttpRequest is a partial shim.","solutions":["Use a text-based hub protocol (JSON) when LongPolling is the only available transport on legacy XHR.","Upgrade the runtime/browser to one with a complete XMLHttpRequest implementation.","Prefer the WebSockets or ServerSentEvents transport which do not rely on XHR responseType."],"exampleFix":"// before - forcing binary over legacy long-polling\nnew HubConnectionBuilder()\n  .withUrl(url, { transport: HttpTransportType.LongPolling })\n  .withHubProtocol(new MessagePackHubProtocol())\n  .build();\n// after - keep JSON for long polling\nnew HubConnectionBuilder()\n  .withUrl(url, { transport: HttpTransportType.LongPolling })\n  .build(); // default JSON protocol","handlingStrategy":"validation","validationCode":"function supportsBinaryLongPolling(): boolean {\n  return typeof XMLHttpRequest !== \"undefined\"\n    && typeof new XMLHttpRequest().responseType !== \"string\";\n}","typeGuard":"function xhrSupportsBinary(): boolean {\n  try {\n    return typeof new XMLHttpRequest().responseType !== \"string\";\n  } catch { return false; }\n}","tryCatchPattern":null,"preventionTips":["Prefer WebSockets/SSE for binary protocols.","Use the JSON protocol when LongPolling is the only transport.","Upgrade legacy browsers/WebViews that ship a partial XHR."],"tags":["transport","long-polling","binary","browser","legacy"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}