Tauri plugin

Messages and errors

What a subscription's channel carries, the state objects, ack rules and SocketIoError kinds.

The JS API handles the channel for you; this page describes it for Rust-side channels (subscribe) and for debugging.

Channel messages

A subscription's channel carries:

type Message =
  | { type: 'state'; state: ConnectionState; snapshot?: boolean }
  | { type: 'event'; event: string; args: unknown[]; binary?: number[][]; ackId?: number }

The first state message carries snapshot: true: the state at subscribe time, also returned by connect / attach; nothing older follows it on that channel.

States

{ status: 'connecting', attempt }
{ status: 'connected', sid, recovered }
{ status: 'disconnected', reason, error? }
{ status: 'reconnecting', attempt, delay, error? }
{ status: 'closed', reason, error? }

Reasons are socket.io-client's strings (io server disconnect, io client disconnect, ping timeout, transport close, transport error, parse error) plus connect rejected, reconnect failed, client dropped.

A failed first connect can send the attempt's states (connecting, closed) on the channel before the promise rejects; guest-js drops that socket, the rejection is the answer.

Server acks

A server ack gets one ackId, offered to every webview subscribed to the event; the first answer wins, later ones fail with UnknownAck. Acks wait for ACK_TTL (2 min). Once a disconnect starts, no ack is offered any more. Read-only clients offer no acks to webviews.

Errors

Rejections are SocketIoError with kind, message and data. Messages never contain URLs or query values.

kindWhen
ConnectRejectedthe server's middleware refused the namespace; data is its err.data
ConnectTimeoutthe first connect attempt timed out
NotConnected, Disconnected, Closed, AckTimeoutas in the Rust client
AccessDeniedthe client is read-only
UnknownClientno client with that id
AlreadyExiststhe id is in use
ReservedRust reserved the id
UnknownAckthe ack was answered, expired or belongs to another client or webview
UrlNotAllowedthe URL is outside allow_url_prefix
TooManySubscriptionsthe webview has 64 subscriptions
InvalidOptionsa wrong option type or value, or a refused header (the value is not echoed)
NotConfigurablesetAuth / setHeaders / setQuery / reconnect on a client Rust connected
WebsocketCloseddata: { code, reason }
ProxyFailedthe proxy refused
HttpStatus, Websocket, Http, TlsProviderMissing, ...engine failures by name; HttpStatus has data.status and data.message
Ipca rejection that is not the plugin's (a command the capability does not allow)