Connection monitor
The quality of a connection can be monitored by making use of the connectionMonitor service. The methods provided by this service enable the retrieval of a connector's current status. This information can be used to diagnose issues caused by poor connections, or to confirm the stability of the connection before proceeding.
Retrieving ConnectorInformation messages
The connectionMonitor service offers two methods with which ConnectorInformation messages can be retrieved.
The first method is getConnectorInformation
, which returns a single ConnectorInformation message, representing the status of the connector at the time of the request.
The second method, openConnectorInformationStream
, opens an incoming stream which will return a ConnectorInformation message each second.
A ConnectorInformation message contains the following fields:
Field | Description |
---|---|
connected |
A boolean indicating whether the connector has an active internet connection. |
connected_since |
The unix timestamp in milliseconds indicating when the connector last established a connection (e.g. 1721649049837). |
latency |
A measurement of the time in milliseconds it takes for data to travel to the connector and back. |
healthy |
A boolean indicating the likelihood of potential issues arising from a poor connection. |
The healthy
field serves as an estimate of a connection's quality, and might therefore not be a suitable indicator in all circumstances.
The value of the healthy
field is determined by evaluating the number of the last 10 latency
values that exceed 500 ms, with recent measurements given greater weight.
If less than 25% of these weighted measurements exceed 500 ms, the healthy
field will be set to true.
If this estimate is insufficient for an application, a more suitable indicator can be calculated with the measurements provided by the ConnectorInformation messages.
Note
The latency
field of a ConnectorInformation message is only updated when the value changes by more than 50 ms.