{"record":{"id":"6e1561a010fb93d7","repo":"OrchardCMS/OrchardCore","slug":"websocket-is-not-supported-in-your-environment","errorCode":null,"errorMessage":"'WebSocket' is not supported in your environment.","messagePattern":"'WebSocket' is not supported in your environment\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.SignalR/wwwroot/Scripts/signalr.js","lineNumber":2993,"sourceCode":"                    transportExceptions.push(new FailedToStartTransportError(`${endpoint.transport} failed: ${ex}`, HttpTransportType[endpoint.transport]));\n                    if (this._connectionState !== \"Connecting\" /* ConnectionState.Connecting */) {\n                        const message = \"Failed to select transport before stop() was called.\";\n                        this._logger.log(LogLevel.Debug, message);\n                        return Promise.reject(new AbortError(message));\n                    }\n                }\n            }\n        }\n        if (transportExceptions.length > 0) {\n            return Promise.reject(new AggregateErrors(`Unable to connect to the server with any of the available transports. ${transportExceptions.join(\" \")}`, transportExceptions));\n        }\n        return Promise.reject(new Error(\"None of the transports supported by the client are supported by the server.\"));\n    }\n    _constructTransport(transport) {\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, 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    _startTransport(url, transferFormat) {\n        this.transport.onreceive = this.onreceive;\n        if (this.features.reconnect) {\n            this.transport.onclose = async (e) => {\n                let callStop = false;","sourceCodeStart":2975,"sourceCodeEnd":3011,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.SignalR/wwwroot/Scripts/signalr.js#L2975-L3011","documentation":"HttpConnection._constructTransport throws this when a WebSockets transport is requested but no WebSocket implementation is available in the runtime — i.e. options.WebSocket is null/undefined because the environment (very old browser, restricted sandbox, or Node without a WebSocket polyfill) does not provide the global WebSocket constructor.","triggerScenarios":"Requesting HttpTransportType.WebSockets explicitly (transport: signalR.HttpTransportType.WebSockets or skipNegotiation: true with WebSockets) in an environment lacking a global WebSocket; running the client in Node.js without injecting options.WebSocket.","commonSituations":"Node.js server-side SignalR clients before WebSocket globals existed (no WebSocket in older Node); locked-down corporate browsers or WebViews without WebSocket support; custom environments that stripped window.WebSocket.","solutions":["Allow an additional transport (SSE or LongPolling) by leaving transport unset (auto) so the client falls back.","In Node, provide a WebSocket implementation: options.WebSocket = require('ws').","Upgrade the runtime/browser to one with native WebSocket support.","If WebSockets are blocked by the network, enable SSE/LongPolling on the server and negotiate normally."],"exampleFix":"// before (Node, no global WebSocket)\nnew signalR.HubConnectionBuilder()\n  .withUrl(url, { transport: signalR.HttpTransportType.WebSockets })\n  .build();\n// after\nconst WebSocket = require(\"ws\");\nnew signalR.HubConnectionBuilder()\n  .withUrl(url, { WebSocket, transport: signalR.HttpTransportType.WebSockets })\n  .build();","handlingStrategy":"fallback","validationCode":"function hasWebSocketSupport() {\n  return typeof WebSocket !== \"undefined\";\n}\nconst transport = hasWebSocketSupport()\n  ? signalR.HttpTransportType.WebSockets\n  : signalR.HttpTransportType.LongPolling;","typeGuard":"function supportsWebSockets(options) {\n  return typeof WebSocket !== \"undefined\" || options.WebSocket != null;\n}","tryCatchPattern":"try {\n  await connection.start();\n} catch (err) {\n  if (err.message.includes(\"'WebSocket' is not supported\")) {\n    connection = rebuildConnection({ transport: signalR.HttpTransportType.LongPolling });\n    await connection.start();\n  } else { throw err; }\n}","preventionTips":["Detect WebSocket support at startup and choose transports accordingly.","In Node.js, always inject options.WebSocket (e.g. require('ws')).","Keep server-side SSE/LongPolling enabled as fallback transports.","Document WebSocket requirements for restricted browser environments."],"tags":["signalr","websockets","environment","missing-dependency"],"backgroundTag":"unsupported-platform","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}