{"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/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/SignalR/clients/ts/signalr/src/HttpConnection.ts#L523-L559","documentation":"Thrown by the default branch of the transport-selection switch in HttpConnection._createTransport. The code only constructs transports for HttpTransportType.WebSockets, ServerSentEvents, and LongPolling; any other value falls through to `default` and is rejected. The library uses this to fail fast on an enum value it cannot map to a concrete Transport implementation.","triggerScenarios":"Calling HttpConnection (or HubConnection via withUrl options) with a `transport` option whose value is not one of the three valid HttpTransportType enum members — e.g. a raw numeric value outside 0/1/2/3, a coerced string, or a value from a mismatched/older version of the enum.","commonSituations":"Passing a number literal instead of the enum (`transport: 4`), importing HttpTransportType from a different signalr package version where enum values differ, or assigning a user-defined transport type constant that does not align with the shipped enum.","solutions":["Use the HttpTransportType enum constant (e.g. HttpTransportType.WebSockets) rather than a literal number.","If letting the client negotiate, omit the `transport` option so the server picks one.","Ensure the enum you reference is imported from the same @microsoft/signalr package version you ship.","If you need a custom transport, supply it via the `transport` factory hook rather than a new enum value."],"exampleFix":"// before\nnew HttpConnection(url, { transport: 4 });\n// after\nimport { HttpTransportType } from \"@microsoft/signalr\";\nnew HttpConnection(url, { transport: HttpTransportType.WebSockets });","handlingStrategy":"validation","validationCode":"import { HttpTransportType } from \"@microsoft/signalr\";\nconst valid = new Set<number>([\n  HttpTransportType.WebSockets,\n  HttpTransportType.ServerSentEvents,\n  HttpTransportType.LongPolling,\n]);\nfunction assertTransport(t: number): void {\n  if (!valid.has(t)) throw new TypeError(`Invalid HttpTransportType: ${t}`);\n}","typeGuard":"function isHttpTransportType(t: unknown): t is HttpTransportType {\n  return typeof t === \"number\" && t >= 0 && t <= 3;\n}","tryCatchPattern":"try {\n  const conn = new HttpConnection(url, { transport });\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith(\"Unknown transport:\")) {\n    // fall back to negotiated transport\n  } else throw e;\n}","preventionTips":["Always reference HttpTransportType enum members, never raw numbers.","Omit the transport option to let negotiation choose.","Import the enum from the same package version you ship."],"tags":["transport","configuration","enum","typescript"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}