dotnet/aspnetcore · error · Error
Unknown transport: .
Error message
Unknown transport: ${transport}. What it means
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.
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.
Example fix
// before
new HttpConnection(url, { transport: 4 });
// after
import { HttpTransportType } from "@microsoft/signalr";
new HttpConnection(url, { transport: HttpTransportType.WebSockets }); Defensive patterns
Strategy: validation
Validate before calling
import { HttpTransportType } from "@microsoft/signalr";
const valid = new Set<number>([
HttpTransportType.WebSockets,
HttpTransportType.ServerSentEvents,
HttpTransportType.LongPolling,
]);
function assertTransport(t: number): void {
if (!valid.has(t)) throw new TypeError(`Invalid HttpTransportType: ${t}`);
} Type guard
function isHttpTransportType(t: unknown): t is HttpTransportType {
return typeof t === "number" && t >= 0 && t <= 3;
} Try / catch
try {
const conn = new HttpConnection(url, { transport });
} catch (e) {
if (e instanceof Error && e.message.startsWith("Unknown transport:")) {
// fall back to negotiated transport
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unknown value: .
- 'EventSource' is not supported in your environment.
- Expected data to be of type
- Message is incomplete.
- negotiateResponse.error
AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11).
Data as JSON: /api/errors/1d39ed5b4cc9bd5e.
Report an issue: GitHub.
Appendix: source
Thrown at src/SignalR/clients/ts/signalr/src/HttpConnection.ts:541
}
private _constructTransport(transport: HttpTransportType): ITransport {
switch (transport) {
case HttpTransportType.WebSockets:
if (!this._options.WebSocket) {
throw new Error("'WebSocket' is not supported in your environment.");
}
return new WebSocketTransport(this._httpClient, this._accessTokenFactory, this._logger, this._options.logMessageContent!,
this._options.WebSocket, this._options.headers || {});
case HttpTransportType.ServerSentEvents:
if (!this._options.EventSource) {
throw new Error("'EventSource' is not supported in your environment.");
}
return new ServerSentEventsTransport(this._httpClient, this._httpClient._accessToken, this._logger, this._options);
case HttpTransportType.LongPolling:
return new LongPollingTransport(this._httpClient, this._logger, this._options);
default:
throw new Error(`Unknown transport: ${transport}.`);
}
}
private _startTransport(url: string, transferFormat: TransferFormat): Promise<void> {
this.transport!.onreceive = this.onreceive;
if (this.features.reconnect) {
this.transport!.onclose = async (e) => {
let callStop = false;
if (this.features.reconnect) {
try {
this.features.disconnected();
await this.transport!.connect(url, transferFormat);
await this.features.resend();
} catch {
callStop = true;
}
} else {
this._stopConnection(e);View on GitHub (pinned to 3600ca084e)