# Enhanced Streams Errors and Reconnects

> Handle gRPC failures, stale topics, duplicate events, and stream restarts.

Canonical: https://nolimitnodes.com/docs/api-reference/enhanced-streams/errors-reconnect

## Common status codes

| Code | Cause | Your action |
|---|---|---|
| `UNAUTHENTICATED` | Missing or invalid key | Replace the credential |
| `PERMISSION_DENIED` | Topic blocked by account access | Review plan access |
| `NOT_FOUND` | Topic name does not exist | Call `ListTopics` |
| `RESOURCE_EXHAUSTED` | Stream or traffic limit reached | Close unused streams |
| `UNAVAILABLE` | Temporary transport failure | Reconnect with backoff |
| `INTERNAL` | Processing failure | Retry once, then log details |

## Reconnect

Enhanced Streams do not accept an offset in `SubscribeRequest`.

After a disconnect:

1. Wait with exponential backoff and jitter.
2. Call `ListTopics` after a `NOT_FOUND` response.
3. Open a new subscription.
4. Deduplicate events in your storage layer.
5. Alert after repeated failures.

## Deduplicate

Store these envelope fields:

- `topic`
- `partition`
- `offset`
- `timestamp_ms`

Use a unique database key over `topic`, `partition`, and `offset`.

## Parse JSON once

Python protobuf clients return `payload` as bytes.

```python
event = json.loads(message.payload)
```

JavaScript proto loaders often return a `Buffer`.

```javascript
const event = JSON.parse(message.payload.toString("utf8"))
```

Do not base64-decode either value.
