InvocationWebSocketHandler Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Base class for handlers that opt in to the invocations_ws
(WebSocket) transport at /invocations_ws, optionally alongside
the HTTP POST /invocations transport.
public abstract class InvocationWebSocketHandler : Azure.AI.AgentServer.Invocations.InvocationHandler
type InvocationWebSocketHandler = class
inherit InvocationHandler
Public MustInherit Class InvocationWebSocketHandler
Inherits InvocationHandler
- Inheritance
Remarks
Override HandleWebSocketAsync(WebSocket, InvocationContext, CancellationToken) to serve a WebSocket connection. The library calls AcceptWebSocketAsync for you, maps a clean handler return to RFC 6455 close code 1000 (NormalClosure) and an uncaught handler exception to 1011 (InternalServerError), preserves handler-initiated close codes unchanged, and emits a structured close-event log line carrying azure.ai.agentserver.invocations_ws.session_id, azure.ai.agentserver.invocations_ws.close_code, and azure.ai.agentserver.invocations_ws.duration_ms.
The inherited HandleAsync(HttpRequest, HttpResponse, InvocationContext, CancellationToken) (HTTP POST /invocations) returns 404 Not Found by default — a WS-only handler does not need to override it. Multi-protocol handlers override both HandleAsync(HttpRequest, HttpResponse, InvocationContext, CancellationToken) and HandleWebSocketAsync(WebSocket, InvocationContext, CancellationToken); both methods see the same session when FOUNDRY_AGENT_SESSION_ID is set so HTTP and WebSocket turns correlate.
No framework-level OpenTelemetry span is created for the connection; ASP.NET Core auto-propagates the inbound W3C trace context to the request Activity, so any spans the handler starts are parented correctly. Session / invocation / x-request-id baggage is propagated onto the current Activity before the handler runs.
Constructors
| Name | Description |
|---|---|
| InvocationWebSocketHandler() | |
Methods
| Name | Description |
|---|---|
| CancelAsync(String, HttpRequest, HttpResponse, InvocationContext, CancellationToken) |
Handles |
| GetAsync(String, HttpRequest, HttpResponse, InvocationContext, CancellationToken) |
Handles |
| GetOpenApiAsync(HttpRequest, HttpResponse, CancellationToken) |
Handles |
| HandleAsync(HttpRequest, HttpResponse, InvocationContext, CancellationToken) |
Handles a |
| HandleWebSocketAsync(WebSocket, InvocationContext, CancellationToken) |
Handles a |