Documentation

Errors and Troubleshooting

Check operation errors, handle asynchronous server errors, and diagnose common SDK problems.

Before you start: follow Connection and lifecycle. Register an error listener once per channel. Also check the errors that your calls return.

Every failure is one CelerisError enum. Match on the variant, never on message text. The SDK's own messages name the field and the rule that failed. They never repeat your input, a credential, or server bytes. Errors that the server sends are the CelerisError::Server variant, which holds a ServerError. The enum is #[non_exhaustive], so a match needs a wildcard arm.

1. Check the call you made

use useceleris_client::{CelerisError, text_payload};

match chat.publish(text_payload("Hello")).await {
    Ok(()) => {}
    Err(CelerisError::NotConnected(_)) => println!("Wait until connected before sending."),
    Err(error) => println!("{error}"),
}

Check connect, publish, and presence_list where you call them. A failed initial connect returns its error to the caller and does not also reach on_error. The SDK likewise reports a failed presence query to its caller.

2. Handle server errors separately

use useceleris_client::{CelerisError, ServerErrorType};

let error_listener = channel.events().on_error(|error| {
    let CelerisError::Server(server_error) = error else {
        println!("{error}");

        return;
    };

    println!(
        "{} {:?} {}",
        server_error.error_type.as_str(),
        server_error.sub_type,
        server_error.message
    );

    match server_error.error_type {
        ServerErrorType::PermissionDeniedError => {
            println!("Check the server-issued channel and segment permissions.");
        }
        ServerErrorType::MessageSizeLimitError => println!("Reduce the payload size."),
        // The SDK pauses and resends recent commands by itself.
        ServerErrorType::RateLimitError => println!("Rate limited; publish less often if this repeats."),
        _ => println!("The server reported an error."),
    }
});

// Later:
error_listener.remove();

A ServerError carries error_type, sub_type (the command it answers, or None), and message (the server's own text). resource is what that command names, such as the segment. Error types are open-ended. A type that a newer server adds arrives as ServerErrorType::Other, so retain a wildcard arm. A resource is a ServerErrorResource: Null, Text, Integer32, Integer64, or an Array of these values. Match its variant before you use it.

A permission denial can identify a command and a segment. It does not identify which of several otherwise identical publishes caused the error. The SDK correlates presence-query errors internally. Those errors return from presence_list instead. Server error text is for people, not for programs. Show it as text, never as raw HTML. Server errors leave the connection open.

3. Choose the right response

VariantResponse
ConfigurationFix the invalid argument or credential. A retry with unchanged input does not help
NotConnectedWait for a connection, then try again. A publish waits in the queue only while the channel is reconnecting
TimeoutCheck the credential endpoint and network, or the query deadline
CancelledThe channel closed, or a newer attempt started, during the operation. Do not automatically restart canceled work
TransportCheck network and credential setup. This does not prove an authentication failure
BackpressureSlow production. The publish queue (publish_queue_size, 64 by default) is full, or a presence query found the writer full or paused
OperationInProgressDo not start simultaneous connects or presence queries on one channel
DeliveryUnknownAcceptance is uncertain. Do not blindly resend an irreversible operation
ProtocolOne frame was dropped. The connection remains usable. field and offset locate the failure
ServerAn error that the server sent. See step 2

The SDK catches a panic in a listener and reports it through on_error as Transport. Catch panics in tasks that your listeners start. The SDK does not report a panic in an error listener.

A deadline that you set with tokio::time::timeout returns its own Elapsed error, not a CelerisError. The SDK then drops the operation, as Connection and lifecycle describes.

4. Diagnose common symptoms

SymptomFirst checks
First connect fails and nothing retriesThis is expected. Call connect again from failed
Socket connects but messages are absentChannel/segment match, a held subscription, and read permission
Sender sees no received copyallow_echo defaults to false
Publish returns Ok, then an error arrivesExpected for server refusals. An Ok return is only local acceptance
A listener still runs after its variable is droppedA dropped Registration keeps the listener. Call remove() to remove it
Presence events miss a userYou get events only for joins and leaves while you hold presence. Query a cluster-wide listing
Credentials were denied but the error says TransportThe handshake status is unavailable to the SDK
Messages are absent after recoveryReplay is bounded. Reload authoritative application state
Channel stops in failed after a connection losson_error gives the cause. Recovery used all maximum_reconnect_attempts (10 by default), or a failure other than Transport or Timeout stopped it. Call connect again
presence_list returns Configurationpage must be at least 1, and per_page must be from 1 to 100
A closed channel cannot reconnectObtain a new channel from the client

See Reconnection and Recovery for which failures retry. Do not run your own retry loop while the channel is in the reconnecting state.

Next: Server-side usage, or the Rust client API for the full error surface.

We use Google cookies for analytics and for advertising measurement, only if you allow them. Until you choose, Google sets no cookies. Refer to our Cookie Policy.