Skip to main content
Skip table of contents

Configuration оf Webhook and notification events

Configuration of Webhook and notification events

To ensure the system maintains high efficiency and is capable of handling the intensive data stream load, it is crucial to optimize the event processing capabilities. This is particularly important as Mediaserver tends to generate a substantial volume of events at the start and conclusion of operations. A system that is not optimized for such a load may experience a decline in service quality or a complete stop.

Webhooks enable an external service to be notified about events within Mediaserver operations or changes in the state of streams. These notifications are dispatched as packages, with each request containing up to 50 events. There is a limit of 5000 events in the queue for dispatching. If the limit is exceeded, the oldest events will be ignored. The event format application/json is typically as follows:

JSON
{
    "event": "An event type, see below",
    "device": "mediaserver",
    "server": "host name of a mediaserver",
    "pid": 1234,
    "timestamp": 12345,
    "seq": 1,
    "data": "Contains additional information about an event"
}

The section to configure Webhook in server.json

dsn cluster.webhook "http://localhost:8080/event/" – a server URL that will receive events. The webhook functionality won’t be available without defining a URL or when it’s wrong.


array cluster.events – an array of event identifiers that can be sent. If not specified or empty, all events are sent.

The details on the event types are below in the table.

JSON
{
    "cluster": {
        "webhook": "http://localhost:8080/event/",
        "events": []
    }
}

Event types

service:up – indicates that the service configuration has been successfully accepted and that all services are functioning correctly.

service:up
JSON
{
    "data": {
        "at": 1706626775,
        "pid": 533277
    },
    "device": "mediaserver",
    "event": "service:up",
    "pid": 533277,
    "seq": 1324967661364755,
    "server": "ms-test-dev1",
    "timestamp": 1706626775
}

service:down – signifies that the service has received a shutdown signal and is in the process of attempting to cease operations properly, although this event may not always be issued.

service:down
JSON
{
    "data": {
        "at": 1706624875,
        "pid": 533277
    },
    "device": "mediaserver",
    "event": "service:down",
    "pid": 533277,
    "seq": 1324967661364755,
    "server": "ms-test-dev1",
    "timestamp": 1706624875
}

service:pulse – the service is currently operational. The event is sent every 60 seconds.

service:puls
JSON
{
    "data": {
        "at": 1706627715,
        "pid": 533643
    },
    "device": "mediaserver",
    "event": "service:pulse",
    "pid": 533643,
    "seq": 1325847587881315,
    "server": "ms-test-dev1",
    "timestamp": 1706627715
}

service:emergency – a critical event related to the failure of one of the services or the runtime environment occurred.

stream:create – Mediaserver created a stream. The event takes place when a stream is added.

stream:create
JSON
{
    "data": {
        "access": "public",
        "address": "192.168.204.10",
        "camera": "camera-uid5065687",
        "dvr": false,
        "enable": true,
        "kind": "primary",
        "reconnects": {
            "attempt": 0,
            "limit": 10,
            "total": 0
        },
        "source": "rtsp://192.168.204.10/Streaming/Channels/101/",
        "state": "active",
        "stime": 1706627843,
        "subscribers": 1,
        "type": "capture",
        "uid": "camera-uid5065687-primary",
        "video": {
            "bitrate": 0,
            "codec": "H265",
            "fps": 0
        }
    },
    "device": "mediaserver",
    "event": "stream:create",
    "pid": 533735,
    "seq": 1326036436599590,
    "server": "ms-test-dev1",
    "timestamp": 1706627843
}

stream:pulse – a stream is successfully captured. The event is sent with the frequency of sending the PINGcommand to the camera.

stream:pulse
JSON
{
    "data": {
        "access": "public",
        "address": "192.168.204.10",
        "camera": "camera-uid5065687",
        "dvr": false,
        "enable": true,
        "kind": "primary",
        "reconnects": {
            "attempt": 0,
            "limit": 10,
            "total": 0
        },
        "source": "rtsp://192.168.204.10/Streaming/Channels/101/",
        "state": "active",
        "stime": 1706627843,
        "subscribers": 1,
        "type": "capture",
        "uid": "camera-uid5065687-primary",
        "video": {
            "bitrate": 3383431,
            "codec": "H265",
            "fps": 75
        }
    },
    "device": "mediaserver",
    "event": "stream:pulse",
    "pid": 533735,
    "seq": 1326036436599594,
    "server": "ms-test-dev1",
    "timestamp": 1706627933
}

stream:reconnect – Mediaserver is attempting to reconnect to a stream.

stream:reconnect
JSON
{
    "data": {
        "access": "public",
        "address": "192.168.204.10",
        "camera": "camera-uid5065687",
        "dvr": false,
        "enable": true,
        "kind": "primary",
        "reconnects": {
            "attempt": 0,
            "limit": 10,
            "total": 0
        },
        "source": "rtsp://192.168.204.10/Streaming/Channels/101/",
        "state": "active",
        "stime": 1706627843,
        "subscribers": 1,
        "type": "capture",
        "uid": "camera-uid5065687-primary",
        "video": {
            "bitrate": 3383431,
            "codec": "H265",
            "fps": 75
        }
    },
    "device": "mediaserver",
    "event": "stream:reconnect",
    "pid": 533735,
    "seq": 1326036436599594,
    "server": "ms-test-dev1",
    "timestamp": 1706627933
}

stream:state –an event occurs when a stream status is updated.

stream:state
JSON
{
    "data": {
        "access": "public",
        "address": "192.168.204.10",
        "camera": "camera-uid5065687",
        "dvr": false,
        "enable": true,
        "kind": "primary",
        "reconnects": {
            "attempt": 0,
            "limit": 10,
            "total": 0
        },
        "source": "rtsp://192.168.204.10/Streaming/Channels/101/",
        "state": "active",
        "stime": 1706627843,
        "subscribers": 1,
        "type": "capture",
        "uid": "camera-uid5065687-primary",
        "video": {
            "bitrate": 3383431,
            "codec": "H265",
            "fps": 75
        }
    },
    "device": "mediaserver",
    "event": "stream:state",
    "pid": 533735,
    "seq": 1326036436599594,
    "server": "ms-test-dev1",
    "timestamp": 1706627933
}

stream:delete – an event occurs when a stream is deleted.

stream:delete
JSON
{
    "data": {
        "access": "public",
        "address": "192.168.204.10",
        "camera": "camera-uid5065687",
        "dvr": false,
        "enable": true,
        "kind": "primary",
        "reconnects": {
            "attempt": 0,
            "limit": 10,
            "total": 0
        },
        "source": "rtsp://192.168.204.10/Streaming/Channels/101/",
        "state": "active",
        "stime": 1706627843,
        "subscribers": 1,
        "type": "capture",
        "uid": "camera-uid5065687-primary",
        "video": {
            "bitrate": 3383431,
            "codec": "H265",
            "fps": 75
        }
    },
    "device": "mediaserver",
    "event": "stream:state",
    "pid": 533735,
    "seq": 1326036436599594,
    "server": "ms-test-dev1",
    "timestamp": 1706627933
}

stream:dvr – an event with regard to ranges of a DVR stream. An event occurs when a new range appears.

stream:dvr
JSON
{
    "access": "public",
    "address": "192.168.204.10",
    "atime": 1709713661,
    "camera": "camera-uid5065687",
    "ctime": 1709713539,
    "dvr": {
        "range": {
            "from": 1709713539,
            "size": 36967784,
            "to": 1709713659,
            "type": "regular"
        }
    },
    "error": {
        "msg": "",
        "no": 0
    },
    "source": "rtsp://192.168.204.10/Streaming/Channels/101/",
    "state": "active",
    "stime": 1709713539,
    "type": "capture",
    "uid": "camera-uid5065687-primary"
}

server:capture – an event of captured server streams.

server:capture
JSON
{
    "data": {
        "ms-test-dev1.navek.dev": [
            "camera-uid8672832-primary",
            "camera-uid8672833-primary"
        ]
    },
    "device": "mediaserver",
    "event": "server:capture",
    "pid": 534459,
    "seq": 1326626505543974,
    "server": "ms-test-dev1",
    "timestamp": 1706628543
}

server:release – an event that signals about the end of the secondary streams capturing.

server:release
JSON
{
    "data": {
        "ms-test-dev1.navek.dev": [
            "camera-uid8672832-primary",
            "camera-uid8672833-primary"
        ]
    },
    "device": "mediaserver",
    "event": "server:release",
    "pid": 534459,
    "seq": 1326626505543974,
    "server": "ms-test-dev1",
    "timestamp": 1706628543
}

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.