> **Photon Beta documentation**
> Browse all pages: https://photon.codes/docs/beta/llms.txt
> Search Beta docs via MCP: https://photon.codes/docs/beta/mcp (OAuth REST API MCP: https://mcp.photon.codes/mcp)

# Errors and reconnection

> Handle typed errors and let Socket.IO manage connection recovery.

Listen for `delivery_error`. Command acknowledgements also return typed failures. Errors include `code`, `message`, `fatal`, and `retryable`. A fatal error is followed by disconnection; the error itself is best-effort if the transport has already failed.

Socket.IO owns heartbeat detection and reconnect backoff. After any automatic reconnect, subscribe with your last successfully processed cursor. A terminal application violation causes an explicit server disconnect: fix its cause before calling `connect()` again. Authentication failures before connection appear as `connect_error`; correct the credential or project rather than retrying indefinitely.

## Fatal errors

| Code | Retryable | Action |
| - | - | - |
| `protocol_violation` | false | Fix the invalid command sequence or excessive input. |
| `subscribe_timeout` | true | Subscribe promptly after connecting. |
| `frame_too_large` | false | Reduce the command size. |
| `slow_consumer` | true | Drain deliveries faster and resume from the processed cursor. |
| `capacity` | true | Allow automatic reconnection with backoff. |
| `server_draining` | true | Reconnect and subscribe with the processed cursor. |
| `upstream_unavailable` | true | Reconnect and resume. |
| `internal` | true | Reconnect; retain the connection ID for diagnostics. |

## Non-fatal errors

| Code | Action |
| - | - |
| `reply_unknown_event` | The expectation expired, was consumed, or belongs to another connection. |
| `reply_invalid` | Correct the reply fields or encoding. |
| `reply_too_large` | Reduce the decoded reply body. |
| `reply_publish_failed` | Forwarding failed; the outcome is not a downstream success. |
| `reply_capacity` | This delivery cannot accept a reply; continue handling events. |
| `reply_forbidden` | Use a credential with project:write to reply. |
| `subscribe_repeated` | Keep using the existing subscription. |
| `frame_invalid` | Correct the event name, payload, or acknowledgement callback. |
