CN109347929B - Heartbeat simulation detection method and device based on lightweight interface and storage medium - Google Patents

Heartbeat simulation detection method and device based on lightweight interface and storage medium Download PDF

Info

Publication number
CN109347929B
CN109347929B CN201811131060.1A CN201811131060A CN109347929B CN 109347929 B CN109347929 B CN 109347929B CN 201811131060 A CN201811131060 A CN 201811131060A CN 109347929 B CN109347929 B CN 109347929B
Authority
CN
China
Prior art keywords
interface
communication interface
lightweight
communication
version number
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811131060.1A
Other languages
Chinese (zh)
Other versions
CN109347929A (en
Inventor
南强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN201811131060.1A priority Critical patent/CN109347929B/en
Publication of CN109347929A publication Critical patent/CN109347929A/en
Application granted granted Critical
Publication of CN109347929B publication Critical patent/CN109347929B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/535Tracking the activity of the user
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/10Active monitoring, e.g. heartbeat, ping or trace-route
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/34Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters 
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention discloses a heartbeat simulation detection method and device based on a lightweight interface, comprising the following steps: acquiring a detection instruction, carrying out polling detection on a communication interface of a server side by adopting a lightweight interface according to the detection instruction, and acquiring result information obtained by detection, wherein the communication interface comprises an interface for the mutual communication between a client side and the server side; judging whether the functional module corresponding to the communication interface has data update or not according to the result information; if the communication interface with the data update is detected, the server side is connected and communicated with the client side mapped by the communication interface so as to send the updated data to the client side for data update. The invention adopts the lightweight interface to carry out polling detection, thereby greatly saving the communication time, reducing the labor development cost aiming at the program itself, and being capable of rapidly and accurately acquiring the changed data relative to the detection communication mode of the server and the client through long connection, ensuring the operation speed of the whole communication architecture to be faster and ensuring the accurate real-time updating.

Description

Heartbeat simulation detection method and device based on lightweight interface and storage medium
Technical Field
The invention relates to the technical field of software systems, in particular to a heartbeat simulation detection method and device based on a lightweight interface, computer equipment and a storage medium.
Background
With the development of the internet, the use of terminals is more and more frequent. The use of the terminal requires support by the background server, i.e. the terminal needs to communicate with the background time. In the prior art, a heartbeat mechanism is adopted to judge whether communication exists between the terminal and the background server. The heartbeat mechanism is a mechanism for periodically sending a self-defined structure body (heartbeat package) to enable the opposite party to know that the opposite party is still alive so as to ensure the validity of the connection. With long connections, there may be a long period of time when no data is going to or from. Theoretically, this connection is kept connected all the time, but in practice it is difficult to know if an intermediate node has failed. More importantly, some nodes (e.g., firewalls) automatically disconnect connections that have no data interaction for a certain period of time. At this time, our heartbeat is required to be wrapped for maintaining long connections, keep alive.
There are generally two techniques for sending the heartbeat packet:
1. The application layer implements the heartbeat packet itself. The application program sends a heartbeat packet to detect whether the connection is normal or not, the server sends a short data packet to the client at intervals of a certain time, then starts a thread, continuously detects the response of the client in the thread, and considers that the client is disconnected if the response of the client is not received within a certain time; also, if the client does not receive the server's heartbeat packet within a certain time, the connection is deemed unavailable.
2. An so_keyalive socket option is used. In the mechanism of TCP, there is a mechanism of heartbeat package, namely, the option of TCP, whether it is a service end or a client end, after one side opens the KeepAlive function, it will automatically send heartbeat package to the other side in a set time, and the other side will automatically reply after receiving the heartbeat package, to tell the other side that I are still online. Since turning on KeepAlive functions requires additional bandwidth and traffic, the TCP protocol layer defaults to not turning on default KeepAlive. Although this is trivial, the cost is increased in a per-flow charging environment, on the other hand, keep alive setup is not reasonable and may disconnect healthy TCP connections due to short network fluctuations. Also, a default KeepAlive timeout requires 7,200,000 MilliSeconds, i.e., 2 hours, for 5 probing times. For many server applications, the 2 hour idle time is too long. Therefore, we need to manually turn on KeepAlive functions and set reasonable KeepAlive parameters.
One server typically connects multiple clients, so the heartbeat package is implemented by the user at the application layer itself, with more code and less complexity. The implementation of the heartbeat function is much simpler with the TCP/IP protocol layer being a built-in KeepAlive function. However, TCP must send a keep-alive detection segment 2 hours after the connection is idle, so the usual approach is to change the keep-alive parameters to be small, but these parameters are maintained per kernel rather than per socket, so changing them affects all sockets that open the option.
In the whole, whether the terminal is communicated with the background server is detected in a long connection mode, and the mode is complex in technology and more in development and maintenance labor cost than the traditional mode.
Disclosure of Invention
The present invention aims to solve at least one of the above technical drawbacks, and in particular, to a detection method capable of quickly and accurately acquiring changed data and saving communication time.
The invention discloses a heartbeat simulation detection method based on a lightweight interface, which comprises the following steps:
acquiring a detection instruction, carrying out polling detection on a communication interface of the server side by adopting a lightweight interface according to the detection instruction, and acquiring result information obtained by detection, wherein the communication interface comprises an interface for the mutual communication between a client side and the server side;
Judging whether the functional module corresponding to the communication interface has data update or not according to the result information;
if the communication interface with the data update is detected, the server side is connected and communicated with the client side mapped by the communication interface, so that updated data is sent to the client side for data update.
Further, the method for judging whether the data update exists in the functional module corresponding to the communication interface according to the result information includes:
acquiring an original version number of the communication interface, and defining that the version number changes according to a preset rule when the communication interface has data changes;
acquiring a real-time version number of the communication interface by adopting a polling mode through a lightweight interface;
and judging whether the original version number and the real-time version number change or not, and generating result information by a judging structure.
Further, the lightweight interface periodically detects the communication interface according to a first preset time period.
Further, the preset rule includes:
the original version number is a row number value of the communication interface file;
the number of lines of the communication interface file varies, and the original version number also varies.
Further, the preset rule includes:
polling a communication interface file in the communication interface;
when detecting that the content in the communication interface file changes, the version number of the communication interface changes on the basis of the previous version number.
Further, the method further comprises the following steps:
monitoring a first frequency of connection communication between the server and the client in a second preset time period in real time;
and detecting the communication interface according to a third preset time period when the first frequency is greater than or equal to the second frequency.
Further, the third preset time period is longer than the first preset time period.
The invention also discloses a heartbeat simulation detection device based on the lightweight interface, which comprises:
the acquisition module is used for: the method comprises the steps that a detection instruction is obtained, a lightweight interface is adopted to carry out polling detection on a communication interface of a server side according to the detection instruction, result information obtained by detection is obtained, and the communication interface comprises an interface for mutual communication between a client side and the server side;
the processing module is used for: the function module is used for judging whether the data update exists in the function module corresponding to the communication interface or not according to the result information;
The execution module: and the server side is used for executing connection communication with the client side mapped by the communication interface if the communication interface with the data update is detected, so as to send the updated data to the client side for data update.
Further, the method further comprises the following steps:
a first acquisition sub-module: the method comprises the steps of obtaining an original version number of the communication interface, and defining that the version number is changed according to a preset rule when the communication interface has data change;
and a second acquisition sub-module: the method comprises the steps of acquiring a real-time version number of a communication interface in a polling mode through a lightweight interface;
a first judging sub-module: and the method is used for judging whether the original version number and the real-time version number change or not, and generating result information by the judging structure.
Further, the lightweight interface periodically detects the communication interface according to a first preset time period.
Further, the preset rule includes:
the original version number is a row number value of the communication interface file;
the number of lines of the communication interface file varies, and the original version number also varies.
Further, the preset rule includes:
polling a communication interface file in the communication interface;
When detecting that the content in the communication interface file changes, the version number of the communication interface is increased by a fixed value.
Further, the method further comprises the following steps:
a first monitoring sub-module: the method comprises the steps that in a second preset time period, a first frequency of connection communication between the server and the client is monitored in real time;
a first processing sub-module: and the communication interface is used for detecting the communication interface according to a third preset time period when the first frequency is greater than or equal to the second frequency.
Further, the third preset time period is longer than the first preset time period.
The invention also discloses a computer device, which comprises a memory and a processor, wherein the memory stores computer readable instructions, and the computer readable instructions, when executed by the processor, cause the processor to execute the steps of the heartbeat simulation detection method based on the lightweight interface.
The invention also discloses a storage medium storing computer readable instructions which, when executed by one or more processors, cause the one or more processors to perform the steps of the lightweight interface-based heartbeat simulation detection method as set forth in any one of the above.
The beneficial effects of the invention are as follows:
1) The lightweight interface is adopted as the polling device, so that the communication time can be greatly saved, and the manpower development cost for the program is reduced;
2) The invention can acquire changed data more quickly and accurately, so that the running speed of the whole communication architecture is faster, and the real-time updating is ensured to be accurately carried out;
3) The running flow is reduced because the server side and the client side do not need to be connected in real time.
Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention.
Drawings
The foregoing and/or additional aspects and advantages of the invention will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings, in which:
FIG. 1 is a flow chart of a method for simulated detection of heartbeat based on a lightweight interface in accordance with the present invention;
FIG. 2 is a flow chart of a method of the present invention for polling result information via a lightweight interface;
FIG. 3 is a schematic diagram of a device module for heartbeat simulation detection based on a lightweight interface;
fig. 4 is a basic structural block diagram of the computer device of the present invention.
Detailed Description
Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to like or similar elements or elements having like or similar functions throughout. The embodiments described below by referring to the drawings are illustrative only and are not to be construed as limiting the invention.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless expressly stated otherwise, as understood by those skilled in the art. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. The term "and/or" as used herein includes all or any element and all combination of one or more of the associated listed items.
It will be understood by those skilled in the art that all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs unless defined otherwise. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
As used herein, a "terminal" includes both a device of a wireless signal receiver having no transmitting capability and a device of receiving and transmitting hardware having receiving and transmitting hardware capable of performing bi-directional communications over a bi-directional communication link, as will be appreciated by those skilled in the art. Such a device may include: a cellular or other communication device having a single-line display or a multi-line display or a cellular or other communication device without a multi-line display; a PCS (Personal Communications Service, personal communication system) that may combine voice, data processing, facsimile and/or data communication capabilities; a PDA (Personal Digital Assistant ) that can include a radio frequency receiver, pager, internet/intranet access, web browser, notepad, calendar and/or GPS (Global Positioning System ) receiver; a conventional laptop and/or palmtop computer or other appliance that has and/or includes a radio frequency receiver. As used herein, "terminal," "terminal device" may be portable, transportable, installed in a vehicle (aeronautical, maritime, and/or land-based), or adapted and/or configured to operate locally and/or in a distributed fashion, to operate at any other location(s) on earth and/or in space. The "terminal" and "terminal device" used herein may also be a communication terminal, a network access terminal, and a music/video playing terminal, for example, may be a PDA, a MID (Mobile Internet Device ), and/or a mobile phone with a music/video playing function, and may also be a smart tv, a set top box, and other devices.
In order to enable any person to remotely control a device for travelling and execute a shooting function to realize the purpose of viewing a shot image in real time, the application provides a heartbeat simulation detection method based on a lightweight interface, wherein when the method is used in an application scene of remotely viewing a house, the heartbeat simulation detection method based on the lightweight interface at least comprises two terminals, one is a remote terminal for viewing the image and a control state by a user and a remote terminal for sending a control command, the remote terminal can be a computer, a notebook, a mobile phone or other terminals, and the unmanned equipment can be a robot or an unmanned equipment such as a remote control car. And the other is an unmanned device that is controlled to move and to be able to perform the relevant shooting actions. The remote communication between the two is realized, the unmanned equipment analyzes and judges the sent related instruction according to the motion state of the unmanned equipment, and executes or prohibits the first state instruction, so that the purpose of remotely controlling and watching rooms is achieved, meanwhile, the unmanned equipment has an automatic obstacle avoidance function, the intelligent degree is high, and the control mode is simple.
The application discloses a heartbeat simulation detection method based on a lightweight interface, which is further described with reference to fig. 1, and the heartbeat simulation detection method comprises the following steps:
S100, acquiring a detection instruction, carrying out polling detection on a communication interface of the server side by adopting a lightweight interface according to the detection instruction, and acquiring result information obtained by detection, wherein the communication interface comprises an interface for the mutual communication between a client side and the server side;
the lightweight interface is an interface mode designed by adopting a lightweight framework, the lightweight framework does not have aggressive API, and the lightweight framework has no dependency on a container, is easy to configure, is easy to be universal, and has short starting time. This is an advantage of a lightweight frame over a heavy frame. It is an advantage of this application that a lightweight interface is used to poll the communication interfaces of the client and server to quickly obtain the changed data.
The lightweight interface mentioned in the application is equivalent to the heartbeat packet in the heartbeat packet mechanism of long connection, the heartbeat packet can be sent at regular time, and the lightweight interface program is a specific program, so that each data interface can be directly monitored. The method for detecting the data interface program adopts a lightweight interface mode, so that the running load of the whole program is not increased, and the monitoring process is faster.
The lightweight interface for detection in the application can poll different interfaces on the server and the client, and the establishment process of the polling mechanism can be referred as follows:
Firstly, a poller is established through a lightweight interface so that the lightweight interface polls the different communication interfaces, then, an item is established, and specific polling rules are covered in the item content to acquire a polling result and generate polling result information. And after the polling device is started, the polling device based on the lightweight interface polls the communication interface according to a preset polling rule until the polling is finished and returns.
S200, judging whether the functional module corresponding to the communication interface has data update or not according to the result information;
in the step S100, the lightweight interfaces are used to poll the communication interfaces, and the polling process is performed according to a preset rule, so that a piece of result information about the polling of the communication interfaces can be generated by polling.
The communication interface is used for communication, so that when the data in the functional module corresponding to the communication interface changes, the data can directly act on the communication interface, and the change of the data can be detected through the communication interface. In the application, the condition of data change is obtained by directly detecting different communication interfaces by adopting a lightweight interface, so that the polling result information in the application is whether the function module corresponding to the communication interface monitored by the detected communication interface has data change or not.
And S300, detecting a communication interface with data update, and connecting and communicating the server side with the client side mapped by the communication interface to send updated data to the client side for data update.
In step S200, it is determined whether there is a change in the communication interface, which one of the changed communication interfaces is the one of the clients mapped by the communication interface, and by using the result information, the server side can perform connection communication with the corresponding client via the corresponding communication interface, and the server side can transmit the changed data to the client for connection communication. And when no updated data exists on the corresponding communication interface, continuing to poll according to a preset rule.
According to the application, the lightweight interface is adopted as the polling device, so that the communication time can be greatly saved, and the manpower development cost for the program is reduced. And the communication interface on the server side is detected only by the mode of interface polling detection so as to judge whether data updating is needed, and compared with the mode of detecting communication by long connection between the server and the client side, the scheme of the application can rapidly and accurately acquire changed data, ensures that the operation speed of the whole communication architecture is faster, and ensures that the real-time updating is accurately carried out. Meanwhile, the server side and the client side do not need to be connected in real time, so that the running flow is reduced.
Furthermore, the application discloses a method for detecting whether the communication interface has data update by adopting a light-weight interface, namely, a version number is set for the communication interface, the version number is related to the information of the functional module mapped by the communication interface, when the related information of the functional module has data change, the number of the version number also changes according to a certain preset rule, so that whether the version number corresponding to the communication interface changes or not is only compared, and whether the functional module corresponding to the communication interface has data update or not can be judged.
Specifically, referring to fig. 2, the method for determining whether there is data update in the functional module corresponding to the communication interface according to the result information in the present application includes:
s110, acquiring an original version number of the communication interface, and defining that the version number is changed according to a preset rule when the communication interface has data change;
the original version number is the initial version number of the communication interface, and there may be various preset rules about the change of the version number, for example, the data is not updated once, the value of a specific position of the version number is changed, for example, the initial version number is defined as 0000, when the information of the functional module mapped by the communication interface is updated with the data, the value of the version number is increased by 1, namely, becomes 0001, when the information of the functional module mapped by the communication interface is updated with the data again, becomes 0002, and so on. By formulating a preset change rule and an original version number, the version number after data change can be distinguished from the version number in the previous state, when the lightweight interface polls, the version number of the communication interface in the current state is obtained and compared with the version number in the previous state, and when the version number and the version number change, the functional module corresponding to the communication interface is judged to have data update.
S120, acquiring a real-time version number of the communication interface in a polling mode through a lightweight interface;
because the server side is correspondingly provided with a plurality of different communication interfaces, all the communication interfaces can be detected in a way of alternately detecting and inquiring. In the application, the polling mode is performed by the polling rule specified when the poller is created, and the polling rule comprises the sequence of detecting different communication interfaces by the lightweight interfaces. The specific manner of detecting the sequence of the communication interfaces can be arbitrarily formulated, for example, the type of the client mapped by the communication interfaces or naming rules of the communication interfaces, or the importance degree of the client or the functional module mapped by the communication interfaces is differentiated, and all the communication interfaces or some selected communication interfaces can be detected by the lightweight interfaces only by selecting any detection manner. And detecting the version numbers of all the communication interfaces one by one according to the polling rule to obtain the real-time version numbers of the communication interfaces.
S130, judging whether the original version number and the real-time version number change or not, and generating result information by the judging structure.
Based on the above-mentioned polling rule and rule for setting version number, the version number of the communication interface is recorded every time when data update occurs, so by monitoring the real-time version number in the current state, it can be compared with the last recorded version number of the communication interface, so as to determine whether the version number of the communication interface changes, and whether the mapped data end has data change.
Further, the detection rule is not limited to the order of polling the communication interface, and includes a processing manner when detecting that the communication interface has data change, for example, a polling rule may be set as follows: when detecting that the communication interface has data change, feeding back the information of the communication interface to a server in real time, and simultaneously continuing the subsequent round-robin action, wherein the result information is mutually independent parameter information of the currently detected communication interface with data update;
or when detecting that the communication interface has data change, directly feeding back the information of the communication interface to a server side, and stopping polling action, wherein the result information is independent parameter information of the currently detected communication interface with data update.
Or when detecting that the communication interfaces have data change, only recording the information of the corresponding communication interfaces, continuing to perform polling action, and uniformly feeding back the information of the communication interfaces with data change to a server after all the communication interfaces are subjected to polling detection, wherein the result information is the set of the parameter information of all the monitored communication interfaces with data change.
And after the server receives the result information, the server performs connection communication on the detected communication interfaces with data updating.
In the application, the lightweight interface periodically detects the communication interface according to a first preset time period. In the polling process, a single one of the pollers generated by the lightweight interfaces can be adopted to perform polling detection according to a polling rule, and the first preset time period at the moment is the time from the completion of detection of the last communication interface to the next start of detection of the first communication interface through the pollers of the lightweight interfaces.
Furthermore, the application can also adopt a plurality of pollers to poll, wherein the first preset time period is the time interval between the start of the pollers of the previous lightweight interfaces and the start of the pollers of the next lightweight interfaces, and the detection interval can be shortened by adopting a mode of sequentially detecting the plurality of lightweight interfaces, so that updated data can be obtained more rapidly.
The preset rule of the version number has multiple forms, and the application discloses the following two types, in one embodiment, the original version number is a line number of the communication interface file; the function module mapped by the communication interface is realized by combining program fields, when the program fields are added or reduced, the number of lines of the program codes can be changed, for the reasons, the original version number is defined as the line number value of the communication interface file, and once the function module is changed and is embodied on the number of lines of the codes, the corresponding real-time version number is changed. One possible definition is:
the version number is defined in the above manner.
The method is only suitable for the situation that the number of lines of codes representing the functional module changes, if the number of lines of the codes is unchanged or only parameters corresponding to the codes change through the deletion and the addition of the codes, the version number is unchanged, and based on the method, the application also discloses another rule for formulating the version number.
In another embodiment, an original version number is defined, specific contents of a communication interface file corresponding to the original communication interface are recorded, each piece of content is polled, whether content is changed is detected, when any content of the communication interface file is changed, the version number is changed according to a preset rule, and the preset rule can be a certain field appointed on the changed original version number, or the previous version number is changed in an accumulated mode.
Polling a communication interface file in the communication interface;
when the content in the communication interface file is detected to change, the version number of the communication interface changes on the basis of the previous version number, for example, a fixed value is added to distinguish the version number from the previous version number.
In the application, the lightweight interface polls the communication interface periodically through a first preset time period, whether data update exists or not is intelligently monitored, and the frequency of the data update cannot be controlled, and further, as an optimized scheme, the application also establishes a second preset time period, and the detection method comprises the following steps:
monitoring a first frequency of connection communication between the server and the client in a second preset time period in real time;
the second preset time period is generally longer than the first preset time period, and the primary user counts the number of times of the communication interface data update detected in the time period, including the same number of times of the communication interface data update and different number of times of the communication interface data update, and the number of times is the first frequency.
And judging the communication activity degree in the current time period by counting the first frequency.
And detecting the communication interface according to a third preset time period when the first frequency is greater than or equal to the second frequency.
The second frequency is a preset threshold value related to the number of times of updating the communication interface data in a second preset time period, when the first frequency is greater than the second frequency, the current communication can be considered to be too active, when the communication is active, the data interaction quantity is large, the server side is busy in operation and the server side can possibly cause the failure of the server, so that the second frequency is set as the threshold value, and the normal communication between the server side and the client side is ensured.
Further, when the first frequency is greater than the second frequency, the communication interface is polled according to a third preset time period, and the third preset time period is greater than the first preset time period, namely when the first frequency is greater than the second frequency, the polling time interval is prolonged, the server delays the data updating of the client, the number of times of communication between the server and the client is reduced in unit time, the communication activity between the server and the client is reduced, so that the workload of the server is reduced, and the normal operation of the server is ensured all the time.
The application also discloses a heartbeat simulation detection device based on the lightweight interface, which comprises:
The acquisition module 100: the method comprises the steps that a detection instruction is obtained, a lightweight interface is adopted to carry out polling detection on a communication interface of a server side according to the detection instruction, result information obtained by detection is obtained, and the communication interface comprises an interface for mutual communication between a client side and the server side;
the lightweight interface is an interface mode designed by adopting a lightweight framework, the lightweight framework does not have aggressive API, and the lightweight framework has no dependency on a container, is easy to configure, is easy to be universal, and has short starting time. This is an advantage of a lightweight frame over a heavy frame. It is an advantage of this application that a lightweight interface is used to poll the communication interfaces of the client and server to quickly obtain the changed data.
The lightweight interface mentioned in the application is equivalent to the heartbeat packet in the heartbeat packet mechanism of long connection, the heartbeat packet can be sent at regular time, and the lightweight interface program is a specific program, so that each data interface can be directly monitored. The method for detecting the data interface program adopts a lightweight interface mode, so that the running load of the whole program is not increased, and the monitoring process is faster.
The processing module 200: the function module is used for judging whether the data update exists in the function module corresponding to the communication interface or not according to the result information;
the acquiring module 100 uses a lightweight interface to poll each communication interface, and because the polling process is performed according to a preset rule, polling can generate a result message about polling the communication interface.
The communication interface is used for communication, so that when the data in the functional module corresponding to the communication interface changes, the data can directly act on the communication interface, and the change of the data can be detected through the communication interface. In the application, the condition of data change is obtained by directly detecting different communication interfaces by adopting a lightweight interface, so that the polling result information in the application is whether the function module corresponding to the communication interface monitored by the detected communication interface has data change or not.
Execution module 300: and the server side is used for executing connection communication with the client side mapped by the communication interface if the communication interface with the data update is detected, so as to send the updated data to the client side for data update.
The processing module 200 can determine whether there is a change in the communication interface, which one of the communication interfaces has a change, and which one of the clients the communication interface maps to, and can connect and communicate the server with the corresponding client via the corresponding communication interface by using the data, and the server transmits the changed data to the client for connection and communication. And when no updated data exists on the corresponding communication interface, continuing to poll according to a preset rule.
According to the application, the lightweight interface is adopted as the polling device, so that the communication time can be greatly saved, and the manpower development cost for the program is reduced. And the communication interface on the server side is detected only by the mode of interface polling detection so as to judge whether data updating is needed, and compared with the mode of detecting communication by long connection between the server and the client side, the scheme of the application can rapidly and accurately acquire changed data, ensures that the operation speed of the whole communication architecture is faster, and ensures that the real-time updating is accurately carried out. Meanwhile, the server side and the client side do not need to be connected in real time, so that the flow is reduced.
Furthermore, the application discloses a method for detecting whether the communication interface has data update by adopting a light-weight interface, namely, a version number is set for the communication interface, the version number is related to the information of the functional module mapped by the communication interface, when the related information of the functional module has data change, the number of the version number also changes according to a certain preset rule, so that whether the version number corresponding to the communication interface changes or not is only compared, and whether the functional module corresponding to the communication interface has data update or not can be judged.
The application relates to a heartbeat simulation detection device based on a lightweight interface, which further comprises:
a first acquisition sub-module: the method comprises the steps of obtaining an original version number of the communication interface, and defining that the version number is changed according to a preset rule when the communication interface has data change;
the original version number is the initial version number of the communication interface, and there may be various preset rules about the change of the version number, for example, the data is not updated once, the value of a specific position of the version number is changed, for example, the initial version number is defined as 0000, when the information of the functional module mapped by the communication interface is updated with the data, the value of the version number is increased by 1, namely, becomes 0001, when the information of the functional module mapped by the communication interface is updated with the data again, becomes 0002, and so on. By formulating a preset change rule and an original version number, the version number after data change can be distinguished from the version number in the previous state, when the lightweight interface polls, the version number of the communication interface in the current state is obtained and compared with the version number in the previous state, and when the version number and the version number change, the functional module corresponding to the communication interface is judged to have data update.
And a second acquisition sub-module: the method comprises the steps of acquiring a real-time version number of a communication interface in a polling mode through a lightweight interface;
because the server side is correspondingly provided with a plurality of different communication interfaces, all the communication interfaces can be detected in a way of alternately detecting and inquiring. In the application, the polling mode is performed by the polling rule specified when the poller is created, and the polling rule comprises the sequence of detecting different communication interfaces by the lightweight interfaces. The specific manner of detecting the sequence of the communication interfaces can be arbitrarily formulated, for example, the type of the client mapped by the communication interfaces or naming rules of the communication interfaces, or the importance degree of the client or the functional module mapped by the communication interfaces is differentiated, and all the communication interfaces or some selected communication interfaces can be detected by the lightweight interfaces only by selecting any detection manner. And detecting the version numbers of all the communication interfaces one by one according to the polling rule to obtain the real-time version numbers of the communication interfaces.
A first judging sub-module: and the method is used for judging whether the original version number and the real-time version number change or not, and generating result information by the judging structure.
Based on the above-mentioned polling rule and rule for setting version number, the version number of the communication interface is recorded every time when data update occurs, so by monitoring the real-time version number in the current state, it can be compared with the last recorded version number of the communication interface, so as to determine whether the version number of the communication interface changes, and whether the mapped data end has data change.
Further, the detection rule is not limited to the order of polling the communication interface, and includes a processing manner when detecting that the communication interface has data change, for example, a polling rule may be set as follows: when detecting that the communication interface has data change, feeding back the information of the communication interface to a server in real time, and simultaneously continuing the subsequent round-robin action, wherein the result information is mutually independent parameter information of the currently detected communication interface with data update;
or when detecting that the communication interface has data change, directly feeding back the information of the communication interface to a server side, and stopping polling action, wherein the result information is independent parameter information of the currently detected communication interface with data update.
Or when detecting that the communication interfaces have data change, only recording the information of the corresponding communication interfaces, continuing to perform polling action, and uniformly feeding back the information of the communication interfaces with data change to a server after all the communication interfaces are subjected to polling detection, wherein the result information is the set of the parameter information of all the monitored communication interfaces with data change.
And after the server receives the result information, the server performs connection communication on the detected communication interfaces with data updating.
In the application, the lightweight interface periodically detects the communication interface according to a first preset time period. In the polling process, a single one of the pollers generated by the lightweight interfaces can be adopted to perform polling detection according to a polling rule, and the first preset time period at the moment is the time from the completion of detection of the last communication interface to the next start of detection of the first communication interface through the pollers of the lightweight interfaces.
Furthermore, the application can also adopt a plurality of pollers to poll, wherein the first preset time period is the time interval between the start of the pollers of the previous lightweight interfaces and the start of the pollers of the next lightweight interfaces, and the detection interval can be shortened by adopting a mode of sequentially detecting the plurality of lightweight interfaces, so that updated data can be obtained more rapidly.
The preset rule of the version number has multiple forms, and the application discloses the following two types, in one embodiment, the original version number is a line number of the communication interface file; the function module mapped by the communication interface is realized by combining program fields, when the program fields are added or reduced, the number of lines of the program codes can be changed, for the reasons, the original version number is defined as the line number value of the communication interface file, and once the function module is changed and is embodied on the number of lines of the codes, the corresponding real-time version number is changed.
The method is only suitable for the situation that the number of lines of codes representing the functional module changes, if the number of lines of the codes is unchanged or only parameters corresponding to the codes change through the deletion and the addition of the codes, the version number is unchanged, and based on the method, the application also discloses another rule for formulating the version number.
In another embodiment, an original version number is defined, specific contents of a communication interface file corresponding to the original communication interface are recorded, each piece of content is polled, whether content is changed is detected, when any content of the communication interface file is changed, the version number is changed according to a preset rule, and the preset rule can be a certain field appointed on the changed original version number, or the previous version number is changed in an accumulated mode.
Polling a communication interface file in the communication interface;
when the content in the communication interface file is detected to change, the version number of the communication interface changes on the basis of the previous version number, for example, a fixed value is added to distinguish the version number from the previous version number.
In the application, the lightweight interface polls the communication interface periodically through a first preset time period, whether data update exists or not is intelligently monitored, and the frequency of the data update cannot be controlled, and further, as an optimized scheme, the application further comprises the following steps:
the first monitoring submodule is used for monitoring a first frequency of connection communication between the server and the client in a second preset time period in real time;
the second preset time period is generally longer than the first preset time period, and the primary user counts the number of times of the communication interface data update detected in the time period, including the same number of times of the communication interface data update and different number of times of the communication interface data update, and the number of times is the first frequency.
And judging the communication activity degree in the current time period by counting the first frequency.
And the first processing submodule is used for detecting the communication interface according to a third preset time period when the first frequency is greater than or equal to the second frequency.
The second frequency is a preset threshold value related to the number of times of updating the communication interface data in a second preset time period, when the first frequency is greater than the second frequency, the current communication can be considered to be too active, when the communication is active, the data interaction quantity is large, the server side is busy in operation and the server side can possibly cause the failure of the server, so that the second frequency is set as the threshold value, and the normal communication between the server side and the client side is ensured.
Further, when the first frequency is greater than the second frequency, the communication interface is polled according to a third preset time period, and the third preset time period is greater than the first preset time period, namely when the first frequency is greater than the second frequency, the polling time interval is prolonged, the server delays the data updating of the client, the number of times of communication between the server and the client is reduced in unit time, the communication activity between the server and the client is reduced, so that the workload of the server is reduced, and the normal operation of the server is ensured all the time.
The embodiment of the application provides a basic structure block diagram of computer equipment and please refer to fig. 4.
The computer device includes a processor, a non-volatile storage medium, a memory, and a network interface connected by a system bus. The non-volatile storage medium of the computer device stores an operating system, a database and computer readable instructions, the database can store a control information sequence, and when the computer readable instructions are executed by the processor, the processor can realize a heartbeat simulation detection method based on a lightweight interface. The processor of the computer device is used to provide computing and control capabilities, supporting the operation of the entire computer device. The memory of the computer device may have stored therein computer readable instructions that, when executed by the processor, cause the processor to perform a method of heartbeat simulation detection based on a lightweight interface. The network interface of the computer device is for communicating with a terminal connection. It will be appreciated by persons skilled in the art that the architecture shown in fig. 4 is merely a block diagram of some of the architecture relevant to the present inventive arrangements and is not limiting as to the computer device to which the present inventive arrangements are applicable, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
The computer equipment receives the state information of the prompt behavior sent by the associated client, namely whether the associated terminal starts the prompt and whether the user closes the prompt task. By verifying whether the task conditions are met or not, a corresponding preset instruction is further sent to the associated terminal, so that the associated terminal can execute corresponding operation according to the preset instruction, and effective supervision of the associated terminal is achieved. Meanwhile, when the prompt information state is different from a preset state instruction, the server side controls the associated terminal to continuously ring so as to prevent the problem that the prompt task of the associated terminal is automatically terminated after being executed for a period of time.
The invention also provides a storage medium storing computer readable instructions that, when executed by one or more processors, cause the one or more processors to perform the method of lightweight interface-based heartbeat analog detection of any of the embodiments described above.
Those skilled in the art will appreciate that implementing all or part of the above-described methods in accordance with the embodiments may be accomplished by way of a computer program stored in a computer-readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. The storage medium may be a nonvolatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a random access Memory (Random Access Memory, RAM).
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, these steps are not necessarily performed in order as indicated by the arrows. The steps are not strictly limited in order and may be performed in other orders, unless explicitly stated herein. Moreover, at least some of the steps in the flowcharts of the figures may include a plurality of sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, the order of their execution not necessarily being sequential, but may be performed in turn or alternately with other steps or at least a portion of the other steps or stages.
The foregoing is only a partial embodiment of the present invention, and it should be noted that it will be apparent to those skilled in the art that modifications and adaptations can be made without departing from the principles of the present invention, and such modifications and adaptations are intended to be comprehended within the scope of the present invention.

Claims (10)

1. A heartbeat simulation detection method based on a lightweight interface is characterized by comprising the following steps:
acquiring a detection instruction, carrying out polling detection on a communication interface of a server side by adopting a lightweight interface according to the detection instruction, and acquiring result information obtained by detection, wherein the communication interface comprises an interface for the mutual communication between a client side and the server side; the lightweight interface is an interface mode designed through a lightweight framework;
Judging whether the functional module corresponding to the communication interface has data update or not according to the result information;
if the communication interface with the data update is detected, the server side is connected and communicated with the client side mapped by the communication interface, so that updated data is sent to the client side for data update.
2. The heartbeat simulation detection method based on the lightweight interface of claim 1 wherein the method for determining whether the data update exists in the functional module corresponding to the communication interface according to the result information includes:
acquiring an original version number of the communication interface, and defining that the version number changes according to a preset rule when the communication interface has data changes;
acquiring a real-time version number of the communication interface by adopting a polling mode through a lightweight interface;
and judging whether the original version number and the real-time version number change or not, and generating result information by a judging structure.
3. The method for simulated detection of heart beat based on a lightweight interface of claim 1, wherein the lightweight interface periodically detects the communication interface according to a first preset time period.
4. The lightweight interface-based heartbeat simulation detection method of claim 2 wherein the preset rules include:
the original version number is a row number value of the communication interface file;
the number of lines of the communication interface file varies, and the original version number also varies.
5. The lightweight interface-based heartbeat simulation detection method of claim 2 wherein the preset rules include:
polling a communication interface file in the communication interface;
when detecting that the content in the communication interface file changes, the version number of the communication interface changes on the basis of the previous version number.
6. A lightweight interface based heartbeat simulation detection method as claimed in claim 3, further comprising:
monitoring a first frequency of connection communication between the server and the client in a second preset time period in real time;
and detecting the communication interface according to a third preset time period when the first frequency is greater than or equal to the second frequency.
7. The lightweight interface based heartbeat analog detection method of claim 6 wherein the third preset time period is spaced longer than the first preset time period.
8. A lightweight interface-based heartbeat analog detection device, comprising:
the acquisition module is used for: the method comprises the steps that a detection instruction is obtained, a lightweight interface is adopted to carry out polling detection on a communication interface of a server side according to the detection instruction, result information obtained by detection is obtained, and the communication interface comprises an interface for mutual communication between a client side and the server side; the lightweight interface is an interface mode designed through a lightweight framework;
the processing module is used for: the function module is used for judging whether the data update exists in the function module corresponding to the communication interface or not according to the result information;
the execution module: and the server side is used for executing connection communication with the client side mapped by the communication interface if the communication interface with the data update is detected, so as to send the updated data to the client side for data update.
9. A computer device comprising a memory and a processor, the memory having stored therein computer readable instructions which, when executed by the processor, cause the processor to perform the steps of the lightweight interface based heartbeat analog detection method as claimed in any one of claims 1 to 7.
10. A storage medium storing computer readable instructions which, when executed by one or more processors, cause the one or more processors to perform the steps of a lightweight interface based heartbeat analog detection method as claimed in any one of claims 1 to 7.
CN201811131060.1A 2018-09-27 2018-09-27 Heartbeat simulation detection method and device based on lightweight interface and storage medium Active CN109347929B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811131060.1A CN109347929B (en) 2018-09-27 2018-09-27 Heartbeat simulation detection method and device based on lightweight interface and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811131060.1A CN109347929B (en) 2018-09-27 2018-09-27 Heartbeat simulation detection method and device based on lightweight interface and storage medium

Publications (2)

Publication Number Publication Date
CN109347929A CN109347929A (en) 2019-02-15
CN109347929B true CN109347929B (en) 2023-08-22

Family

ID=65307200

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811131060.1A Active CN109347929B (en) 2018-09-27 2018-09-27 Heartbeat simulation detection method and device based on lightweight interface and storage medium

Country Status (1)

Country Link
CN (1) CN109347929B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111865687B (en) * 2020-07-20 2023-05-30 上海万物新生环保科技集团有限公司 Service data updating method and device
CN112769651B (en) * 2021-01-13 2022-04-26 杭州迪普科技股份有限公司 TCP connection detection method and device and electronic equipment
CN113242284B (en) * 2021-04-30 2022-11-22 北京有竹居网络技术有限公司 Communication method, device and communication system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101557416A (en) * 2008-04-11 2009-10-14 北京闻言科技有限公司 Lightweight method of data merging of mobile phone client terminal and server terminal based on Http
CN102664773A (en) * 2012-05-22 2012-09-12 中国人民解放军信息工程大学 Method and device for detecting network flow
WO2014166523A1 (en) * 2013-04-09 2014-10-16 Nokia Solutions And Networks Oy Method and apparatus for generating insight into the customer experience of web based applications
CN105786452A (en) * 2014-12-16 2016-07-20 上海飞田通信股份有限公司 System and method for development of lightweight-class APP on mobile equipment
CN106209504A (en) * 2016-06-29 2016-12-07 努比亚技术有限公司 A kind of information processing method and device, server
WO2017215614A1 (en) * 2016-06-16 2017-12-21 中兴通讯股份有限公司 Method, device and system for realising heart beat keepalive

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101557416A (en) * 2008-04-11 2009-10-14 北京闻言科技有限公司 Lightweight method of data merging of mobile phone client terminal and server terminal based on Http
CN102664773A (en) * 2012-05-22 2012-09-12 中国人民解放军信息工程大学 Method and device for detecting network flow
WO2014166523A1 (en) * 2013-04-09 2014-10-16 Nokia Solutions And Networks Oy Method and apparatus for generating insight into the customer experience of web based applications
CN105786452A (en) * 2014-12-16 2016-07-20 上海飞田通信股份有限公司 System and method for development of lightweight-class APP on mobile equipment
WO2017215614A1 (en) * 2016-06-16 2017-12-21 中兴通讯股份有限公司 Method, device and system for realising heart beat keepalive
CN106209504A (en) * 2016-06-29 2016-12-07 努比亚技术有限公司 A kind of information processing method and device, server

Also Published As

Publication number Publication date
CN109347929A (en) 2019-02-15

Similar Documents

Publication Publication Date Title
CN109347929B (en) Heartbeat simulation detection method and device based on lightweight interface and storage medium
US11228973B2 (en) Wireless sensing network communication method
US20060173860A1 (en) Information processing system, server apparatus and client terminal apparatus
CN110266810B (en) Message receiving method, device and storage medium based on MQTT protocol
CN110868459A (en) Data transmission method, device, terminal and storage medium
US20180241609A1 (en) Remote casting of media content
CN102869123A (en) Virtual peripheral data acquisition method and system applicable to intelligent display equipment
WO2020154959A1 (en) Multi-load image transmission method, control system, control terminal, unmanned aerial vehicle, and server
JP2018005431A (en) Operation monitoring server and operation monitoring system
CN111405531A (en) Method, medium, terminal and device for improving communication quality
CN111212151B (en) File transmission method, device and storage medium
CN107682939B (en) Communication method based on LORA ad hoc protocol
CN106375324B (en) Network communication system and method based on TCP/IP communication protocol
CN112333237B (en) 5G industrial module and electronic equipment
US20140074978A1 (en) Method for managing apparatus and information distributing apparatus
CN112653717B (en) Multi-cloud cooperation distributed system and application distribution method
CN112134613A (en) Industrial communication system and communication method of unmanned aerial vehicle
US10778585B1 (en) Connection and application state migration for uninterrupted service availability
CN112532741A (en) Intelligent device control method and device, electronic device and storage medium
CN110958148A (en) Deployment system of distributed access equipment
CN111343700A (en) Wireless sensor network communication method
US20220321623A1 (en) Establishing a producer / consumer session in the cloud
CN113645108B (en) Intelligent household equipment monitoring system and method
CN108957520A (en) Monitor method and device, storage medium and the processor of environmental data
KR20040017361A (en) System and method for remotely monitoring modem status

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant