The application provides a kind of data offline synchronization method based on
MQTT protocol
client and
server, it is related to
information technology field, including that
client and
server establish
MQTT long connection;
Client encapsulates message synchronization interface, and judges current network state in interface, if network is unobstructed, go online mode, if network is not connected, go offline mode;In online mode, data is directly synchronized to
server through
MQTT connection;In offline mode,
client first caches synchronization data, and checks network state regularly, when network recovers, immediately start synchronization task;
Server receives message, and parses data according to
message type and handles it.The application can be applied in places with good network environment such as shopping mall, office building, street, etc., and also can be applied in places with poor network environment such as field, mountainous area,
jungle, etc., with wider application scenarios.Using the characteristics of MQTT publishing and subscribing, when a large amount of data is used, the server can process data
on demand, reduce the pressure on the service, and improve the stability of the service.