#[non_exhaustive]pub struct WebSocketTransportConfig {
pub request_timeout: Duration,
pub send_timeout: Duration,
pub ping_interval: Option<Duration>,
pub extra_headers: HashMap<String, String>,
pub extensions: Vec<String>,
pub connect_timeout: Duration,
pub max_message_size: usize,
pub max_pending_requests: usize,
/* private fields */
}websocket only.Expand description
Configuration for WebSocketTransport::connect_with_config.
#[non_exhaustive]: build it with Default and the with_* setters,
which cover every field; a struct literal is not available outside this
crate, so a field added later does not break callers.
Its Debug prints the names of extra_headers, never their values.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.request_timeout: DurationTimeout for unary responses and for the first frame of a stream. Default: 30 seconds.
Through A2aClient a stream’s first-frame bound
is ClientConfig::stream_first_event_timeout
instead: the client applies its own stream bounds to every stream it
returns, whichever transport produced it. This value remains the
bound for a stream taken from the transport directly.
send_timeout: DurationHow long a blocking SendMessage waits for the agent’s turn.
Default: DEFAULT_SEND_TIMEOUT.
ping_interval: Option<Duration>How often an idle connection is pinged, and so how soon a connection
the network dropped without telling anyone is found out: a peer that
sends nothing (the pong included) through two intervals in a row is
taken to be gone, between two and three intervals after its last frame.
Every pending call then fails at once as a dropped connection does, and
the next call reconnects. None sends no pings. Default: 15 seconds.
Without it a half-open connection (a NAT or load balancer that forgot the flow, a peer that lost power) was never detected: no ping, and a call’s timeout did not mark the connection dead, so every call timed out on the same socket until the kernel gave up, about fifteen minutes later (audit D-08). Any frame from the peer counts as life; a busy connection sends no pings.
extra_headers: HashMap<String, String>Extra HTTP headers for the WebSocket upgrade request (e.g. an
Authorization header produced by an
AuthInterceptor).
extensions: Vec<String>The extensions to ask the agent for; see
with_extensions. Default: none.
connect_timeout: DurationHow long the connect may take: TCP, TLS, and the HTTP upgrade handshake, together. Default: 10 seconds.
Nothing bounded this. connect_async_with_config was awaited bare, and
no OS timeout covers an upgrade that is answered late or never — a
server that accepts the TCP connection and then goes silent held the
caller forever. Measured against such a server: still pending at 3
seconds, with no deadline to reach.
Every sibling transport already bounded this — JSON-RPC and REST
through ClientConfig::connection_timeout, gRPC through
GrpcTransportConfig::connect_timeout — and this default matches
theirs. ClientConfig::connection_timeout cannot reach here: this
transport is built directly and handed to with_custom_transport, so
it never sees a ClientConfig.
max_message_size: usizeMaximum size of an incoming WebSocket message, in bytes, enforced at the protocol level during the read. Default: 32 MiB, replacing tungstenite’s 64 MiB default.
That default is
DEFAULT_MAX_RESPONSE_SIZE,
the same constant the HTTP and gRPC transports start from — the same
value, not the same setting. This transport is reached through
with_custom_transport,
so it never sees a ClientConfig and
max_response_size does not reach it. The two agree until somebody
changes one, and the person who tightens a limit is the person who
decided the default was wrong for them. Set the bound here.
max_pending_requests: usizeHow many requests may be awaiting a response on this connection at
once, unary and streaming together. Default:
DEFAULT_MAX_PENDING_REQUESTS.
The pending map holds a sender per in-flight request and a WebSocket
connection is meant to be long-lived, so without a cap a caller that
issued requests faster than the server answered them grew it without
bound. The N+1-st request is refused up front with
ClientError::TooManyPendingRequests rather than queued invisibly;
it is retryable, and a later attempt finds room once responses arrive.
Implementations§
Source§impl WebSocketTransportConfig
impl WebSocketTransportConfig
Sourcepub const fn with_max_pending_requests(
self,
max: usize,
) -> WebSocketTransportConfig
pub const fn with_max_pending_requests( self, max: usize, ) -> WebSocketTransportConfig
Sets how many requests may be awaiting a response on this connection
at once. See max_pending_requests.
Sourcepub const fn with_ping_interval(
self,
every: Duration,
) -> WebSocketTransportConfig
pub const fn with_ping_interval( self, every: Duration, ) -> WebSocketTransportConfig
Sets ping_interval.
Sourcepub const fn without_ping(self) -> WebSocketTransportConfig
pub const fn without_ping(self) -> WebSocketTransportConfig
Sends no pings: a half-open connection is then found only when a write
to it fails or its peer closes it. See ping_interval.
Sourcepub const fn with_request_timeout(
self,
timeout: Duration,
) -> WebSocketTransportConfig
pub const fn with_request_timeout( self, timeout: Duration, ) -> WebSocketTransportConfig
Sets the request timeout.
Sourcepub const fn with_send_timeout(
self,
timeout: Duration,
) -> WebSocketTransportConfig
pub const fn with_send_timeout( self, timeout: Duration, ) -> WebSocketTransportConfig
Sets send_timeout.
Sourcepub const fn with_connect_timeout(
self,
timeout: Duration,
) -> WebSocketTransportConfig
pub const fn with_connect_timeout( self, timeout: Duration, ) -> WebSocketTransportConfig
Sets how long the connect may take, handshake included.
Sourcepub fn with_extra_headers(
self,
headers: HashMap<String, String>,
) -> WebSocketTransportConfig
pub fn with_extra_headers( self, headers: HashMap<String, String>, ) -> WebSocketTransportConfig
Sets extra HTTP headers for the upgrade request.
Sourcepub fn with_extensions<I, S>(self, uris: I) -> WebSocketTransportConfig
pub fn with_extensions<I, S>(self, uris: I) -> WebSocketTransportConfig
Asks the agent to use these extensions on every request of the
connection: the A2A-Extensions service parameter (spec §3.2.6), sent
with the upgrade, which is where the server reads a WebSocket’s
service parameters. An A2A-Extensions entry in
extra_headers replaces it.
The connect refuses a URI that is empty, or holds a comma, whitespace or anything but visible ASCII.
Sourcepub const fn with_max_message_size(
self,
max_bytes: usize,
) -> WebSocketTransportConfig
pub const fn with_max_message_size( self, max_bytes: usize, ) -> WebSocketTransportConfig
Sets the maximum incoming message size in bytes.
Sourcepub fn with_tls_config(self, config: ClientConfig) -> WebSocketTransportConfig
Available on crate feature tls-rustls only.
pub fn with_tls_config(self, config: ClientConfig) -> WebSocketTransportConfig
tls-rustls only.Sets the TLS configuration for a wss:// endpoint; a ws:// one does
not use it.
Without one the transport uses
default_tls_config, Mozilla’s roots
verified with ring, as the HTTP transports do. For a private CA pass
tls_config_with_extra_roots.
Its ALPN list, if it has one, must not offer h2: the upgrade is an
HTTP/1.1 request, and a server that picks h2 cannot answer it.
Trait Implementations§
Source§impl Clone for WebSocketTransportConfig
impl Clone for WebSocketTransportConfig
Source§fn clone(&self) -> WebSocketTransportConfig
fn clone(&self) -> WebSocketTransportConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WebSocketTransportConfig
impl Debug for WebSocketTransportConfig
Source§impl Default for WebSocketTransportConfig
impl Default for WebSocketTransportConfig
Source§fn default() -> WebSocketTransportConfig
fn default() -> WebSocketTransportConfig
Auto Trait Implementations§
impl Forget for WebSocketTransportConfig
impl Freeze for WebSocketTransportConfig
impl Move for WebSocketTransportConfig
impl RefUnwindSafe for WebSocketTransportConfig
impl Send for WebSocketTransportConfig
impl Sync for WebSocketTransportConfig
impl Unpin for WebSocketTransportConfig
impl UnsafeUnpin for WebSocketTransportConfig
impl UnwindSafe for WebSocketTransportConfig
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].