# Online and Offline notification

EMQ X online and offline system message notification function automatically sends a system topic message when the client connection is successful or the client is disconnected, and EMQ X turns on the online and offline notification module by default.

# Create module

The online and offline notification module is started by default and can be started and stopped through the dashboard page.

Open EMQ X Dashboard (opens new window), click the "Modules" tab on the left:

image-20200927213049265

Select the online and offline notification module

image-20200927213049265

There is no need to configure any parameters for the online and offline notification. After you click Add directly, the module is added.

image-20200927213049265

# Online and offline message notification format

$SYS Subject prefix: $SYS/brokers/${node}/clients/

| Topic | Description | | ------------------------ | ------------------------ ---------------- | | ${clientid}/connected | Online event. When any client goes online, EMQ X will publish a message on that topic | | ${clientid}/disconnected | Offline event. When any client goes offline, EMQ X will publish a message on that topic |

The Payload of the connected event message is parsed into JSON format as follows:

{
    "username": "foo",
    "ts": 1625572213873,
    "sockport": 1883,
    "proto_ver": 4,
    "proto_name": "MQTT",
    "keepalive": 60,
    "ipaddress": "127.0.0.1",
    "expiry_interval": 0,
    "connected_at": 1625572213873,
    "connack": 0,
    "clientid": "emqtt-8348fe27a87976ad4db3",
    "clean_start": true
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

The Payload of the disconnected event message is parsed into JSON format as follows:

{
    "username": "foo",
    "ts": 1625572213873,
    "sockport": 1883,
    "reason": "tcp_closed",
    "proto_ver": 4,
    "proto_name": "MQTT",
    "ipaddress": "127.0.0.1",
    "disconnected_at": 1625572213873,
    "clientid": "emqtt-8348fe27a87976ad4db3"
}
1
2
3
4
5
6
7
8
9
10
11