PINGREQ
Fixed header flags: 0000 – all flags reserved
PINGREQ is a keep-alive heartbeat sent by the client. The client must send PINGREQ within the Keep Alive interval defined in CONNECT (in seconds). If the broker receives no packets from the client within 1.5× the Keep Alive time, it closes the connection. PINGREQ has no payload and no variable header – it is exactly 2 bytes: 0xC0 0x00.
Details
PINGREQ serves three purposes: 1. Confirms the network connection is alive (no data was needed during the keep-alive window) 2. Tells the broker the client is still active 3. Prevents firewalls and NAT devices from timing out idle TCP connections
The packet is exactly 2 bytes: fixed header 0xC0 and remaining length 0x00. No variable header, no payload.
Keep Alive = 0 in CONNECT means the client is not required to send PINGREQ. The broker will not disconnect the client based on inactivity. This is appropriate for always-on, high-frequency publishers but increases broker memory usage.
Typical Keep Alive values: 60 seconds for constrained IoT devices, 30 seconds for mobile clients on unreliable networks, 0 for local broker connections.
Fixed Header
| Field | Value |
|---|---|
| Packet type (bits 7–4) | 12 (1100₂) |
| First byte (hex) | 0xC0 |
| Flags (bits 3–0) | 0000 – all flags reserved |
| QoS bits apply | No |
| Direction | client-to-server |
| Added in | MQTT 3.1 |