Provides guidance on configuring raw WebSocket endpoints in Orchard Core tenants using the CrestApps WebSockets module. Covers middleware setup, WebSocketOptions, connection registries, and host affinity.
Ships in crestapps-orchardcore. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an Orchard Core expert. Generate accurate code and configuration for features that accept raw WebSocket upgrades (HttpContext.WebSockets.AcceptWebSocketAsync()) in a CrestApps Orchard Core tenant.
app.UseWebSockets(). Without it a raw upgrade is refused. SignalR does not need it (see orchardcore-signalr).CrestApps.OrchardCore.WebSockets is the single place the middleware is added. It is EnabledByDependencyOnly, so it never shows as a toggle; declare it as a dependency of your feature instead of enabling it in a recipe.CrestApps.OrchardCore.WebSockets.Abstractions (IWebSocketConnectionRegistry, WebSocketRendezvous), not on the module's host wiring.{ "steps": [...] }.sealed modifier, except for View Models.| Item | Value |
|---|---|
| Module package | CrestApps.OrchardCore.WebSockets (category Infrastructure) |
| Feature ID | CrestApps.OrchardCore.WebSockets (WebSocketsConstants.Feature.Area) |
| Enabled by | Dependency only (for example the CrestApps.OrchardCore.Telnyx feature) |
| Contracts package | CrestApps.OrchardCore.WebSockets.Abstractions (namespace CrestApps.OrchardCore.WebSockets) |
| Configuration section | CrestApps:WebSockets (WebSocketsConstants.ConfigurationSectionPath), bound to ASP.NET Core WebSocketOptions |
| Default registry | InMemoryWebSocketConnectionRegistry (per node) |
| Distributed registry | DistributedWebSocketConnectionRegistry, active when OrchardCore.Redis is enabled |
using CrestApps.OrchardCore.WebSockets;
using OrchardCore.Modules.Manifest;
[assembly: Feature(
Id = "MyCompany.MediaBridge",
Name = "Media Bridge",
Category = "Telephony",
Dependencies =
[
WebSocketsConstants.Feature.Area,
]
)]
Every key is optional; omitted keys keep the ASP.NET Core defaults (two-minute keep-alive, no origin restriction).
{
"OrchardCore": {
"CrestApps": {
"WebSockets": {
"KeepAliveInterval": "00:00:30",
"KeepAliveTimeout": "00:00:10",
"AllowedOrigins": [ "https://app.example.com" ]
}
}
}
}
| Key | Meaning |
|---|---|
KeepAliveInterval | Interval for server ping frames on an idle socket. |
KeepAliveTimeout | Time to wait for a pong before aborting. Omit to disable. |
AllowedOrigins | Accepted Origin header values. Empty accepts all. Only browser handshakes send Origin, so this does not restrict server-to-server provider callbacks. |
Environment variables use OrchardCore__CrestApps__WebSockets__KeepAliveInterval. A tenant's own App_Data/Sites/{TenantName}/appsettings.json starts at CrestApps without the OrchardCore wrapper. The options are read once when the pipeline is built, so a change needs a tenant reload.
A provider (for example Telnyx media streaming) is asked to dial back to a WebSocket endpoint. The request that asked waits for that socket; the endpoint that accepts it hands it over through the registry.
using System.Security.Cryptography;
using CrestApps.OrchardCore.WebSockets;
using Microsoft.AspNetCore.WebUtilities;
public sealed class MediaBridgeStarter
{
private readonly IWebSocketConnectionRegistry _registry;
public MediaBridgeStarter(IWebSocketConnectionRegistry registry)
{
_registry = registry;
}
public async Task RunAsync(CancellationToken cancellationToken)
{
var key = WebEncoders.Base64UrlEncode(RandomNumberGenerator.GetBytes(32));
var rendezvous = await _registry.RegisterAsync(key, cancellationToken);
try
{
// Ask the provider to connect to /api/my-bridge/media?key={key} here.
var socket = await rendezvous.ConnectedTask.WaitAsync(TimeSpan.FromSeconds(15), cancellationToken);
try
{
// Read and write media frames on the socket.
}
finally
{
rendezvous.Release();
}
}
catch
{
rendezvous.Abort();
await _registry.RemoveAsync(key, CancellationToken.None);
throw;
}
}
}
The endpoint the provider dials:
routes.Map("/api/my-bridge/media", async (HttpContext httpContext, IWebSocketConnectionRegistry registry) =>
{
if (!httpContext.WebSockets.IsWebSocketRequest)
{
return Results.BadRequest();
}
var rendezvous = await registry.TryClaimAsync(httpContext.Request.Query["key"], httpContext.RequestAborted);
if (rendezvous is null)
{
// Unknown, already claimed, expired, or registered on another node.
return Results.NotFound();
}
var socket = await httpContext.WebSockets.AcceptWebSocketAsync();
rendezvous.TryComplete(socket);
// Keep the request, and so the socket, alive until the consumer releases it.
await rendezvous.ReleasedTask;
return Results.Empty;
});
RegisterAsync throws on a duplicate key. TryClaimAsync atomically claims and removes the rendezvous, so a key works once.
| Registry | When | Behavior |
|---|---|---|
| In-memory | Default | A key is known only on the node that registered it. A callback on another node looks like an unknown key. |
| Distributed | OrchardCore.Redis enabled for the tenant | The rendezvous still lives on the registering node, which records ownership of the key in Redis for 10 minutes. A misrouted callback is still refused, but the log names the owning node and the rendezvous stays intact for the provider's retry. If Redis is unreachable, registration falls back to node-local behavior. |
OrchardCore.Redis so misrouting shows in the log.IWebSocketConnectionRegistry is replaceable; register another implementation with services.Replace(...) to add a relay.Both registries count rendezvous operations on the CrestApps.OrchardCore.WebSockets meter: crestapps.websockets.rendezvous (result = registered, conflict, claimed, miss, cross_node, removed; cross_node is a socket that arrived on a node other than the waiting one) and crestapps.websockets.rendezvous.wait.duration (registration to the provider's socket arriving). The rendezvous key never tags a metric. See orchardcore-observability.
| Symptom | Check |
|---|---|
| Upgrade refused or the request is not a WebSocket request | Your feature does not depend on CrestApps.OrchardCore.WebSockets, so UseWebSockets is not in the pipeline |
| Callback is refused with an unknown key | The callback reached another node, the key expired, or it was already claimed |
| Browser handshake rejected | The page origin is missing from AllowedOrigins |
| Idle sockets drop behind a proxy | Lower KeepAliveInterval below the proxy idle timeout |
orchardcore-telephony-telnyx for the Telnyx media stream endpoint that uses this feature.orchardcore-contact-center for voice media and live call topology.orchardcore-signalr for hub-based real-time messaging.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
orchard-core, websockets, crestapps, tenant-pipeline, rendezvous
/crestapps-orchardcore:orchardcore-websocketsfrom crestapps-orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin crestapps-orchardcore137 skills in this plugin
/orchardcore-accountsSkill for the CrestApps Orchard Core Accounts module (CrestApps.OrchardCore.Accounts) with its Account Members, Account Team, Account E-mail Domains and Account Locations features. Covers the Account type and AccountPart, the account picker and search, IAccountChildTypeRule, account page sections (AccountPageTabs, AddPageSection, Notes), members and IAccountMemberService, account invitations, the account owner and team picked from staff, e-mail domains, locations with a billing location, the account's billing profile and party members, the Accounts recipe and deployment steps, and the admin menu. Use this skill when requests mention accounts, the businesses or households records belong to, an account page tab, members, invitations, owners, domains or locations. Strong matches include AccountPart, AccountPageTabs, IAccountMemberService, IAccountInvitationService, AccountInvitation, AccountTeamPart, AccountEmailDomainsPart, IAccountEmailDomains, AccountLocationsPart and ManageAccountMembers./orchardcore-accounts-b2bSkill for the CrestApps Orchard Core Accounts B2B module (CrestApps.OrchardCore.Accounts.B2B), business selling on an Account content item. Covers B2BAccountPart and B2BAccount, buyers as account members and ship-to addresses as account locations, terms (deposit, net days, credit limit) through the account-terms tender billed to the account, the account's billing profile, purchase order numbers, quotes, price lists through IBuyerPriceProvider, order limits, approvals and budgets, OCI punchout, the account/business page and API, the PriceLists recipe and deployment steps, the B2BAccounts report source, and the move from the removed Companies module. Use this skill when requests mention B2B, wholesale or business buyers, net terms, purchase orders, price lists, order approvals or punchout. Strong matches include B2BAccountPart, B2BAccount, AccountTerms, AccountTermsTenderProvider, B2BAccountBillingProfileSource, IB2BAccountStore, PriceList, B2BPriceProvider, B2BApprovalService and ManageB2BAccounts.Other plugins' skills for the same job