Skip to main content

Wykrywanie utraty połączenia HMI z brokerem MQTT

Streszczenie: Jak subskrybent MQTT może wykryć utratę połączenia HMI z brokerem: subskrypcja tematu statusu iot-2/type/mt/id/<Registration ID>/evt/status/fmt/json; po rozłączeniu broker wysyła wiadomość „last will”.
EN: How an MQTT subscriber detects that a Weintek HMI lost its broker connection using the status topic and last will message.

Dotyczy: panele HMI Weintek z funkcją MQTT (publisher)
Źródło: Weintek FAQ (materiały producenta), oryginalny tytuł: „How to know the HMI loses the connection with the MQTT broker?”

If HMI is a MQTT publisher, how can the subscriber know when does the HMI lose the connection with the broker? When the HMI connects with the broker for the first time, it will send an initial topic, which is the HMI’s connection status. The subscriber can then subscribe to this topic to know whether the connection is lost.

 

Subscribe the following topic: 
iot-2/type/mt/id//evt/status/fmt/json
The is the [Registration ID] of each HMI. Use MQTT.fx as the subscriber example:

Ilustracja: Wykrywanie utraty połączenia HMI z brokerem MQTT – Use MQTT.fx as the subscriber example:

By subscribing this topic, the subscriber will receive the following text message: 

Ilustracja: Wykrywanie utraty połączenia HMI z brokerem MQTT – By subscribing this topic, the subscriber will receive the following text message:

When the HMI loses the connection with the MQTT broker, the subscriber will receive the “last will” message as follows:

Ilustracja: Wykrywanie utraty połączenia HMI z brokerem MQTT – When the HMI loses the connection with the MQTT broker, the subscriber will receive the “last will” message as follows:

 

Słowa kluczowe

MQTT, utrata połączenia, connection lost, status, last will, LWT, broker, Registration ID, MQTT.fx, iot-2, JSON, How to know the HMI loses the connection with the MQTT broker?