Skip to content

Errors

natsio.errors

Public exception hierarchy.

Every exception raised by natsio derives from NATSError. Where it helps except ergonomics, subtrees additionally mix in the matching builtin (e.g. TimeoutError is also a builtins.TimeoutError).

AuthenticationExpiredError

AuthenticationExpiredError(
    description: str = "", *, fatal: bool = True
)

Bases: ServerError

Credentials expired while the connection was active.

AuthorizationViolationError

AuthorizationViolationError(
    description: str = "", *, fatal: bool = True
)

Bases: ServerError

Credentials were rejected by the server.

BadHeadersError

BadHeadersError(description: str = '')

Bases: NATSError

A header block or user-supplied header is malformed or unsafe to send.

ConfigError

ConfigError(description: str = '')

Bases: NATSError, ValueError

Invalid client configuration.

ConnectionClosedError

ConnectionClosedError(description: str = '')

Bases: NATSError, ConnectionError

The operation cannot proceed because the connection is closed.

DrainTimeoutError

DrainTimeoutError(description: str = '')

Bases: TimeoutError

A drain did not finish within drain_timeout.

MaxControlLineExceededError

MaxControlLineExceededError(description: str = '')

Bases: ParserError

A control line exceeded the configured maximum length.

MaxPayloadExceededError

MaxPayloadExceededError(description: str = '')

Bases: ProtocolError

A message payload exceeded the maximum payload size.

MaxSubscriptionsExceededError

MaxSubscriptionsExceededError(description: str = '')

Bases: ServerError

The account's subscription limit was hit. Non-fatal: the connection stays open.

MissingDependencyError

MissingDependencyError(description: str = '')

Bases: NATSError, ImportError

An optional dependency is required for the requested feature.

NATSError

NATSError(description: str = '')

Bases: Exception

Root of the natsio exception hierarchy.

NoReplySubjectError

NoReplySubjectError(description: str = '')

Bases: NATSError

Attempted to respond to a message that carries no reply subject.

NoRespondersError

NoRespondersError(description: str = '')

Bases: NATSError

No subscriber is listening on the requested subject (server status 503).

NoServersAvailableError

NoServersAvailableError(description: str = '')

Bases: ConnectionClosedError

Every server in the pool is unreachable or exhausted its retry budget.

ParserError

ParserError(description: str = '')

Bases: ProtocolError

Fatal framing/parsing failure.

A byte stream cannot be resynchronized mid-frame: after this is raised the parser refuses further use and the connection must be torn down.

PermissionsViolationError

PermissionsViolationError(description: str = '')

Bases: ServerError

Publish/subscribe denied for a subject. Non-fatal: the connection stays open.

ProtocolError

ProtocolError(description: str = '')

Bases: NATSError

The peer violated the NATS wire protocol.

ReconnectBufExceededError

ReconnectBufExceededError(description: str = '')

Bases: NATSError

A publish issued while disconnected exceeded reconnect_buf_size.

Non-fatal: the connection stays alive and reconnect continues; only this publish is rejected. Raised immediately for every disconnected publish when buffering is disabled (reconnect_buf_size=-1).

ServerError

ServerError(description: str = '', *, fatal: bool = True)

Bases: NATSError

An error reported by the server via -ERR.

SlowConsumerError

SlowConsumerError(
    description: str = "",
    *,
    subject: str = "",
    sid: int = 0,
    dropped: int = 0,
)

Bases: NATSError

A subscription exceeded its pending limits; messages were dropped.

StaleConnectionError

StaleConnectionError(
    description: str = "", *, fatal: bool = True
)

Bases: ServerError

The server (or ping monitoring) declared the connection stale.

SubscriptionClosedError

SubscriptionClosedError(description: str = '')

Bases: NATSError

The subscription has been unsubscribed or drained.

TimeoutError

TimeoutError(description: str = '')

Bases: NATSError, TimeoutError

An operation exceeded its deadline.

WebsocketError

WebsocketError(description: str = '')

Bases: ProtocolError

A WebSocket (RFC 6455) handshake or framing violation.

Fatal like a framing error: a WebSocket stream cannot be resynchronized mid-frame, so the transport must be torn down.