> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/tposs/latest/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/tposs/latest/troubleshooting/nats.md).

# NATS issues

TPOSS uses NATS JetStream for distributed session locking and CDMP endpoint tracking. Connection failures are logged with code `1010`.

## How TPOSS connects to NATS

On startup, TPOSS opens a pool of connections to each configured NATS server (**nats-services.{SERVICE_NAME}.connections_per_stream** and **nats-services.{SERVICE_NAME}.pool_size**). After establishing connections, it can create the required JetStream streams and KV buckets. If any of these steps fail, TPOSS logs a critical error with code `1010` and stops. Once running, TPOSS retries dropped connections automatically using a configurable backoff (**nats-services.{SERVICE_NAME}.backoff_period**).

## Diagnosing NATS issues

- Check the **nats_requests_rtt** metric - high latency indicates NATS is reachable but slow, which can cause lock timeouts and request failures.
- Check the NATS server logs and resource usage (memory, CPU, open connections). JetStream streams are kept in memory by default; insufficient memory is a common cause of degraded performance under load.
- If TPOSS logs `NATS authorization file does not contain properly formatted NKey seed and JWT token`, verify the Kubernetes secret referenced by **nats-services.{SERVICE_NAME}.secret_name** is correctly formatted and mounted.
- For temporary `Cannot connect to NATS` errors that resolve on their own, check network stability between the TPOSS pod and the NATS service, and consider increasing **nats-services.{SERVICE_NAME}.connection_timeout** if the network has high latency.

## Recovery

TPOSS will reconnect and resume normal operation once NATS is reachable again.
