CN106961364A - Heartbeat detecting method and application server - Google Patents

Heartbeat detecting method and application server Download PDF

Info

Publication number
CN106961364A
CN106961364A CN201710269323.4A CN201710269323A CN106961364A CN 106961364 A CN106961364 A CN 106961364A CN 201710269323 A CN201710269323 A CN 201710269323A CN 106961364 A CN106961364 A CN 106961364A
Authority
CN
China
Prior art keywords
heartbeat
record
application server
heartbeat detection
mobile terminal
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.)
Withdrawn
Application number
CN201710269323.4A
Other languages
Chinese (zh)
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.)
Nubia Technology Co Ltd
Original Assignee
Nubia Technology Co 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 Nubia Technology Co Ltd filed Critical Nubia Technology Co Ltd
Priority to CN201710269323.4A priority Critical patent/CN106961364A/en
Publication of CN106961364A publication Critical patent/CN106961364A/en
Withdrawn legal-status Critical Current

Links

Classifications

    • 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
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/16Threshold monitoring
    • 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/54Presence management, e.g. monitoring or registration for receipt of user log-on information, or the connection status of the users

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The invention discloses a kind of application server, including memory, processor and storage are on a memory and the palmus detection system that can run on a processor, and following steps are realized when palmus detection system is executed by processor:When receiving the heartbeat packet transmitted by mobile terminal client terminal, the heartbeat detection record for the mobile terminal client terminal that whether is stored with the application server internal memory being connected with mobile terminal client terminal length is inquired about;If being stored with the heartbeat detection record, heartbeat detection record is updated according to the heartbeat packet received;With the heartbeat detection record stored in default frequency poll application server internal memory, determine to detect record with the presence or absence of abnormal heartbeats in the heartbeat detection record;If deleting abnormal heartbeats detection record in the presence of if, and disconnect and detect that record between corresponding mobile terminal client terminal and application server long connects with the abnormal heartbeats.The present invention more flexibly can be managed to long connection.

Description

Heartbeat detecting method and application server
Technical field
The present invention relates to communication technical field, more particularly to a kind of heartbeat detecting method and application server.
Background technology
In recent years, with the fast development of development of Mobile Internet technology, the function of the mobile terminal such as mobile phone, panel computer is got over Come abundanter, the type and quantity for the third party application that user installs on mobile terminals are also continuously increased.Answer a For program, its client is often installed in tens mobile terminals up to a million and used by mobile terminal user. Usually, application client needs to maintain one long connection with application server when in use, by the length even Data interaction could be carried out with the application server by connecing, and realize the function of the application program.
To maintain the long connection, being provided with the mobile terminal of application client needs periodically to send out to application server Heartbeat packet is sent, if application server receives the heartbeat packet, illustrates that mobile terminal is online, long connection therebetween normally may be used With.If conversely, application server does not receive heartbeat packet, illustrating that mobile terminal is not online, the long connection occurs abnormal.It is logical Often, to economize on resources, if not receiving heartbeat packet, application server can actively close the long connection.However, heartbeat packet is omitted Influence factor it is a lot (such as network signal is good, the system failure), accidental omission is not meant to that long connection has disconnected, Therefore, heartbeat packet is detected in the prior art and omits the processing mode underaction for just being done by application server and closing long connection, urgently Need to improve.
The content of the invention
In view of this, the present invention proposes a kind of heartbeat detecting method and application server, can be more neatly to installing There is the long connection between the mobile terminal of application client and application server to be detected, improve Consumer's Experience.
First, to achieve the above object, the present invention proposes a kind of application server, and the application server includes storage Device, processor and the palmus detection system that can be run on the memory and on the processor is stored in, the heartbeat inspection Following steps are realized when examining system is by the computing device:
When receiving the heartbeat packet transmitted by mobile terminal client terminal, inquiry is connected with the mobile terminal client terminal length Application server internal memory in whether be stored with the mobile terminal client terminal heartbeat detection record;
If the heartbeat detection record for the mobile terminal client terminal that is stored with the application server internal memory, according to institute The heartbeat packet of reception is updated to the information described in heartbeat detection record;
With the heartbeat detection record stored in application server internal memory described in default frequency poll, the heartbeat is determined In detection record record is detected with the presence or absence of abnormal heartbeats;
If there is abnormal heartbeats detection record, delete the abnormal heartbeats detection record, and disconnect with it is described different Normal heartbeat detection records the long connection between corresponding mobile terminal client terminal and the application server.
Alternatively, the step that the information described in being recorded according to the heartbeat packet received to the heartbeat detection is updated Before rapid, the processor is additionally operable to perform the palmus detection system, to realize following steps:
Calculate the heartbeat packet the reception time and heartbeat detection record between the described heartbeat detection time Time difference;
If the time difference exceeds preset time, directly determine that the corresponding heartbeat detection is recorded as the abnormal heart Jump detection record.
Alternatively, the information according to described in the heartbeat packet received is recorded to the heartbeat detection is updated Step, is specifically included:
The heartbeat detection time according to described in the reception time of the heartbeat packet updates the heartbeat detection record;
It is described to determine to detect the step of recording with the presence or absence of abnormal heartbeats in the heartbeat detection record, specifically include:
The heartbeat detection time described in each heartbeat detection record and the time difference of current poll time are calculated, And determine that the heartbeat detection records center jumps the heart that detection time exceeds predetermined threshold value with the time difference of current poll time Jump detection and be recorded as the abnormal heartbeats detection record.
Alternatively, the information according to described in the heartbeat packet received is recorded to the heartbeat detection is updated Step, is specifically included:
Heartbeat detection number of times according to described in the heartbeat packet received updates the heartbeat detection record;
It is described to determine to detect the step of recording with the presence or absence of abnormal heartbeats in the heartbeat detection record, specifically include:
It is continuous in default polling cycle that heartbeat detection number of times described in each heartbeat detection record is united Meter, and determine that the heartbeat detection records center jumps detection number of times and keeps constant heartbeat to examine in the default polling cycle Survey is recorded as the abnormal heartbeats detection record.
Alternatively, before the step of heartbeat packet received transmitted by mobile terminal client terminal described, the processor It is additionally operable to perform the palmus detection system, to realize following steps:
In the connection of mobile terminal client terminal length during the application server, inquire about in the application server internal memory whether The heartbeat detection record for being stored with related to the mobile terminal client terminal;
If the heartbeat detection record for not being stored with related to the mobile terminal client terminal in the application server internal memory, Then increase the heartbeat detection record of the mobile terminal client terminal newly in the application server internal memory.
In addition, to achieve the above object, the present invention also provides a kind of heartbeat detecting method, this method is applied to application service Device, methods described includes:
When receiving the heartbeat packet transmitted by mobile terminal client terminal, inquire about and whether deposited in the application server internal memory Contain the heartbeat detection record of the mobile terminal client terminal;
If the heartbeat detection record for the mobile terminal client terminal that is stored with the application server internal memory, according to institute The heartbeat packet of reception is updated to the information described in heartbeat detection record;
With the heartbeat detection record stored in application server internal memory described in default frequency poll, the heartbeat is determined In detection record record is detected with the presence or absence of abnormal heartbeats;
If there is abnormal heartbeats detection record, delete the abnormal heartbeats detection record, and disconnect with it is described different Normal heartbeat detection records the long connection between corresponding mobile terminal client terminal and the application server.
Alternatively, the step that the information described in being recorded according to the heartbeat packet received to the heartbeat detection is updated Before rapid, also include:
Calculate the heartbeat packet the reception time and heartbeat detection record between the described heartbeat detection time Time difference;
If the time difference exceeds preset time, directly determine that the corresponding heartbeat detection is recorded as the abnormal heart Jump detection record.
Alternatively, the information according to described in the heartbeat packet received is recorded to the heartbeat detection is updated Step, is specifically included:
The heartbeat detection time according to described in the reception time of the heartbeat packet updates the heartbeat detection record;
It is described to determine to detect the step of recording with the presence or absence of abnormal heartbeats in the heartbeat detection record, specifically include:
The heartbeat detection time described in each heartbeat detection record and the time difference of current poll time are calculated, And determine that the heartbeat detection records center jumps the heart that detection time exceeds predetermined threshold value with the time difference of current poll time Jump detection and be recorded as the abnormal heartbeats detection record.
Alternatively, the information according to described in the heartbeat packet received is recorded to the heartbeat detection is updated Step, is specifically included:
Heartbeat detection number of times according to described in the heartbeat packet received updates the heartbeat detection record;
It is described to determine to detect the step of recording with the presence or absence of abnormal heartbeats in the heartbeat detection record, specifically include:
It is continuous in default polling cycle that heartbeat detection number of times described in each heartbeat detection record is united Meter, and determine that the heartbeat detection records center jumps detection number of times and keeps constant heartbeat to examine in the default polling cycle Survey is recorded as the abnormal heartbeats detection record.
Alternatively, before the step of heartbeat packet received transmitted by mobile terminal client terminal described, methods described is also Including:
In the connection of mobile terminal client terminal length during the application server, inquire about in the application server internal memory whether The heartbeat detection record for being stored with related to the mobile terminal client terminal;
If the heartbeat detection record for not being stored with related to the mobile terminal client terminal in the application server internal memory, Then increase the heartbeat detection record of the mobile terminal client terminal newly in the application server internal memory.
Further, to achieve the above object, the present invention also provides a kind of computer-readable recording medium, the computer Readable storage medium storing program for executing is stored with palmus detection system, and the palmus detection system can be by least one computing device, so that institute The step of stating at least one computing device heartbeat detecting method described above.
Compared to prior art, application server, heartbeat detecting method and computer-readable storage proposed by the invention Medium, is preserved to internal memory by the heartbeat detection record for the mobile terminal client terminal that will be connected with application server length first;So Afterwards, when receiving the heartbeat packet of mobile terminal client terminal transmission, the heartbeat detection record stored in internal memory is carried out more in real time Newly;Then, the heartbeat detection record after renewal is inquired about using the mode of poll in application server side, only mobile whole Client is held to send heartbeat packet or the serious time-out of the application server reception heartbeat packet (heartbeat detection i.e. in heartbeat detection record The heartbeat detection number of times that time exceeds in predetermined threshold value, or heartbeat detection record with the time difference of current poll time continues Keep constant in default polling cycle) when, just disconnect the long connection between mobile terminal client terminal and application server.This Sample, can both avoid not receiving the disadvantage that heartbeat packet turns off the long connection once detecting application server in the prior art End, the mobile terminal client terminal that can also grow connection for the application server from application server side is carried out for greater flexibility Management.
Brief description of the drawings
Fig. 1 is the optional applied environment schematic diagram of each embodiment one of the invention;
Fig. 2 is the schematic diagram of the optional hardware structure of application server one in Fig. 1;
Fig. 3 is the high-level schematic functional block diagram of the embodiment of palmus detection system first, second of the present invention;
Fig. 4 is the high-level schematic functional block diagram of palmus detection system 3rd embodiment of the present invention;
Fig. 5 is the implementation process diagram of heartbeat detecting method first embodiment of the present invention;
Fig. 6 is the implementation process diagram of heartbeat detecting method second embodiment of the present invention;
Fig. 7 is the implementation process diagram of heartbeat detecting method 3rd embodiment of the present invention.
Reference:
Mobile terminal 1
Application server 2
Network 3
Memory 11
Processor 12
Network interface 13
Palmus detection system 200
Enquiry module 201
Update module 202
Poller module 203
Processing module 204
Newly-increased module 205
Process step S301-S304、S401-S402、S501-S502
The realization, functional characteristics and advantage of the object of the invention will be described further referring to the drawings in conjunction with the embodiments.
Embodiment
In order to make the purpose , technical scheme and advantage of the present invention be clearer, it is right below in conjunction with drawings and Examples The present invention is further elaborated.It should be appreciated that specific embodiment described herein is only to explain the present invention, not For limiting the present invention.Based on the embodiment in the present invention, those of ordinary skill in the art are not before creative work is made The every other embodiment obtained is put, the scope of protection of the invention is belonged to.
It should be noted that the description for being related to " first ", " second " etc. in the present invention is only used for describing purpose, and can not It is interpreted as indicating or implies its relative importance or the implicit quantity for indicating indicated technical characteristic.Thus, define " the One ", at least one this feature can be expressed or be implicitly included to the feature of " second ".In addition, the skill between each embodiment Art scheme can be combined with each other, but must can be implemented as basis with those of ordinary skill in the art, when technical scheme With reference to occur it is conflicting or when can not realize it will be understood that the combination of this technical scheme is not present, also not in application claims Protection domain within.
Refering to shown in Fig. 1, being the optional applied environment schematic diagram of each embodiment one of the invention.
In the present embodiment, present invention can apply to include but not limited to, mobile terminal 1, application server 2, network In 3 applied environment.Wherein, the mobile terminal 1 can be that mobile phone, smart phone, notebook computer, digital broadcasting connect Receive device, PDA (personal digital assistant), PAD (panel computer), PMP (portable media player), guider etc. can Mobile device, and such as fixed terminal of numeral TV, desktop computer, notebook, server etc..The application server 2 can be the computing devices such as rack-mount server, blade server, tower server or Cabinet-type server, the application clothes Business device 2 can be the server cluster that independent server or multiple servers are constituted.The network 3 can be Intranet (Intranet), internet (Internet), global system for mobile communications (Global System of Mobile communication, GSM), WCDMA (Wideband Code Division Multiple Access, WCDMA), 4G networks, 5G networks, bluetooth (Bluetooth), the wirelessly or non-wirelessly network such as Wi-Fi.
Wherein, in the application server 2 by the network 3 respectively with one or more mobile terminal 1s (in figure Only show one) communicate to connect, it is respectively mounted and has run corresponding with the application server 2 in each described mobile terminal 1 Application client (hereinafter " mobile terminal client terminal ").The mobile terminal client terminal is used to respond mobile terminal The operation of user, creates long connection between the mobile terminal client terminal and the application server 2, so that described mobile whole End client can be carried out data transmission and be interacted with the application server 2 by the long connection.
In the present embodiment, when being installed in the application server 2 and having run palmus detection system 200, when the heart When jumping the operation of detecting system 200, the heartbeat packet transmitted by the detecting of application server 2 mobile terminal client terminal is being received Corresponding heartbeat detection record in the internal memory of the application server 2 is inquired about during the heartbeat packet, and then to the heartbeat Detection record is updated so that the application server 2 can record mobile whole to judge according to the heartbeat detection after renewal Whether the long connection between end client and the application server 2 meets default condition, and then according to different judgement knots Fruit is more neatly treated differently to the long connection, it is to avoid take excessive server resource.
Refering to the schematic diagram for shown in Fig. 2, being the optional hardware structure of application server 2 one in Fig. 1.In the present embodiment, institute Stating application server 2 may include, but be not limited only to, and connection memory 11, processor 12, net can be in communication with each other by system bus Network interface 13.It is pointed out that Fig. 2 illustrate only the mobile terminal 1 with component 11-13, it should be understood that not It is required that implement all components shown, the more or less component of the implementation that can be substituted.
Wherein, the memory 11 at least includes a type of readable storage medium storing program for executing, and the readable storage medium storing program for executing includes Flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memories etc.), random access storage device (RAM), it is static with Machine access memory (SRAM), read-only storage (ROM), Electrically Erasable Read Only Memory (EEPROM), it is programmable only Read memory (PROM), magnetic storage, disk, CD etc..In certain embodiments, the memory 11 can be described answers With the internal storage unit of server 2, such as hard disk or internal memory of the application server 2.In further embodiments, it is described to deposit Reservoir 11 can also be the External memory equipment of the application server 2, such as the plug-in type being equipped with the application server 2 is hard Disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, flash card (Flash Card) etc..Certainly, the memory 11 can also both including the application server 2 internal storage unit or wrap Include its External memory equipment.In the present embodiment, the memory 11 is generally used for storing the behaviour for being installed on the application server 2 Make system and types of applications software, such as the program code of the palmus detection system 200.In addition, the memory 11 is also It can be used for temporarily storing the Various types of data that has exported or will export.
The processor 12 can be in certain embodiments central processing unit (Central ProcessingUnit, CPU), controller, microcontroller, microprocessor or other data processing chips.The processor 12 is generally used for should described in control With the overall operation of server 2, such as execution control related to mobile terminal 1 progress data interaction or communication and place Reason etc..In the present embodiment, the processor 12 is used to run the program code stored in the memory 11 or processing data, Such as running described palmus detection system 200.
The network interface 13 may include radio network interface or wired network interface, and the network interface 13 is generally used for Communication connection is set up between the application server 2 and other electronic equipments.In the present embodiment, the network interface 13 is mainly used The application server 2 is connected with one or more mobile terminal 1s in by the network 3, in the application service Data transmission channel and communication connection are set up between device 2 and one or more of mobile terminal 1s.
So far, oneself is through describing the applied environment of each embodiment of the invention and the hardware configuration of relevant device and work(in detail Energy.Below, above-mentioned applied environment and relevant device will be based on, each embodiment of the present invention is proposed.
First, the present invention proposes a kind of palmus detection system 200.
Refering to the functional block diagram for shown in Fig. 3, being the first embodiment of palmus detection system 200 of the present invention.In the present embodiment, Described palmus detection system 200 can be divided into one or more modules, and one or more of modules are stored in In the memory 11, and it is performed by one or more processors (being the processor 12 in the present embodiment), to complete this Invention.For example, in figure 3, described palmus detection system 200 can be divided into enquiry module 201, update module 202, wheel Ask module 203 and processing module 204.Functional module alleged by the present invention is a series of meters for referring to complete specific function Calculation machine programmed instruction section, than program more suitable for describing execution of the palmus detection system 200 in the application server 2 Process.The function of putting up with each functional module 201-204 below is described in detail.
The enquiry module 201, for when receiving the heartbeat packet transmitted by mobile terminal client terminal, inquiry is described should Recorded with the heartbeat detection for the mobile terminal client terminal that whether is stored with the internal memory of server 2.
Generally, the installation of a application client may up to million, if the application server 2 is tieed up for a long time Hold and be connected with the length between each mobile terminal client terminal, then can take substantial amounts of server resource, give application clothes The operation of business device 2 brings huge pressure.Therefore, in the prior art, in order to save server resource, application server 2 is usual The mobile terminal client terminal of long connection therewith can will be detected whether in abnormal unusable state by heartbeat detection mechanism. Usually, above-mentioned heartbeat detection mechanism is generally comprised:1) mobile terminal client terminal is periodically to the application server 2 of long connection therewith Send heartbeat packet;2) application server 2 receives the heartbeat packet transmitted by mobile terminal client terminal and feeds back corresponding information, simultaneously Start a timer to be monitored the time of giving out a contract for a project of subsequent movement client terminals, to judge that mobile terminal client terminal is No time-out of giving out a contract for a project (giving out a contract for a project the cycle beyond default).So, by regular between application server 2 and mobile terminal client terminal Packet receiving and give out a contract for a project and the cycle of giving out a contract for a project is monitored, it may be determined that the application server 2 of mutually long connection and mobile terminal visitor Whether " online " family end, and then determines whether the long connection is good for use.It is pointed out that to existing heartbeat detection For mechanism, as long as application server 2 is not received as the heartbeat transmitted by mobile terminal client terminal within the default cycle of giving out a contract for a project Bag, then can judge that the mobile terminal client terminal for growing connection therewith is in abnormality, the long connection is unavailable, and then directly breaks The length opened between the mobile terminal client terminal is connected, and discharges resource.
Although as can be seen that above-mentioned heartbeat detection mechanism can discharge the service occurred shared by abnormal long connection in time Device resource, but also there is higher False Rate simultaneously.Specifically, normally, heartbeat packet leakage hair or leakage is caused to be received (i.e. above Described application server 2 is not received as the heartbeat packet transmitted by mobile terminal client terminal in predetermined period) influence factor It is diversified, such as mobile terminal user has closed the data traffic of the mobile terminal 1, the mobile terminal 1 from shifting by mistake The not good region of dynamic signal of communication, which is passed through, mobile communications network is unstable etc. is likely to result in the mobile terminal client terminal not The heartbeat packet is sent, even if or the mobile terminal client terminal have sent the heartbeat packet but the heartbeat packet is not by the application Reception of server 2 etc..When above-mentioned situation occurs, the long company between the application server 2 and the mobile terminal client terminal It is probably of short duration sexual abnormality, and the of short duration sexual abnormality can typically recover quickly to connect, if such as mobile terminal 1 from As long as the not good region of mobile communication signal is left or mobile terminal user reopens the data traffic of mobile terminal 1 in time Switch, the then long connection can recover state good for use etc..
Therefore, be the False Rate of the existing heartbeat detection mechanism of reduction, the present embodiment in advance by with the application server 2 The corresponding heartbeat detection record storage of mobile terminal client terminal of long connection status is kept in the internal memory of the application server 2, When receiving as the heartbeat packet transmitted by mobile terminal client terminal, to be inquired about and the mobile terminal directly from the internal memory The corresponding heartbeat detection record of client, and then the information of heartbeat detection record record is updated, so that follow-up work It can be recorded more precisely to determine whether to disconnect the mobile terminal client terminal according to the heartbeat detection after renewal in flow Length between the application server 2 is connected.Wherein, the corresponding heartbeat detection record of the mobile terminal client terminal can be wrapped Include, but be not limited only to, the identifying of the mobile terminal 1, the ID of the long connection, the mobile terminal client terminal are the last to institute State application server 2 and send the time (being hereinafter " heartbeat detection time ") of heartbeat packet, the mobile terminal client terminal history The information such as the number of times of heartbeat packet are sent to the application server 2.
Specifically, when receiving the heartbeat packet transmitted by mobile terminal client terminal, the enquiry module 201 is obtained first The ID of the mobile terminal client terminal and the mobile terminal 1 mark, then according to acquired mobile terminal client terminal ID Or the inquiry from the internal memory of the application server 2 of mobile terminal 1 mark is recorded with the presence or absence of corresponding heartbeat detection.
The update module 202, for the mobile terminal client terminal that is stored with the internal memory of application server 2 When heartbeat detection is recorded, the information according to described in the heartbeat packet received is recorded to the heartbeat detection is updated.
It will be recalled from above that the present embodiment by the heartbeat detection record storage in the internal memory of application server 2, its mesh Be by the heartbeat detection record record in real time the mobile terminal client terminal to the application server 2 send heartbeat packet Information (for example record the mobile terminal client terminal to send out the heartbeat coating reception time that is received of application server 2 and go through History receives number of times etc.).Therefore, after the application server 2 receives the heartbeat packet transmitted by the mobile terminal client terminal, It is described if there is the heartbeat detection record corresponding with the mobile terminal client terminal in the internal memory of the application server 2 Update module 202 can be according to the heartbeat packet received, and described information is updated in being recorded to the heartbeat detection.Need It is noted that the renewal may include, but it is not limited only to, by the heartbeat detection time described in heartbeat detection record (i.e. mobile terminal client terminal is the last sends heartbeat packet to the application server 2, and the application server 2 receives institute State the time of heartbeat packet) it is updated to the reception time of the currently received heartbeat packet of the application server 2, or by the heartbeat (mobile terminal client terminal history sends heartbeat packet to heartbeat detection number of times described in detection record to the application server 2 Number of times) increase is one inferior.
You need to add is that, if the mobile terminal client terminal is to send the heart to the application server 2 for the first time Bag is jumped, then the heartbeat detection time described in during the heartbeat detection corresponding with the mobile terminal client terminal is recorded is (i.e. The mobile terminal client terminal is the last to send heartbeat packet to the application server 2, and the application server 2 receives described The time of heartbeat packet) and the heartbeat detection number of times (i.e. the mobile terminal client terminal history to the application server 2 send the heart Jump the number of times of bag) it is sky.Now, the renewal of 202 pairs of update module heartbeat detection record can be:Directly by institute Stating the heartbeat detection time described in heartbeat detection record records the currently received heartbeat packet of the application server 2 The reception time, and it is one inferior directly to record the heartbeat detection number of times described in the heartbeat detection record.
The poller module 203, for the heartbeat to be stored in the internal memory of application server 2 described in default frequency poll Detection record, determines to detect record with the presence or absence of abnormal heartbeats in the heartbeat detection record.
It will be recalled from above that the mobile terminal client terminal periodically can send heartbeat packet to the application server 2, to detect The situation of long connection between the two.And the application server 2 can then be sent out receiving by the mobile terminal client terminal Update the heartbeat detection record being stored in its internal memory after the heartbeat packet sent, and described in the heartbeat detection records Mobile terminal client terminal heartbeat packet sends the information of situation.Therefore, in the present embodiment, the application server 2 can pass through coding A specific polling mechanism is set, the polling mechanism is stored in every in the internal memory of application server 2 for periodic polling One heartbeat detection record, and then the information in each heartbeat detection record is verified, verify out the heartbeat Abnormal heartbeats in detection record detect record, are finally detected record come to corresponding long connection according to the abnormal heartbeats It is managed.So, one or more movements that long connection is kept to the application server 2 can be realized from the side of application server 2 Client terminals carry out flexible long connection management.
In certain embodiments, the abnormal heartbeats detection record can refer in the heartbeat detection record, described The time difference of heartbeat detection time and current poll time recorded beyond the heartbeat detection of predetermined threshold value., wherein it is desired to say Bright, the predetermined threshold value is preferably that the heartbeat packet for recording corresponding mobile terminal client terminal with the heartbeat detection is given out a contract for a project week 3 times of the time value of phase.That is, if heartbeat packet of 5 minutes hairs of mobile terminal client terminal, the predetermined threshold value can be set to 15 points Clock.Specifically, the poller module 203 can be deposited in the internal memory of application server 2 described in default frequency poll first The heartbeat detection record of storage, then calculates the heartbeat detection time described in each heartbeat detection record with working as front-wheel The time difference of inquiry time, and then relatively whether the time difference determines in the heartbeat detection record beyond predetermined threshold value Abnormal heartbeats detection record.Usually, if the time difference exceeds the predetermined threshold value, corresponding heartbeat detection is illustrated Record did not carry out renewal for a long time, namely corresponding mobile terminal client terminal is not sent out to the application server 2 for a long time Heartbeat packet is passed through, therefore the poller module 203 can be determined that corresponding heartbeat detection is recorded as the abnormal heartbeats detection record. If conversely, the time difference is without departing from the predetermined threshold value, illustrating that corresponding heartbeat detection record enters in the recent period for a long time Went renewal, namely corresponding mobile terminal client terminal is transmitted across heartbeat packet to the application server 2 in the recent period, therefore the poll Module 203 can be determined that corresponding heartbeat detection is recorded as normal heartbeat detection record.
In further embodiments, the abnormal heartbeats detection record can also refer in the heartbeat detection record, institute The heartbeat detection number of times of record keeps constant heartbeat detection to record in default polling cycle., wherein it is desired to explanation It is that time value corresponding with the default polling cycle is preferably not less than the cycle of giving out a contract for a project of mobile terminal client terminal heartbeat packet Time value.That is, if the cycle of giving out a contract for a project of mobile terminal client terminal is heartbeat packet of 5 minutes hairs, and the polling cycle is 2 minutes Once, then the default polling cycle can be 3 polling cycles to poll.Specifically, the poller module 203 can be first With the heartbeat detection record stored in the internal memory of application server 2 described in default frequency poll, then in the default poll It is continuous in cycle that heartbeat detection number of times described in each heartbeat detection record is counted, and then by verifying Constant heartbeat is kept to examine in the default polling cycle with the presence or absence of heartbeat detection number of times in the heartbeat detection record Record is surveyed to determine that the abnormal heartbeats in the heartbeat detection record detect record.Usually, if a certain bar heartbeat detection is recorded Described in heartbeat detection number of times keep constant in the default polling cycle, then illustrate corresponding heartbeat detection record length Time did not carry out renewal, namely corresponding mobile terminal client terminal does not send mistake heart to the application server 2 for a long time Bag is jumped, therefore the poller module 203 can be determined that corresponding heartbeat detection is recorded as the abnormal heartbeats detection record.Conversely, If the heartbeat detection number of times described in a certain bar heartbeat detection record is changed in the default polling cycle, say Bright corresponding heartbeat detection record was carrying out renewal, namely corresponding mobile terminal client terminal in the recent period to described in the recent period for a long time Application server 2 is transmitted across heartbeat packet, therefore the poller module 203 can be determined that corresponding heartbeat detection is recorded as the normal heart Jump detection record.
The processing module 204, for existing in the heartbeat detection record during abnormal heartbeats detection record, deletes institute Abnormal heartbeats detection record is stated, and is disconnected and is detected with the abnormal heartbeats and record corresponding mobile terminal client terminal and described answer With the long connection between server.
It will be recalled from above that heartbeat detection time and the current poll time described in being recorded when a certain bar heartbeat detection Time difference exceed the predetermined threshold value, or the heartbeat detection number of times described in heartbeat detection record is all in default poll When keeping constant in the phase, illustrate that the heartbeat detection record did not carry out renewal, corresponding mobile terminal visitor for a long time Family end is not transmitted across heartbeat packet to the application server 2 for a long time, typically can be determined that corresponding with heartbeat detection record Mobile terminal client and the application server 2 between long connection is occurring and non-transitory exception.Therefore, the present embodiment In, the processing module 204 directly can record suppressing exception heartbeat detection, and disconnect and abnormal heartbeats detection record Long connection between corresponding mobile terminal client terminal and the application server, to discharge the clothes shared by length connection Business device resource.
By above-mentioned functions module 201-204, palmus detection system 200 proposed by the invention, first by will with should The heartbeat detection record that the mobile terminal client terminal of connection is grown with server 2 is preserved to internal memory;Then, mobile terminal is being received During the heartbeat packet that client is sent, the heartbeat detection record stored in internal memory is updated;Then, make in application server side The heartbeat detection record after renewal is inquired about with the mode of poll, only heartbeat packet is sent in mobile terminal client terminal or answers With server 2 receive the serious time-out of heartbeat packet (heartbeat detection time and current poll time i.e. in heartbeat detection record when Between the heartbeat detection number of times that exceeds in predetermined threshold value, or heartbeat detection record of difference continue to keep not in default polling cycle Become) when, just disconnect the long connection between mobile terminal client terminal and application server 2.So, it can both avoid in the prior art The drawbacks of heartbeat packet turns off the long connection is not received once detecting application server 2, can also be from application server 2 The mobile terminal client terminal that side grow connection for the application server 2 is managed for greater flexibility.
Further, the above-mentioned first embodiment based on palmus detection system 200 of the present invention, proposes that the second of the present invention is real Apply example (as shown in Figure 3).In the present embodiment, the update module 202 is additionally operable to:
Before the information described in being recorded according to the heartbeat packet received to the heartbeat detection is updated, institute is calculated State heartbeat packet the reception time and heartbeat detection record in time difference between the described heartbeat detection time;And institute When stating the time difference beyond preset time, directly determine that the corresponding heartbeat detection is recorded as the abnormal heartbeats detection record.
It will be recalled from above that first embodiment monitors the application clothes by setting up polling mechanism in the side of application server 2 The heartbeat detection being engaged between device 2 and the mobile terminal client terminal, and send heartbeat packet or application in mobile terminal client terminal Server receives the serious time-out of heartbeat packet (heartbeat detection time and the time difference of current poll time i.e. in heartbeat detection record Value exceeds the heartbeat detection number of times in predetermined threshold value, or heartbeat detection record and continues to keep constant in default polling cycle) When, judge that long connection is abnormal unavailable, and then the long connection between mobile terminal client terminal and application server is disconnected, to save Server resource.And the present embodiment be then by directly compare adjacent application server twice 2 receive the time of heartbeat packet come It is whether abnormal to long connection to judge.
Specifically, when application server 2 receives the heartbeat packet that the mobile terminal client terminal is sent, the renewal mould Block 202 inquires about heartbeat detection corresponding with the mobile terminal client terminal record stored in the internal memory of application server 2 first, Obtained from heartbeat detection record described heartbeat detection time (namely the mobile terminal client terminal it is the last to The application server 2 sends heartbeat packet, and the application server 2 receives the time of the heartbeat packet);Then, institute is calculated State heartbeat packet the reception time and heartbeat detection record in time difference between the described heartbeat detection time;Finally, will The time difference is compared with preset time, to judge the shape of the long connection between mobile terminal client terminal and application server State.Wherein, the preset time is preferably that the heartbeat packet of the mobile terminal client terminal is given out a contract for a project 3 times of time value of cycle.
Usually, if the time difference exceeds the preset time, the double reception of the application server 2 is illustrated To the overlong time of heartbeat packet, the long connection between the application server 2 and the mobile terminal client terminal omits more Heartbeat packet, the long connection is abnormal unavailable.Now, the update module 202 can be determined that and the corresponding heart of the long connection Jump detection and be recorded as the abnormal heartbeats detection record.If conversely, the time difference, without departing from the preset time, illustrates institute State the double time for receiving heartbeat packet of application server 2 normally, the application server 2 and the mobile terminal client Excessive heartbeat packet is not omitted in long connection between end, and the long connection is good for use.Now, the update module 202 can To judge to be recorded as normal heartbeat detection record with the long corresponding heartbeat detection of connection.
By above-mentioned functions module 202, palmus detection system 200 proposed by the invention can be by directly more adjacent Application server 2 receives the time of heartbeat packet to judge whether long connection is abnormal twice, and then abnormal length is connected Row disconnection process is tapped into, server resource is saved.
Further, above-mentioned first and second embodiment based on palmus detection system 200 of the present invention, proposes the present invention's 3rd embodiment (as shown in Figure 4).In the present embodiment, described palmus detection system 200 also includes newly-increased module 205, wherein:
The enquiry module 201, when being additionally operable to the application server 2 in the connection of mobile terminal client terminal length, inquiry The heartbeat detection record for whether being stored with related to the mobile terminal client terminal in the internal memory of application server 2.
The newly-increased module 205, for not being stored with and the mobile terminal client in the internal memory of application server 2 When the related heartbeat detection in end is recorded, the heartbeat inspection of the mobile terminal client terminal is increased newly in the internal memory of application server 2 Survey record.
Knowable to above, when abnormal unavailable, the meeting of long connection between mobile terminal client terminal and the application server 2 Delete corresponding heartbeat detection record in the internal memory of application server 2.Therefore, in the present embodiment, as mobile terminal visitor When family end is connected (including set up and re-establish for the first time) with the application server 2 foundation length, if detecting the application The heartbeat detection corresponding with the mobile terminal client terminal is not recorded in the internal memory of server 2, then needs to take in the application It is engaged in increasing heartbeat detection record corresponding with the mobile terminal client terminal in the internal memory of device 2 newly.Wherein, the newly-increased heartbeat detection Record is at least include but not limited to, the information such as the identifying of the mobile terminal 1, ID of the long connection.
Pass through above-mentioned functions module 205, palmus detection system 200 proposed by the invention, additionally it is possible in mobile terminal visitor When long be connected is set up in family end with the application server 2, it is previously detected in the internal memory of application server 2 and whether is stored with and movement The corresponding heartbeat detection record of client terminals, if the newly-increased corresponding heartbeat in the internal memory of the application server 2 without if Detection record, subsequently to provide convenient to the long connection work whether good for use being monitored.
In addition, the present invention also proposes a kind of heartbeat detecting method.
Refering to the implementation process diagram for shown in Fig. 5, being heartbeat detecting method first embodiment of the present invention.In the present embodiment In, according to different demands, the execution sequence of the step in flow chart shown in Fig. 5 can change, and some steps can be omitted.
Step S301, when receiving the heartbeat packet transmitted by mobile terminal client terminal, is inquired about in the application server 2 Whether be stored with depositing the mobile terminal client terminal heartbeat detection record.
Generally, the installation of a application client may up to million, if the application server 2 is tieed up for a long time Hold and be connected with the length between each mobile terminal client terminal, then can take substantial amounts of server resource, give application clothes The operation of business device 2 brings huge pressure.Therefore, in the prior art, in order to save server resource, application server 2 is usual The mobile terminal client terminal of long connection therewith can will be detected whether in abnormal unusable state by heartbeat detection mechanism. Usually, above-mentioned heartbeat detection mechanism is generally comprised:1) mobile terminal client terminal is periodically to the application server 2 of long connection therewith Send heartbeat packet;2) application server 2 receives the heartbeat packet transmitted by mobile terminal client terminal and feeds back corresponding information, simultaneously Start a timer to be monitored the time of giving out a contract for a project of subsequent movement client terminals, to judge that mobile terminal client terminal is No time-out of giving out a contract for a project (giving out a contract for a project the cycle beyond default).So, by regular between application server 2 and mobile terminal client terminal Packet receiving and give out a contract for a project and the cycle of giving out a contract for a project is monitored, it may be determined that the application server 2 of mutually long connection and mobile terminal visitor Whether " online " family end, and then determines whether the long connection is good for use.It is pointed out that to existing heartbeat detection For mechanism, as long as application server 2 is not received as the heartbeat transmitted by mobile terminal client terminal within the default cycle of giving out a contract for a project Bag, then can judge that the mobile terminal client terminal for growing connection therewith is in abnormality, the long connection is unavailable, and then directly breaks The length opened between the mobile terminal client terminal is connected, and discharges resource.
Although as can be seen that above-mentioned heartbeat detection mechanism can discharge the service occurred shared by abnormal long connection in time Device resource, but also there is higher False Rate simultaneously.Specifically, normally, heartbeat packet leakage hair or leakage is caused to be received (i.e. above Described application server 2 is not received as the heartbeat packet transmitted by mobile terminal client terminal in predetermined period) influence factor It is diversified, such as mobile terminal user has closed the data traffic of the mobile terminal 1, the mobile terminal 1 from shifting by mistake The not good region of dynamic signal of communication, which is passed through, mobile communications network is unstable etc. is likely to result in the mobile terminal client terminal not The heartbeat packet is sent, even if or the mobile terminal client terminal have sent the heartbeat packet but the heartbeat packet is not by the application Reception of server 2 etc..When above-mentioned situation occurs, the long company between the application server 2 and the mobile terminal client terminal It is probably of short duration sexual abnormality, and the of short duration sexual abnormality can typically recover quickly to connect, if such as mobile terminal 1 from As long as the not good region of mobile communication signal is left or mobile terminal user reopens the data traffic of mobile terminal 1 in time Switch, the then long connection can recover state good for use etc..
Therefore, be the False Rate of the existing heartbeat detection mechanism of reduction, the present embodiment in advance by with the application server 2 The corresponding heartbeat detection record storage of mobile terminal client terminal of long connection status is kept in the internal memory of the application server 2, When receiving as the heartbeat packet transmitted by mobile terminal client terminal, to be inquired about and the mobile terminal directly from the internal memory The corresponding heartbeat detection record of client, and then the information of heartbeat detection record record is updated, so that follow-up work It can be recorded more precisely to determine whether to disconnect the mobile terminal client terminal according to the heartbeat detection after renewal in flow Length between the application server 2 is connected.Wherein, the corresponding heartbeat detection record of the mobile terminal client terminal can be wrapped Include, but be not limited only to, the identifying of the mobile terminal 1, the ID of the long connection, the mobile terminal client terminal are the last to institute State application server 2 and send the time (being hereinafter " heartbeat detection time ") of heartbeat packet, the mobile terminal client terminal history The information such as the number of times of heartbeat packet are sent to the application server 2.Specifically, when receiving transmitted by mobile terminal client terminal During heartbeat packet, the ID of the mobile terminal client terminal and the mark of the mobile terminal 1 are obtained first, then according to acquired Mobile terminal client terminal ID or mobile terminal 1 the mark inquiry from the internal memory of the application server 2 whether there is the corresponding heart Jump detection record.
Step S302, the heartbeat detection note for the mobile terminal client terminal that is stored with the internal memory of application server 2 During record, the information according to described in the heartbeat packet received is recorded to the heartbeat detection is updated.
It will be recalled from above that the present embodiment by the heartbeat detection record storage in the internal memory of application server 2, its mesh Be by the heartbeat detection record record in real time the mobile terminal client terminal to the application server 2 send heartbeat packet Information (for example record the mobile terminal client terminal to send out the heartbeat coating reception time that is received of application server 2 and go through History receives number of times etc.).Therefore, after the application server 2 receives the heartbeat packet transmitted by the mobile terminal client terminal, , can be with if there is heartbeat detection record corresponding with the mobile terminal client terminal in the internal memory of the application server 2 According to the heartbeat packet received, described information is updated in being recorded to the heartbeat detection.It should be noted that described Renewal may include, but be not limited only to, the heartbeat detection is recorded described in heartbeat detection time (i.e. mobile terminal client terminal The last to send heartbeat packet to the application server 2, the application server 2 receives the time of the heartbeat packet) more It is newly the reception time of the currently received heartbeat packet of the application server 2, or by described in heartbeat detection record Heartbeat detection number of times (mobile terminal client terminal history sends the number of times of heartbeat packet to the application server 2) increase by one is inferior.
You need to add is that, if the mobile terminal client terminal is to send the heart to the application server 2 for the first time Bag is jumped, then the heartbeat detection time described in during the heartbeat detection corresponding with the mobile terminal client terminal is recorded is (i.e. The mobile terminal client terminal is the last to send heartbeat packet to the application server 2, and the application server 2 receives described The time of heartbeat packet) and the heartbeat detection number of times (i.e. the mobile terminal client terminal history to the application server 2 send the heart Jump the number of times of bag) it is sky.Now, can be to the renewal that the heartbeat detection is recorded:Directly the heartbeat detection is recorded In described heartbeat detection time record reception time of the currently received heartbeat packet of the application server 2, and Directly record the heartbeat detection number of times described in the heartbeat detection record inferior for one.
Step S303, is recorded, really with the heartbeat detection stored in the internal memory of application server 2 described in default frequency poll In the fixed heartbeat detection record record is detected with the presence or absence of abnormal heartbeats.
It will be recalled from above that the mobile terminal client terminal periodically can send heartbeat packet to the application server 2, to detect The situation of long connection between the two.And the application server 2 can then be sent out receiving by the mobile terminal client terminal Update the heartbeat detection record being stored in its internal memory after the heartbeat packet sent, and described in the heartbeat detection records Mobile terminal client terminal heartbeat packet sends the information of situation.Therefore, in the present embodiment, the application server 2 can pass through coding A specific polling mechanism is set, the polling mechanism is stored in every in the internal memory of application server 2 for periodic polling One heartbeat detection record, and then the information in each heartbeat detection record is verified, verify out the heartbeat Abnormal heartbeats in detection record detect record, are finally detected record come to corresponding long connection according to the abnormal heartbeats It is managed.So, one or more movements that long connection is kept to the application server 2 can be realized from the side of application server 2 Client terminals carry out flexible long connection management.
In certain embodiments, the abnormal heartbeats detection record can refer in the heartbeat detection record, described The time difference of heartbeat detection time and current poll time recorded beyond the heartbeat detection of predetermined threshold value., wherein it is desired to say Bright, the predetermined threshold value is preferably that the heartbeat packet for recording corresponding mobile terminal client terminal with the heartbeat detection is given out a contract for a project week 3 times of the time value of phase.That is, if heartbeat packet of 5 minutes hairs of mobile terminal client terminal, the predetermined threshold value can be set to 15 points Clock.Specifically, the heartbeat detection note that can be stored first in the internal memory of application server 2 described in default frequency poll Record, then calculates the heartbeat detection time and the time difference of current poll time described in each heartbeat detection record Value, and then relatively whether the time difference determines the abnormal heartbeats detection in the heartbeat detection record beyond predetermined threshold value Record.Usually, if the time difference exceeds the predetermined threshold value, illustrate that corresponding heartbeat detection record does not have for a long time Renewal was carried out, namely corresponding mobile terminal client terminal is not transmitted across heartbeat packet to the application server 2 for a long time, therefore can To judge that corresponding heartbeat detection is recorded as the abnormal heartbeats detection record.If conversely, the time difference is without departing from described Predetermined threshold value, then illustrate that corresponding heartbeat detection record was carrying out renewal, namely corresponding mobile terminal visitor in the recent period for a long time Family end is transmitted across heartbeat packet to the application server 2 in the recent period, therefore can be determined that corresponding heartbeat detection is recorded as the normal heart Jump detection record.
In further embodiments, the abnormal heartbeats detection record can also refer in the heartbeat detection record, institute The heartbeat detection number of times of record keeps constant heartbeat detection to record in default polling cycle., wherein it is desired to explanation It is that time value corresponding with the default polling cycle is preferably not less than the cycle of giving out a contract for a project of mobile terminal client terminal heartbeat packet Time value.That is, if the cycle of giving out a contract for a project of mobile terminal client terminal is heartbeat packet of 5 minutes hairs, and the polling cycle is 2 minutes Once, then the default polling cycle can be 3 polling cycles to poll.Specifically, can be first with default frequency wheel The heartbeat detection record stored in the internal memory of application server 2 is ask, it is then continuous to every in the default polling cycle Described heartbeat detection number of times is counted in one heartbeat detection record, and then is remembered by verifying the heartbeat detection Constant heartbeat detection is kept to record to determine in the default polling cycle with the presence or absence of heartbeat detection number of times in record State the abnormal heartbeats detection record in heartbeat detection record.Usually, if the heartbeat described in a certain bar heartbeat detection record is examined Survey number of times and keep constant in the default polling cycle, then illustrate that corresponding heartbeat detection record was not carried out for a long time Update, namely corresponding mobile terminal client terminal is not transmitted across heartbeat packet to the application server 2 for a long time, therefore can be determined that Corresponding heartbeat detection is recorded as the abnormal heartbeats detection record.If conversely, the heart described in a certain bar heartbeat detection record Jump detection number of times in the default polling cycle to be changed, then illustrate corresponding heartbeat detection record for a long time near Phase carried out renewal, namely corresponding mobile terminal client terminal is transmitted across heartbeat packet to the application server 2 in the recent period, therefore can be with Judge that corresponding heartbeat detection is recorded as normal heartbeat detection record.
Step S304, when there is abnormal heartbeats detection record in heartbeat detection record, deletes the abnormal heartbeats Detection record, and disconnect detected with the abnormal heartbeats record corresponding mobile terminal client terminal and the application server it Between long connection.
It will be recalled from above that heartbeat detection time and the current poll time described in being recorded when a certain bar heartbeat detection Time difference exceed the predetermined threshold value, or the heartbeat detection number of times described in heartbeat detection record is all in default poll When keeping constant in the phase, illustrate that the heartbeat detection record did not carry out renewal, corresponding mobile terminal visitor for a long time Family end is not transmitted across heartbeat packet to the application server 2 for a long time, typically can be determined that corresponding with heartbeat detection record Mobile terminal client and the application server 2 between long connection is occurring and non-transitory exception.Therefore, the present embodiment can Directly to record suppressing exception heartbeat detection, and disconnection records corresponding mobile terminal client with abnormal heartbeats detection Long connection between end and the application server, to discharge the server resource shared by length connection.
By above-mentioned steps S301-304, heartbeat detecting method proposed by the invention, first by will be with application service The heartbeat detection record of the mobile terminal client terminal of the length connection of device 2 is preserved to internal memory;Then, mobile terminal client terminal is being received During the heartbeat packet of transmission, the heartbeat detection record stored in internal memory is updated;Then, poll is used in application server side Mode the heartbeat detection record after renewal is inquired about, only send heartbeat packet or application service in mobile terminal client terminal Device 2 receives the serious time-out of the heartbeat packet (time difference of heartbeat detection time and current poll time i.e. in heartbeat detection record Heartbeat detection number of times in predetermined threshold value, or heartbeat detection record continues to keep constant in default polling cycle) when, Just disconnect the long connection between mobile terminal client terminal and application server 2.So, a detection in the prior art can both be avoided Do not receive the drawbacks of heartbeat packet just turns off the long connection to application server 2, can also from the side of application server 2 for The mobile terminal client terminal that the application server 2 grow connection is managed for greater flexibility.
Further, the above-mentioned first embodiment based on heartbeat detecting method of the present invention, proposes heartbeat detection side of the present invention The second embodiment of method.
As shown in fig. 6, being the implementation process diagram of data method for transformation second embodiment of the present invention.In the present embodiment, Before the step of information described in being recorded according to the heartbeat packet received to the heartbeat detection is updated, methods described Also include:
Step S401, in the reception time of the calculating heartbeat packet and the heartbeat detection record during described heartbeat detection Between between time difference.
Step S402, if the time difference exceeds preset time, directly determines that the corresponding heartbeat detection is recorded as The abnormal heartbeats detection record.
It will be recalled from above that first embodiment monitors the application clothes by setting up polling mechanism in the side of application server 2 The heartbeat detection being engaged between device 2 and the mobile terminal client terminal, and send heartbeat packet or application in mobile terminal client terminal Server receives the serious time-out of heartbeat packet (heartbeat detection time and the time difference of current poll time i.e. in heartbeat detection record Value exceeds the heartbeat detection number of times in predetermined threshold value, or heartbeat detection record and continues to keep constant in default polling cycle) When, judge that long connection is abnormal unavailable, and then the long connection between mobile terminal client terminal and application server is disconnected, to save Server resource.And the present embodiment be then by directly compare adjacent application server twice 2 receive the time of heartbeat packet come It is whether abnormal to long connection to judge.
Specifically, when application server 2 receives the heartbeat packet that the mobile terminal client terminal is sent, institute is inquired about first Heartbeat detection corresponding with the mobile terminal client terminal record stored in the internal memory of application server 2 is stated, from the heartbeat detection Described heartbeat detection time is obtained in record, and (namely the mobile terminal client terminal is the last to the application server 2 send heartbeat packet, and the application server 2 receives the time of the heartbeat packet);Then, the reception of the heartbeat packet is calculated Time difference in time and heartbeat detection record between the described heartbeat detection time;Finally, by the time difference and in advance If the time is compared, to judge the state of the long connection between mobile terminal client terminal and application server.Wherein, it is described pre- 3 times of the time value of cycle if the heartbeat packet that the time is preferably the mobile terminal client terminal is given out a contract for a project.
Usually, if the time difference exceeds the preset time, the double reception of the application server 2 is illustrated To the overlong time of heartbeat packet, the long connection between the application server 2 and the mobile terminal client terminal omits more Heartbeat packet, the long connection is abnormal unavailable.At this point it is possible to described in judging to be recorded as with the long corresponding heartbeat detection of connection Abnormal heartbeats detection record.If conversely, the time difference without departing from the preset time, illustrates that the application server 2 connects The continuous time for receiving heartbeat packet twice is normal, the long connection between the application server 2 and the mobile terminal client terminal Excessive heartbeat packet is not omitted, the long connection is good for use.At this point it is possible to judge that heartbeat corresponding with the length connection is examined Survey is recorded as normal heartbeat detection record.
By above-mentioned steps S401-S402, heartbeat detecting method proposed by the invention can be by directly more adjacent Application server 2 receives the time of heartbeat packet to judge whether long connection is abnormal twice, and then abnormal length is connected Row disconnection process is tapped into, server resource is saved.
Further, above-mentioned first and second embodiment based on heartbeat detecting method of the present invention, proposes heartbeat of the present invention The 3rd embodiment of detection method.
As shown in fig. 7, being the implementation process diagram of data method for transformation 3rd embodiment of the present invention.In the present embodiment, Before the step of heartbeat packet received transmitted by mobile terminal client terminal described, methods described also includes:
Step S501, in the connection of mobile terminal client terminal length during the application server 2, inquires about the application server The heartbeat detection record for whether being stored with related to the mobile terminal client terminal in 2 internal memories;
Step S502, if not being stored with the heart related to the mobile terminal client terminal in the internal memory of the application server 2 Detection record is jumped, then increases the heartbeat detection record of the mobile terminal client terminal newly in the internal memory of application server 2.
Knowable to above, when abnormal unavailable, the meeting of long connection between mobile terminal client terminal and the application server 2 Delete corresponding heartbeat detection record in the internal memory of application server 2.Therefore, in the present embodiment, as mobile terminal visitor When family end is connected (including set up and re-establish for the first time) with the application server 2 foundation length, if detecting the application The heartbeat detection corresponding with the mobile terminal client terminal is not recorded in the internal memory of server 2, then needs to take in the application It is engaged in increasing heartbeat detection record corresponding with the mobile terminal client terminal in the internal memory of device 2 newly.Wherein, the newly-increased heartbeat detection Record is at least include but not limited to, the information such as the identifying of the mobile terminal 1, ID of the long connection.
Pass through above-mentioned steps S501-S502, heartbeat detecting method proposed by the invention, additionally it is possible in mobile terminal client When long be connected is set up in end with the application server 2, it is previously detected in the internal memory of application server 2 and whether is stored with movement eventually The heartbeat detection record that client is corresponding is held, is examined if increasing corresponding heartbeat newly in the internal memory of the application server 2 without if Record is surveyed, subsequently to provide convenient to the long connection work whether good for use being monitored.
The embodiments of the present invention are for illustration only, and the quality of embodiment is not represented.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side Method can add the mode of required general hardware platform to realize by software, naturally it is also possible to by hardware, but in many cases The former is more preferably embodiment.Understood based on such, technical scheme is substantially done to prior art in other words Going out the part of contribution can be embodied in the form of software product, and the computer software product is stored in a storage medium In (such as ROM/RAM, magnetic disc, CD), including some instructions are make it that a station terminal equipment (can be mobile phone, computer, clothes It is engaged in device, air-conditioner, or network equipment etc.) perform method described in each embodiment of the invention.
The preferred embodiments of the present invention are these are only, are not intended to limit the scope of the invention, it is every to utilize this hair Equivalent structure or equivalent flow conversion that bright specification and accompanying drawing content are made, or directly or indirectly it is used in other related skills Art field, is included within the scope of the present invention.

Claims (10)

1. a kind of application server, it is characterised in that the application server includes memory, processor and is stored in described deposit On reservoir and the palmus detection system that can run on the processor, when the palmus detection system is by the computing device Realize following steps:
When receiving the heartbeat packet transmitted by mobile terminal client terminal, what inquiry was connected with the mobile terminal client terminal length should Recorded with the heartbeat detection for the mobile terminal client terminal that whether is stored with server memory;
If the heartbeat detection record for the mobile terminal client terminal that is stored with the application server internal memory, according to being received Heartbeat packet to the heartbeat detection record described in information be updated;
With the heartbeat detection record stored in application server internal memory described in default frequency poll, the heartbeat detection is determined In record record is detected with the presence or absence of abnormal heartbeats;
If there is the abnormal heartbeats detection record, the abnormal heartbeats detection record is deleted, and disconnect and the abnormal heart Jump the long connection for detecting and recording between corresponding mobile terminal client terminal and the application server.
2. application server as claimed in claim 1, it is characterised in that examined according to the heartbeat packet received to the heartbeat Survey before the step of information described in record is updated, the processor is additionally operable to perform the palmus detection system, with Realize following steps:
Calculate the heartbeat packet the reception time and heartbeat detection record in time between the described heartbeat detection time Difference;
If the time difference exceeds preset time, directly determine that the corresponding heartbeat detection is recorded as the abnormal heartbeats inspection Survey record.
3. application server as claimed in claim 1, it is characterised in that it is described according to the heartbeat packet received to the heartbeat The step of information described in record is updated is detected, is specifically included:
The heartbeat detection time according to described in the reception time of the heartbeat packet updates the heartbeat detection record;
It is described to determine to detect the step of recording with the presence or absence of abnormal heartbeats in the heartbeat detection record, specifically include:
The heartbeat detection time described in each heartbeat detection record and the time difference of current poll time are calculated, and really The fixed heartbeat detection records center jumps detection time and the time difference of current poll time is examined beyond the heartbeat of predetermined threshold value Survey is recorded as the abnormal heartbeats detection record.
4. application server as claimed in claim 1, it is characterised in that it is described according to the heartbeat packet received to the heartbeat The step of information described in record is updated is detected, is specifically included:
Heartbeat detection number of times according to described in the heartbeat packet received updates the heartbeat detection record;
It is described to determine to detect the step of recording with the presence or absence of abnormal heartbeats in the heartbeat detection record, specifically include:
It is continuous in default polling cycle that heartbeat detection number of times described in each heartbeat detection record is counted, and Determine that the heartbeat detection records center jumps detection number of times and keeps constant heartbeat detection to remember in the default polling cycle Record and detect record for the abnormal heartbeats.
5. the application server as described in claim any one of 1-4, it is characterised in that receive mobile terminal client described Before the step of holding transmitted heartbeat packet, the processor is additionally operable to perform the palmus detection system, to realize following step Suddenly:
In the connection of mobile terminal client terminal length during the application server, inquire about and whether stored in the application server internal memory There is the heartbeat detection record related to the mobile terminal client terminal;
If the heartbeat detection record for not being stored with related to the mobile terminal client terminal in the application server internal memory, Increase the heartbeat detection record of the mobile terminal client terminal in the application server internal memory newly.
6. a kind of heartbeat detecting method, applied to application server, it is characterised in that methods described includes:
When receiving the heartbeat packet transmitted by mobile terminal client terminal, inquire about and whether be stored with the application server internal memory The heartbeat detection record of the mobile terminal client terminal;
If the heartbeat detection record for the mobile terminal client terminal that is stored with the application server internal memory, according to being received Heartbeat packet to the heartbeat detection record described in information be updated;
With the heartbeat detection record stored in application server internal memory described in default frequency poll, the heartbeat detection is determined In record record is detected with the presence or absence of abnormal heartbeats;
If there is the abnormal heartbeats detection record, the abnormal heartbeats detection record is deleted, and disconnect and the abnormal heart Jump the long connection for detecting and recording between corresponding mobile terminal client terminal and the application server.
7. heartbeat detecting method as claimed in claim 6, it is characterised in that according to the heartbeat packet received to the heartbeat Detect before the step of information described in record is updated, also include:
Calculate the heartbeat packet the reception time and heartbeat detection record in time between the described heartbeat detection time Difference;
If the time difference exceeds preset time, directly determine that the corresponding heartbeat detection is recorded as the abnormal heartbeats inspection Survey record.
8. heartbeat detecting method as claimed in claim 6, it is characterised in that it is described according to the heartbeat packet received to the heart The step of information described in detection record is updated is jumped, is specifically included:
The heartbeat detection time according to described in the reception time of the heartbeat packet updates the heartbeat detection record;
It is described to determine to detect the step of recording with the presence or absence of abnormal heartbeats in the heartbeat detection record, specifically include:
The heartbeat detection time described in each heartbeat detection record and the time difference of current poll time are calculated, and really The fixed heartbeat detection records center jumps detection time and the time difference of current poll time is examined beyond the heartbeat of predetermined threshold value Survey is recorded as the abnormal heartbeats detection record.
9. heartbeat detecting method as claimed in claim 6, it is characterised in that it is described according to the heartbeat packet received to the heart The step of information described in detection record is updated is jumped, is specifically included:
Heartbeat detection number of times according to described in the heartbeat packet received updates the heartbeat detection record;
It is described to determine to detect the step of recording with the presence or absence of abnormal heartbeats in the heartbeat detection record, specifically include:
It is continuous in default polling cycle that heartbeat detection number of times described in each heartbeat detection record is counted, and Determine that the heartbeat detection records center jumps detection number of times and keeps constant heartbeat detection to remember in the default polling cycle Record and detect record for the abnormal heartbeats.
10. a kind of computer-readable recording medium, the computer-readable recording medium storage has palmus detection system, the heart Jumping detecting system can be by least one computing device, so as to appoint at least one described computing device such as claim 6-9 The step of heartbeat detecting method described in one.
CN201710269323.4A 2017-04-24 2017-04-24 Heartbeat detecting method and application server Withdrawn CN106961364A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710269323.4A CN106961364A (en) 2017-04-24 2017-04-24 Heartbeat detecting method and application server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710269323.4A CN106961364A (en) 2017-04-24 2017-04-24 Heartbeat detecting method and application server

Publications (1)

Publication Number Publication Date
CN106961364A true CN106961364A (en) 2017-07-18

Family

ID=59483851

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710269323.4A Withdrawn CN106961364A (en) 2017-04-24 2017-04-24 Heartbeat detecting method and application server

Country Status (1)

Country Link
CN (1) CN106961364A (en)

Cited By (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107360239A (en) * 2017-07-25 2017-11-17 郑州云海信息技术有限公司 A kind of client connection status detection method and system
CN108809761A (en) * 2018-06-12 2018-11-13 威创集团股份有限公司 Presence detection method and device
CN108900370A (en) * 2018-06-08 2018-11-27 努比亚技术有限公司 It is long to connect multiple overtime judgment method, device and computer readable storage medium
CN108924195A (en) * 2018-06-20 2018-11-30 郑州云海信息技术有限公司 A kind of unidirectional heartbeat mechanism implementation method, device, equipment and system
CN109088799A (en) * 2018-09-28 2018-12-25 腾讯科技(深圳)有限公司 A kind of user end inserting method, device, terminal and storage medium
CN109602413A (en) * 2018-12-06 2019-04-12 Oppo广东移动通信有限公司 Heartbeat detecting method, device, storage medium and server
CN109992436A (en) * 2017-12-29 2019-07-09 华为技术有限公司 Thread block detection method and equipment
CN110224880A (en) * 2018-03-01 2019-09-10 华为技术有限公司 A kind of heartbeat inspecting method and monitoring device
CN111131458A (en) * 2019-12-25 2020-05-08 深圳市网心科技有限公司 Heartbeat keep-alive method, electronic device, system and medium
CN111901176A (en) * 2020-08-03 2020-11-06 京信通信系统(中国)有限公司 Fault determination method, device, equipment and storage medium
CN113014446A (en) * 2021-02-10 2021-06-22 北京字跳网络技术有限公司 Abnormal offline user detection method, device, server, storage medium and system
CN113220515A (en) * 2021-05-12 2021-08-06 武汉中仪物联技术股份有限公司 Mobile device connection state detection method and device, electronic device and storage medium
CN113746910A (en) * 2021-08-25 2021-12-03 湖北美和易思教育科技有限公司 H5 page reconnection server method, terminal and readable storage medium
CN113905005A (en) * 2021-09-30 2022-01-07 完美世界(北京)软件科技发展有限公司 Client state updating method and device for instant messaging
CN114885219A (en) * 2022-05-05 2022-08-09 北京达佳互联信息技术有限公司 Task execution state monitoring method and device, electronic equipment and storage medium
CN115022384A (en) * 2022-05-05 2022-09-06 北京北方华创微电子装备有限公司 HSMS communication connection method and device
CN115334141A (en) * 2022-08-03 2022-11-11 上海艺赛旗软件股份有限公司 Bidirectional data transmission system, method and device based on heartbeat mechanism
CN115550222A (en) * 2022-10-12 2022-12-30 云知声智能科技股份有限公司 Equipment abnormal state detection method, system, terminal and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102647314A (en) * 2012-05-16 2012-08-22 深圳市乐唯科技开发有限公司 Client side on-line state judgment method and system
CN103067209A (en) * 2013-01-25 2013-04-24 浪潮电子信息产业股份有限公司 Heartbeat module self-testing method
CN103139303A (en) * 2013-02-07 2013-06-05 网易(杭州)网络有限公司 Method, device and system used for maintaining connected heartbeat
CN103401714A (en) * 2013-08-01 2013-11-20 广东威创视讯科技股份有限公司 Method for detecting network connection state and client side
CN105635248A (en) * 2015-12-18 2016-06-01 Tcl集团股份有限公司 Method and system for releasing TCP (Transmission Control Protocol) connection resources
CN105827697A (en) * 2016-03-14 2016-08-03 广州趣丸网络科技有限公司 User off-line detection method and user off-line detection system
CN106341908A (en) * 2016-08-24 2017-01-18 福州瑞芯微电子股份有限公司 Method and system for maintaining long connection of mobile network

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102647314A (en) * 2012-05-16 2012-08-22 深圳市乐唯科技开发有限公司 Client side on-line state judgment method and system
CN103067209A (en) * 2013-01-25 2013-04-24 浪潮电子信息产业股份有限公司 Heartbeat module self-testing method
CN103139303A (en) * 2013-02-07 2013-06-05 网易(杭州)网络有限公司 Method, device and system used for maintaining connected heartbeat
CN103401714A (en) * 2013-08-01 2013-11-20 广东威创视讯科技股份有限公司 Method for detecting network connection state and client side
CN105635248A (en) * 2015-12-18 2016-06-01 Tcl集团股份有限公司 Method and system for releasing TCP (Transmission Control Protocol) connection resources
CN105827697A (en) * 2016-03-14 2016-08-03 广州趣丸网络科技有限公司 User off-line detection method and user off-line detection system
CN106341908A (en) * 2016-08-24 2017-01-18 福州瑞芯微电子股份有限公司 Method and system for maintaining long connection of mobile network

Cited By (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107360239A (en) * 2017-07-25 2017-11-17 郑州云海信息技术有限公司 A kind of client connection status detection method and system
CN109992436A (en) * 2017-12-29 2019-07-09 华为技术有限公司 Thread block detection method and equipment
CN110224880B (en) * 2018-03-01 2021-02-23 华为技术有限公司 Heartbeat monitoring method and monitoring equipment
CN110224880A (en) * 2018-03-01 2019-09-10 华为技术有限公司 A kind of heartbeat inspecting method and monitoring device
CN108900370A (en) * 2018-06-08 2018-11-27 努比亚技术有限公司 It is long to connect multiple overtime judgment method, device and computer readable storage medium
CN108900370B (en) * 2018-06-08 2021-12-17 努比亚技术有限公司 Long connection multiple timeout judging method, device and computer readable storage medium
CN108809761A (en) * 2018-06-12 2018-11-13 威创集团股份有限公司 Presence detection method and device
CN108809761B (en) * 2018-06-12 2020-09-04 威创集团股份有限公司 Online state detection method and device
CN108924195A (en) * 2018-06-20 2018-11-30 郑州云海信息技术有限公司 A kind of unidirectional heartbeat mechanism implementation method, device, equipment and system
CN109088799A (en) * 2018-09-28 2018-12-25 腾讯科技(深圳)有限公司 A kind of user end inserting method, device, terminal and storage medium
CN109088799B (en) * 2018-09-28 2021-09-14 腾讯科技(深圳)有限公司 Client access method, device, terminal and storage medium
CN109602413B (en) * 2018-12-06 2022-01-18 Oppo广东移动通信有限公司 Heartbeat detection method, heartbeat detection device, storage medium and server
CN109602413A (en) * 2018-12-06 2019-04-12 Oppo广东移动通信有限公司 Heartbeat detecting method, device, storage medium and server
CN111131458A (en) * 2019-12-25 2020-05-08 深圳市网心科技有限公司 Heartbeat keep-alive method, electronic device, system and medium
CN111901176A (en) * 2020-08-03 2020-11-06 京信通信系统(中国)有限公司 Fault determination method, device, equipment and storage medium
CN113014446A (en) * 2021-02-10 2021-06-22 北京字跳网络技术有限公司 Abnormal offline user detection method, device, server, storage medium and system
CN113220515A (en) * 2021-05-12 2021-08-06 武汉中仪物联技术股份有限公司 Mobile device connection state detection method and device, electronic device and storage medium
CN113746910A (en) * 2021-08-25 2021-12-03 湖北美和易思教育科技有限公司 H5 page reconnection server method, terminal and readable storage medium
CN113905005A (en) * 2021-09-30 2022-01-07 完美世界(北京)软件科技发展有限公司 Client state updating method and device for instant messaging
CN114885219A (en) * 2022-05-05 2022-08-09 北京达佳互联信息技术有限公司 Task execution state monitoring method and device, electronic equipment and storage medium
CN115022384A (en) * 2022-05-05 2022-09-06 北京北方华创微电子装备有限公司 HSMS communication connection method and device
CN114885219B (en) * 2022-05-05 2023-08-29 北京达佳互联信息技术有限公司 Task execution state monitoring method and device, electronic equipment and storage medium
CN115022384B (en) * 2022-05-05 2023-10-13 北京北方华创微电子装备有限公司 HSMS communication connection method and device
CN115334141A (en) * 2022-08-03 2022-11-11 上海艺赛旗软件股份有限公司 Bidirectional data transmission system, method and device based on heartbeat mechanism
CN115550222A (en) * 2022-10-12 2022-12-30 云知声智能科技股份有限公司 Equipment abnormal state detection method, system, terminal and storage medium

Similar Documents

Publication Publication Date Title
CN106961364A (en) Heartbeat detecting method and application server
US11704221B2 (en) Systems and methods for collecting, tracking, and storing system performance and event data for computing devices
CN108055264A (en) Dispatching device, method and the computer readable storage medium of stream pushing server
CN104182545A (en) Application program recommendation method and device
CN108416485A (en) Method for identifying ID, electronic device and computer readable storage medium
CN111767142B (en) Method for setting current limiting threshold of service node and service terminal equipment
CN108681504A (en) Automated testing method, test server and computer readable storage medium
CN107689982A (en) Multi-data source method of data synchronization, application server and computer-readable recording medium
US20130055271A1 (en) Apparatus and method for controlling polling
CN109617726A (en) Error log acquisition method and server
CN108243239A (en) A kind of method, apparatus, electronic equipment and system that web application service is provided
CN110533286B (en) Block chain-based coalition member management method and device and computer equipment
CN108268296A (en) Loading method, the client and server of page layout
CN108446171A (en) Electronic device, distributed system execute method for allocating tasks and storage medium
CN104581671A (en) Prompting method and device for data traffic
CN110287007A (en) Data call response method, server and computer readable storage medium
CN110401553B (en) Server configuration method and device
CN107395451A (en) Surfing flow abnormal processing method, device, equipment and storage medium
CN107666401A (en) A kind of configuration information obtaining method and terminal
CN109257256A (en) Apparatus monitoring method, device, computer equipment and storage medium
CN110598797B (en) Fault detection method and device, storage medium and electronic device
CN109462510B (en) CDN node quality evaluation method and device
CN107733785A (en) A kind of multiple terminals chat message synchronization removal method and device
CN112445504A (en) Equipment firmware upgrading method, device and system
CN113377710B (en) Data acquisition method and device and electronic equipment

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
WW01 Invention patent application withdrawn after publication

Application publication date: 20170718

WW01 Invention patent application withdrawn after publication