当前位置:网站首页>Learning Tai Chi Maker - mqtt Chapter II (VI) mqtt wills
Learning Tai Chi Maker - mqtt Chapter II (VI) mqtt wills
2022-06-28 04:55:00 【xuechanba】
Video link : https://www.bilibili.com/video/BV1B54y1t7j5/?spm_id_from=autoNext&vd_source=b91967c499b23106586d7aa35af46413
The data link :http://www.taichi-maker.com/homepage/esp8266-nodemcu-iot/iot-tuttorial/mqtt-tutorial/mqtt-last-will/


When the client disconnects normally , Will send to the server DISCONNECT message , After the server receives the message , You know , The client is disconnected normally , Instead of accidentally disconnecting .

However , When the server does not receive DISCONNECT In the case of messages , Discover clients “ heartbeat ” Stopped. , At this time, the server knows that the client is disconnected accidentally .
Give another example through the client software :
When connected normally ,

When you click Disconnect after , This is software ( client ) Will go to MQTT Server sends a DISCONNECT Data packets , In this case , The server knows that the client is disconnected normally . However , If I close the software directly or the computer shuts down accidentally , here , Software ( client ) I won't go to MQTT Server send DISCONNECT Data packets , That is to say, as long as the client does not MQTT Server send DISCONNECT Data packets , This is an accidental disconnection .

( Only clients that have subscribed to the will can receive the will information when the published client accidentally disconnects .)
1、 How the client sends the will message to the server


Pass below MQTT.fx This software is used to operate how to use MQTT will ,
First , Click on the gear



After setting up , Click on OK , It's set up .
below , Let's open another one MQTT.fx Software , Subscribe to the topics published by the above client as a client , But there is a very important step , That's it
1、 Delete the contents of the will set before , Because it is subscribed as a client , So there is no need for these contents .

2、 Click regenerate Client ID, It's very important .

after , Click on OK, It's set up .

Now? , We accidentally disconnected the client that issued the will ( Close the software directly ), See what happens .

If the will retention information is checked , What kind of result will happen ?
First open a software and set it ,

Open another software ( It is the same as the setting for opening another software mentioned above )
after , We accidentally disconnected the client that issued the will ( Close the software directly ), See what happens .
Will also receive information about wills .
Now? , Open another software ( The settings are the same , Mainly regenerate ClientID), Then click to subscribe to the will topic .
You will find that you have received the will information immediately .

And if the connection was normally disconnected before ?
When the connection is normally disconnected, it will not send , When other clients subscribe to the will information , I will receive the reserved wills immediately , Instead of waiting until you accidentally disconnect .
Last , Let's talk about it MQTT Will operation suggestions

( How to demonstrate , I'll introduce it later )
边栏推荐
- UI自动化测试框架搭建 —— 编写一个APP自动化
- CUPTI error: CUPTI could not be loaded or symbol could not be found.
- Are test / development programmers really young? The world is fair. We all speak by strength
- Binary sort tree: BST
- UI automation test framework construction - write an app automation
- 100+ data science interview questions and answers Summary - machine learning and deep learning
- On the necessity of building a video surveillance convergence platform and its scenario application
- [applet] solution document using font awesome Font Icon (picture and text)
- Pager when importing text files from MySQL
- Role of native keyword
猜你喜欢
随机推荐
Bitlock recovery occurs in win 10, and the blue screen error code is 0x1600007e
CI & CD must be known!
几百行代码实现一个脚本解释器
What to do when MySQL changes the password and reports an error
UI自动化测试框架搭建 —— 编写一个APP自动化
Congratulations to myself, official account has more than ten thousand fans
openssl客户端编程:一个不起眼的函数导致的SSL会话失败问题
RxSwift --(1)创建一个项目
Google Earth Engine(GEE)——全球洪水数据库 v1 (2000-2018年)
lotus v1.16.0 calibnet
Matlab exercises -- exercises related to symbolic operation
Feign通过自定义注解实现路径的转义
Pager when importing text files from MySQL
[applet] solution document using font awesome Font Icon (picture and text)
Mise en place d'un cadre d'essai d'automatisation de l'interface utilisateur - - rédaction d'une application d'automatisation
quartus 复制IP核
多线程实现 重写run(),怎么注入使用mapper文件操作数据库
深度强化学习笔记
How to clean the nozzle of Epson l3153 printer
[Matlab bp regression prediction] GA Optimized BP regression prediction (including comparison before optimization) [including source code 1901]









