> For the complete documentation index, see [llms.txt](https://docs.triton.one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.triton.one/solana/real-time-streaming/preconfirmations-grpc/errors-and-reconnection.md).

# Errors and reconnection

Preconfirmations gRPC error types and status codes (UNAUTHENTICATED, RESOURCE\_EXHAUSTED, DATA\_LOSS), and how the Rust client reconnects a dropped stream.

## Error types

| type             | from                                  | when                                                                                                                                               |
| ---------------- | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ConnectError`   | `Connector::connect`, `connect_lazy`  | bad endpoint URI, token not ascii, TLS setup; `connect` also fails on connection refused or timed out                                              |
| `SubscribeError` | `subscribe_harmonic`, `subscribe_bam` | region of the wrong feed, filters over a limit, or the server refused the subscribe (bad token, region not served, feed not entitled, cooling off) |
| `StreamError`    | a stream item                         | the server ended the stream with a status, or closed it                                                                                            |

`RegionError` and `FilterError` are the smaller types behind `SubscribeError`. `ParseError` is returned separately by the `parse` helpers. For one top-level type wrap them with `anyhow` or `Box<dyn Error>`.

## Status codes

| status                | message                                                                                                                                                                                                          | meaning                                                                                                                                                                              | what to do                                                                                                            |
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------- |
| `UNAUTHENTICATED`     | `x-token required`, `x-token not entitled to preconfs`, `x-token not entitled to this feed`                                                                                                                      | no token, an unknown token or one with no preconfs feed, or a token without this feed; see [Access](/solana/real-time-streaming/preconfirmations-grpc.md#access)                     | send the token's value and check the feed is enabled                                                                  |
| `PERMISSION_DENIED`   | `subscription disabled for this feed`                                                                                                                                                                            | the feed was disabled on the subscription while the stream was open                                                                                                                  | the stream is closed; re-enable the feed                                                                              |
| `INVALID_ARGUMENT`    | for example `harmonic_region is required; one stream serves one region`, or `filter <name>: …`                                                                                                                   | region missing, unspecified or of the other feed; a filter over a limit, with no selector, or with a value that does not parse                                                       | fix the request                                                                                                       |
| `FAILED_PRECONDITION` | `region <name> is not served here; served: {…}`                                                                                                                                                                  | the region is not served by this deployment                                                                                                                                          | use one of the regions in [Feeds and regions](/solana/real-time-streaming/preconfirmations-grpc/feeds-and-regions.md) |
| `RESOURCE_EXHAUSTED`  | `account exceeded its coverage limit for this region, cooling off`, `account is cooling off after exceeding its coverage limit for this region, retry in <N>s`, `subscriber cannot keep up, outbound queue full` | over the [coverage](/solana/real-time-streaming/preconfirmations-grpc/coverage-billing-and-limits.md#coverage) share for 30 seconds, still cooling off, or the client cannot keep up | narrow the filters, read faster, retry after the cooloff                                                              |
| `DATA_LOSS`           | `subscriber lagged <N> events behind`                                                                                                                                                                            | the stream fell so far behind the feed that the server dropped its position                                                                                                          | reconnect; the gap is gone                                                                                            |
| `UNAVAILABLE`         | `service shutting down`                                                                                                                                                                                          | the point of presence is restarting                                                                                                                                                  | reconnect; anycast lands on another                                                                                   |

## Reconnect

Points of presence restart on every deploy, so a long-lived stream will drop. By default the Rust client resubscribes the stream with the same request after a backoff and yields `Event::Reconnected`.

{% hint style="warning" %}
Preconfs produced in between are gone; on Harmonic, framing restarts at the next `SlotStart`.
{% endhint %}

| Not retried: errors that retrying cannot fix end the stream | Retried             |
| ----------------------------------------------------------- | ------------------- |
| `Unauthenticated`                                           | `Unavailable`       |
| `PermissionDenied`                                          | `DataLoss`          |
| `InvalidArgument`                                           | `ResourceExhausted` |
| `FailedPrecondition`                                        | `Internal`          |
| `NotFound`                                                  | `Unknown`           |
| `AlreadyExists`                                             | `Aborted`           |
| `OutOfRange`                                                | `Cancelled`         |
| `Unimplemented`                                             | `DeadlineExceeded`  |
|                                                             | A closed stream     |

A stream reconnects once it is open: the first `subscribe_harmonic` or `subscribe_bam` call is not retried, and its error is yours to handle.

The default schedule waits 100ms, then doubles up to 10s between attempts, and never gives up. Tune or disable it on the connector:

```rust
use std::time::Duration;
use triton_preconfs_client::{Connector, Reconnect};

let client = Connector::new(endpoint)
    .reconnect(
        Reconnect::default()
            .initial_interval(Duration::from_millis(250))
            .multiplier(2.0)
            .max_interval(Duration::from_secs(30))
            .max_retries(Some(20)),
    )
    .connect()
    .await?;

let client = Connector::new(endpoint).no_reconnect().connect().await?;
```

With reconnect off the stream yields the error and ends.

***

<i class="fa-life-ring">:life-ring:</i> Contact support by clicking the chat icon in your [customer dashboard](https://customers.triton.one)\ <i class="fa-briefcase">:briefcase:</i> Sales questions? [Contact us](https://triton.one/contact)\ <i class="fa-sparkles">:sparkles:</i> AI agent? Read [llms.txt](https://docs.triton.one/llms.txt)\ <i class="fa-rss">:rss:</i> Follow updates: [Blog](https://blog.triton.one) · [X](https://x.com/triton_one) · [YouTube](https://www.youtube.com/@triton_one_ltd) · [Telegram](https://t.me/tritonone) · [GitHub](https://github.com/rpcpool)
