Detect if agent is unable to upload data

Q: How can I detect if the agent is not able to upload data?


The following script checks the agent's connection to the server:

import time
from formant.sdk.agent.v1 import Client as FormantClient


def handle_telemetry(datapoint):
    if datapoint.datapoint.health.status == 2:
        print("Agent cannot reach server")
    if datapoint.datapoint.health.status == 1:
        print("Agent can reach server")



if __name__ == "__main__":
    fclient = FormantClient(ignore_throttled=True, ignore_unavailable=True)

    fclient.register_telemetry_listener_callback(
        handle_telemetry, stream_filter=["$.agent.health"]
    )

    while True:
        time.sleep(10)