# No retained messages, and how to catch up

> Why MQTT V2 retains nothing and replays nothing, what that means for a client that connects late, and how to start from the current state.

Developers · Concept · https://wxalerts.org/docs/developers/mqtt/retained-and-tombstones/

In MQTT V2, nothing on your account's topics is retained. A message is sent once,
to the clients connected when it is published, and then it is gone. There is no
backfill either: an account hears an alert from the moment it matches, and a
client that connects later hears nothing about what happened before.

## What that changes for a client

- **No opening burst.** Subscribing delivers nothing. A message you receive is
  always new, so it is safe to notify on every one.
- **No tombstones.** The V1 feed ended a hazard with an empty retained message.
  V2 ends one with an ordinary message whose `status` is `cancelled` or
  `expired`. Every V2 payload is JSON.
- **A gap is a gap.** If your client is offline, or reconnecting, when an alert
  is issued, that message is not replayed. Reconnect with a backoff and then fill
  the gap yourself.

## Starting from the current state

When your client starts, and after every reconnect, ask the REST API what is in
effect, and then let MQTT carry you from there:

1. Subscribe to `V2/{user_id}/NWS/#` first, so nothing falls between the two.
2. Read the alerts in effect for your places from the
   [alerts API](/docs/api/alerts/), for example the active alerts at a point.
3. Key everything on the alert's `id`. A message replaces what you hold for that
   `id`, and a `status` of `cancelled` or `expired` removes it.

For lightning, the same idea applies: see
[Merge lightning history with the live feed](/docs/developers/mqtt/merging-lightning/).

## When an alert ends

Decide an alert's state from its `status` and `ends`, not from your own clock.
`expires` is the "expect an update by" time and often sits in the past on a live
alert. An alert that ends for some of your places and not others arrives as a
`cancelled` message that names the released places in `places`, while the alert
stays in effect for the rest. If you track alerts by place, drop it from those
places.

If you stop hearing about an alert you hold, check `ends` and the REST API before
you decide it is over. A missed message is possible in any MQTT client, and the
REST API is the source of truth.

The topics, payload and limits are in the
[MQTT alerts feed](/docs/developers/mqtt/alerts/) reference.
