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
| Variant | Response |
|---|---|
Configuration | Fix the invalid argument or credential. A retry with unchanged input does not help |
NotConnected | Wait for a connection, then try again. A publish waits in the queue only while the channel is reconnecting |
Timeout | Check the credential endpoint and network, or the query deadline |
Cancelled | The channel closed, or a newer attempt started, during the operation. Do not automatically restart canceled work |
Transport | Check network and credential setup. This does not prove an authentication failure |
Backpressure | Slow production. The publish queue (publish_queue_size, 64 by default) is full, or a presence query found the writer full or paused |
OperationInProgress | Do not start simultaneous connects or presence queries on one channel |
DeliveryUnknown | Acceptance is uncertain. Do not blindly resend an irreversible operation |
Protocol | One frame was dropped. The connection remains usable. field and offset locate the failure |
Server | An 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
| Symptom | First checks |
|---|---|
| First connect fails and nothing retries | This is expected. Call connect again from failed |
| Socket connects but messages are absent | Channel/segment match, a held subscription, and read permission |
| Sender sees no received copy | allow_echo defaults to false |
Publish returns Ok, then an error arrives | Expected for server refusals. An Ok return is only local acceptance |
| A listener still runs after its variable is dropped | A dropped Registration keeps the listener. Call remove() to remove it |
| Presence events miss a user | You get events only for joins and leaves while you hold presence. Query a cluster-wide listing |
| Credentials were denied but the error says Transport | The handshake status is unavailable to the SDK |
| Messages are absent after recovery | Replay is bounded. Reload authoritative application state |
Channel stops in failed after a connection loss | on_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 Configuration | page must be at least 1, and per_page must be from 1 to 100 |
| A closed channel cannot reconnect | Obtain 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.