---
title: Keep Alive (clientbound)
description: "Play 0x2C, server → client."
---

`play` · `0x2C` · **clientbound** (server → client)

Sends a random `keepAliveId` that the client must echo back in a serverbound KeepAlive. The server sends it about every 15 seconds. If the client does not answer within 30 seconds the server disconnects it with a timeout.

Sent by the server, read by the client. Listen for it with `client.on("KeepAlive", (data) => …)` on the receiving side.

## Fields

| Field | Type | Notes |
|---|---|---|
| `keepAliveId` | Long |  |

## Send it

```ts
// Server side with autoKeepAlive: false.
const keepAliveId = BigInt(Date.now());
await client.sendPacket("KeepAlive", { keepAliveId });

client.on("KeepAlive", (data) => {
  if (data.keepAliveId !== keepAliveId) client.destroy();
});
```

The vanilla client disconnects after 20 seconds without a ping, and the server should drop clients that do not echo the ID within 30 seconds. With `autoKeepAlive: true` (the default) the server does all of this and emits `keepAlive` with the latency.

Field aliases listed under Notes are accepted as alternative keys when writing.

Source: [`src/Core/Versions/776/Packets/play/clientbound/KeepAlive.ts`](https://github.com/GDLev/mc-protocol/blob/master/src/Core/Versions/776/Packets/play/clientbound/KeepAlive.ts)
