Glossary · Subscriptions

KeepAliveCount

MaxKeepAliveCount is the number of publishing intervals a subscription may produce no notifications before the server sends an empty keep-alive message instead. It proves the subscription and the transport are alive when nothing has changed. LifetimeCount must be at least three times this value, and the server enforces that when it revises them.

The mechanics

The count is in publishing cycles, so the keep-alive period is MaxKeepAliveCount multiplied by RevisedPublishingInterval. The keep-alive is a normal Publish response with a sequence number and no notification data - it consumes one of your outstanding Publish requests, which is one more reason to keep a small pool rather than exactly one.

Choosing the value

A 1000 ms publishing interval with MaxKeepAliveCount 10 gives a liveness signal every 10 seconds - fast enough for an operator to notice a stall, cheap enough to ignore. Raising it to save traffic is usually a false economy: keep-alives are tiny, and the count is what pushes LifetimeCount up with it, silently extending how long a dead client's subscription occupies server resources.

Three keep-alives, three questions

The subscription keep-alive answers is this subscription still alive. The session keep-alive, a periodic ServerStatus read by the client, answers is this server still there. A data heartbeat answers is this particular value still being updated. They are independent, they fail independently, and a design that implements only one of them has a blind spot in the other two.

Example

A publishing cycle timeline with data and keep-alives

PublishingInterval 1000 ms   MaxKeepAliveCount 10   LifetimeCount 60

 t+0s    data notification   seq 41
 t+1s    (no change)
 ...
 t+11s   keep-alive          seq 42   empty NotificationData, 10 cycles after seq 41
 t+13s   data notification   seq 43

liveness signal at least every 10 s; subscription deleted after 60 s of no Publish
requests from the client.
The mistake people make: Raising MaxKeepAliveCount without re-checking LifetimeCount. The server revises the lifetime up to at least three times the new keep-alive count, so a client that quietly triples its keep-alive count also triples how long its abandoned subscriptions survive - and on a server near its subscription limit, that is what produces BadTooManySubscriptions after a series of client restarts.

Defined in: Part 4 - Services, CreateSubscription: RequestedMaxKeepAliveCount, RevisedMaxKeepAliveCount and the keep-alive NotificationMessage.

Last verified 7 September 2026 against OPC UA 1.05.07. OPC UA Connect is an educational resource and is not affiliated with the OPC Foundation.

Free download
OPC UA Server Acceptance Test Pack
A 40-check acceptance test you run against a vendor's server before commissioning sign-off. Weighted scoring, three hard gates, and a one-page verdict for the supplier meeting.
Get the free test pack →
Free, no course, no login