@cloudamqp/amqp-client
    Preparing search index...

    Interface AMQPSessionOptions<P, C, KP, KC>

    Options for AMQPSession.connect.

    interface AMQPSessionOptions<
        P extends ParserMap = {},
        C extends CoderMap = {},
        KP extends keyof P & string = never,
        KC extends keyof C & string = never,
    > {
        backoffMultiplier?: number;
        channelMax?: number;
        coders?: CoderRegistry<C>;
        defaultContentEncoding?: KC;
        defaultContentType?: KP;
        frameMax?: number;
        heartbeat?: number;
        logger?: null | Logger;
        maxReconnectInterval?: number;
        maxRetries?: number;
        name?: string;
        onblocked?: (reason: string) => void;
        ondisconnect?: (error?: Error) => void;
        onfailed?: (error?: Error) => void;
        onreturn?: (msg: AMQPMessage<P>) => void;
        onunblocked?: () => void;
        parsers?: ParserRegistry<P>;
        reconnectInterval?: number;
        tlsOptions?: AMQPTlsOptions;
        vhost?: string;
        onconnect(session: AMQPSession<P, C, KP, KC>): void;
    }

    Type Parameters

    • P extends ParserMap = {}
    • C extends CoderMap = {}
    • KP extends keyof P & string = never
    • KC extends keyof C & string = never
    Index

    Properties

    backoffMultiplier?: number

    Multiplier for exponential backoff (default: 2)

    channelMax?: number

    Max channels the session may open on this connection (0 = unlimited). Overrides any ?channelMax= in the URL.

    coders?: CoderRegistry<C>

    Coder registry for automatic message encoding/decoding.

    defaultContentEncoding?: KC

    Default content-encoding applied to published messages when not set explicitly.

    defaultContentType?: KP

    Default content-type applied to published messages when not set explicitly.

    frameMax?: number

    Max AMQP frame size in bytes (minimum 8192). Overrides any ?frameMax= in the URL.

    heartbeat?: number

    Heartbeat interval in seconds (0 disables). Overrides any ?heartbeat= in the URL.

    logger?: null | Logger

    Logger instance. Pass null to disable logging explicitly.

    maxReconnectInterval?: number

    Maximum delay in milliseconds between reconnection attempts (default: 30000)

    maxRetries?: number

    Maximum number of reconnection attempts — 0 means infinite (default: 0)

    name?: string

    Connection name, shown in the RabbitMQ management UI. Overrides any ?name= in the URL.

    onblocked?: (reason: string) => void

    Fires when the broker blocks the connection from publishing — usually triggered by a resource alarm (memory or disk) on the server. Subsequent publishes reject with Connection blocked by server until the broker unblocks. Use this to apply backpressure upstream.

    ondisconnect?: (error?: Error) => void

    Fires when the underlying connection drops, before the reconnect loop starts. Useful for visibility into the gap between disconnect and reconnect.

    onfailed?: (error?: Error) => void

    Fires when max reconnect retries are exhausted.

    onreturn?: (msg: AMQPMessage<P>) => void

    Fires when a mandatory: true publish is returned by the broker because it had no route to a queue. The session wires this onto every channel it opens for publishing, so a single handler covers all session publishes.

    onunblocked?: () => void

    Fires when the broker lifts a previous block on the connection.

    parsers?: ParserRegistry<P>

    Parser registry for automatic message serialization/deserialization.

    reconnectInterval?: number

    Initial delay in milliseconds before reconnecting (default: 1000)

    tlsOptions?: AMQPTlsOptions

    TLS options — only used when connecting via amqp/amqps

    vhost?: string

    AMQP virtual host. For WebSocket URLs the URL path is the relay endpoint, not the vhost — use this option to specify the vhost explicitly. Defaults to "/" for WebSocket connections and to the URL path for TCP connections.

    Methods

    • Fires after a successful (re)connection — both the initial connect and every reconnect after consumer recovery completes. Registering here rather than after connect() resolves means a single handler covers both code paths.

      The session is passed in because on the initial connect this fires before the connect() call returns, so closures over the outer session variable would still see undefined. Use the argument — it's the same instance either way.

      Fire-and-forget. If your handler does async setup that the rest of your code depends on, drive it yourself (e.g. await setup(session) after connect() resolves) and use onconnect to re-run it on reconnects.

      Parameters

      Returns void