{"record":{"id":"1d39ed5b4cc9bd5e","repo":"dotnet/aspnetcore","slug":"unknown-transport-transport","errorCode":null,"errorMessage":"Unknown transport: ${transport}.","messagePattern":"Unknown transport: (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr/src/HttpConnection.ts","lineNumber":541,"sourceCode":"    }\n\n    private _constructTransport(transport: HttpTransportType): ITransport {\n        switch (transport) {\n            case HttpTransportType.WebSockets:\n                if (!this._options.WebSocket) {\n                    throw new Error(\"'WebSocket' is not supported in your environment.\");\n                }\n                return new WebSocketTransport(this._httpClient, this._accessTokenFactory, this._logger, this._options.logMessageContent!,\n                    this._options.WebSocket, this._options.headers || {});\n            case HttpTransportType.ServerSentEvents:\n                if (!this._options.EventSource) {\n                    throw new Error(\"'EventSource' is not supported in your environment.\");\n                }\n                return new ServerSentEventsTransport(this._httpClient, this._httpClient._accessToken, this._logger, this._options);\n            case HttpTransportType.LongPolling:\n                return new LongPollingTransport(this._httpClient, this._logger, this._options);\n            default:\n                throw new Error(`Unknown transport: ${transport}.`);\n        }\n    }\n\n    private _startTransport(url: string, transferFormat: TransferFormat): Promise<void> {\n        this.transport!.onreceive = this.onreceive;\n        if (this.features.reconnect) {\n            this.transport!.onclose = async (e) => {\n                let callStop = false;\n                if (this.features.reconnect) {\n                    try {\n                        this.features.disconnected();\n                        await this.transport!.connect(url, transferFormat);\n                        await this.features.resend();\n                    } catch {\n                        callStop = true;\n                    }\n                } else {\n                    this._stopConnection(e);","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/SignalR/clients/ts/signalr/src/HttpConnection.ts#L523-L559","documentation":"Thrown at HttpConnection.ts:541 in the default branch of _constructTransport's switch. The switch handles WebSockets, ServerSentEvents, and LongPolling; any other numeric value (or a corrupted HttpTransportType) falls through to default. In practice this should be unreachable with the published enum, but it guards against bad input.","triggerScenarios":"Passing a numeric transport value outside 1/2/4 (e.g. 3, 7, 0) via a cast or untyped JS; an enum that was renamed/reordered across versions; constructing a custom transport value with bitwise math that produces an invalid combo (e.g. WebSockets | ServerSentEvents = 3 is not a single transport).","commonSituations":"Calling `_constructTransport` directly in tests with a fabricated number; combining transport flags where only a single concrete transport is expected; a future version of the enum introducing a new value the old client doesn't handle.","solutions":["Use a single concrete HttpTransportType value (WebSockets, ServerSentEvents, LongPolling) rather than a bitwise combination.","If you need 'auto', omit the transport option entirely and let negotiation select.","Ensure you are not passing a string like \"WebSockets\" — pass the enum member."],"exampleFix":"// before (wrong: bitwise combo)\nwithUrl(url, { transport: HttpTransportType.WebSockets | HttpTransportType.LongPolling })\n\n// after (auto-select)\nwithUrl(url)\n// or explicit single transport\nwithUrl(url, { transport: HttpTransportType.WebSockets })","handlingStrategy":"type-guard","validationCode":"const VALID = [HttpTransportType.WebSockets, HttpTransportType.ServerSentEvents, HttpTransportType.LongPolling];\nfunction assertSingleTransport(t) {\n  if (!VALID.includes(t)) throw new Error(`Invalid transport: ${t}. Use one of ${VALID.join(', ')}`);\n}\nassertSingleTransport(options.transport);","typeGuard":"function isSingleValidTransport(t: unknown): t is HttpTransportType {\n  return t === HttpTransportType.WebSockets || t === HttpTransportType.ServerSentEvents || t === HttpTransportType.LongPolling;\n}","tryCatchPattern":"try { await conn.start(transferFormat); }\ncatch (e) {\n  if (/Unknown transport/.test(String(e))) {\n    delete options.transport; // let negotiation auto-select\n    return new HttpConnection(url, options).start(transferFormat);\n  }\n  throw e;\n}","preventionTips":["Always use the HttpTransportType enum, never magic numbers.","Never combine transport flags with bitwise OR for the 'transport' option.","Omit the transport option entirely if you want auto-selection."],"tags":["transport","enum","validation","internal"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}