В момента ресурсът е наличен само на английски

MQTT Server

MQTT is a type of server which works like newspaper. You have publishers and subscribers, and the thing between them is the server.

  • #1020
  • 14 Dec 2018

TL.DR


Now, when we know what is client-server model we can talk about the functions of the server and those of the clients.
 

Functions and communications of the Server and the Client

Before creating a server we must carefully consider what we actually want this server to do.  Sometimes we want simple things like receiving some messages, parsing them and sending back result or another message. In other cases we want our server to do more complicated things like sending requests to another server, or to run some kind of service that will do some communication and have to send the result back to the client. The most important things of the server are to be stable, to be secure and to have ability to manage many connections from different clients.


For easier communication the messages between server and client are send in strictly typed format and specific rules. These rules are discribed in something called Protocol. The Protocol is a set of rules which describes how the communication between client and server happens. One of the responsibilities of the client is to send correct messages/requests. 

As we said there are different functions that servers can do, respectively the communication Protocol is different and clients will send and receive messages in different format.

 

MQTT Server

MQTT is one of the servers that you can easily run and communicate. The model of work is little bit like a newspaper. And the clients can perform two different roles. The first one is called "publisher" and the second "subscriber". Every message which is send or read from the server must have a "topic". Something like different pages in newspapers, like the sport pages or those with tv schedule. So every message must have "topic" and "payload". The payload is actually the message you want to send. Of course there are set of function which server provides like supporting some kind of log messages, different loops and callbacks. Actually the server has no active functions, he only receive messages in some buffer. And because of that we can say that this server is a little bit passive.

MQTT Client

As we said there are two roles that can be performed "Publisher" and "Subscriber".
When the client is a "Publisher" it send/post messages to the server. He post a payload on some topic. From the othrer side when the client is "Subscriber", he subscribes for a topic. And when some messsage is posted on this topic the subscriber receives it. Of course he can subscribe to more than one topic. Also, the subscriber can wait and receive/read only one message, or if he uses some loops he can read all of them. There is also another option when the client wants to communicate with another client, he has to be "Publisher" and "Subscriber" in  the same time. Is it possible? Yes, it is. It's just about some additional lines of code.

 

Where MQTT servers are used ?

Mostly the MQTT's are used in the "Smart House" projects. They are perfect for this, because the user can easily communicate with the devices at his home. For example he can post/send message which starts the air conditioner for example, 20 min before he gets back at home. Or at the morning he can put something in the stove and start baking it minutes before he gets home, so he will have а warm dinner.

 

 

 

 

Курсове и занятия включващи този Урок

Този Урок е използван в следните курсове и занятия.

Image for Perfect STEM course. Module 2 - 1D Games with Led strip.
  • 19
  • 0:00
  • 37
Image for MQTT Server
  • 1
  • 0
  • 0
  • 3d_rotation 0