LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
  • Stream
LangGraph SDK
  • Ui
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Utils
  • Server
  • Stream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
  • Store
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemoteStream
LangGraph SDK
UiClientAuthReactLoggingReact UiUtilsServerStream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
Store
LangGraph Checkpoint Redis
ShallowStore
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
Cli
LangGraph API
LangGraph CLI
LangGraph CUA
Utils
LangGraph Supervisor
LangGraph Swarm
Language
Theme
JavaScript@langchain/langgraph-sdkclientProtocolWebSocketTransportAdapter
Class●Since v1.9

ProtocolWebSocketTransportAdapter

Copy
class ProtocolWebSocketTransportAdapter

Constructors

Properties

Methods

View source on GitHub
constructor
constructor
property
threadId: string

Thread ID this transport currently targets.

method
close→ Promise<void>

Shuts down the transport and releases any underlying resources.

method
events→ AsyncIterable<Message>

Streams incoming protocol messages from the remote peer. Used by WebSocket transports where all events share one connection.

method
open→ Promise<void>

Opens the underlying connection (e.g. WebSocket handshake). For HTTP/SSE transports this is a no-op.

method
send→ Promise<void | ErrorResponse | CommandResponse>

Sends a command and optionally returns an immediate response.

method
setOnReconnected

Register a callback invoked after each successful reconnect. Used by ThreadStream to re-send active subscription.subscribe commands.

method
setThreadId

Rebind this transport to a different thread.

client.threads.stream(threadId, { transport }) calls this (when implemented) whenever the framework binds or re-binds the active thread — including the lazily-minted id from the first submit() on a threadId: null controller. Implementing it lets an adapter be constructed once (optionally with no threadId) and reused as the active thread becomes known, so the framework doesn't have to tear down and rebuild a custom transport when the thread id appears.

Optional: adapters that bake threadId at construction can omit it, in which case the per-call threadId is ignored (prior behaviour).

Transport adapter that speaks the thread-centric protocol over a bidirectional WebSocket. Bound to a threadId at construction or later via setThreadId — the socket connects to ws://.../threads/:thread_id/stream/events.

On unexpected disconnect the adapter reconnects with exponential backoff (see ProtocolWebSocketTransportOptions.maxReconnectAttempts). The server replays buffered events on the new socket; the SDK deduplicates by event_id. ProtocolWebSocketTransportOptions.onReconnected runs after each successful reconnect so ThreadStream can re-issue subscription.subscribe commands.