CN107317731A - A kind of detection method of client and server connection state - Google Patents
A kind of detection method of client and server connection state Download PDFInfo
- Publication number
- CN107317731A CN107317731A CN201710720070.8A CN201710720070A CN107317731A CN 107317731 A CN107317731 A CN 107317731A CN 201710720070 A CN201710720070 A CN 201710720070A CN 107317731 A CN107317731 A CN 107317731A
- Authority
- CN
- China
- Prior art keywords
- client
- server
- heartbeat frame
- detection method
- specified time
- 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.)
- Pending
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/10—Active monitoring, e.g. heartbeat, ping or trace-route
- H04L43/103—Active monitoring, e.g. heartbeat, ping or trace-route with adaptive polling, i.e. dynamically adapting the polling rate
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/08—Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
- H04L43/0805—Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
- H04L43/0811—Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability by checking connectivity
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/143—Termination or inactivation of sessions, e.g. event-controlled end of session
- H04L67/145—Termination or inactivation of sessions, e.g. event-controlled end of session avoiding end of session, e.g. keep-alive, heartbeats, resumption message or wake-up for inactive or interrupted session
Abstract
The present invention discloses a kind of client and the detection method of server connection state, judge whether the status attribute of client is in idle condition, if client is in idle condition, then client timing sends heartbeat frame to server, and judges whether within a specified time to receive the message back of server feedback;If client is with server just in data interaction, client sends heartbeat frame to server in real time, and judges whether within a specified time to receive the message back of server feedback.Such a detection method can reach balance between reducing the wasting of resources and eliminating connection delay.
Description
Technical field
The invention belongs to communication technical field, more particularly to a kind of side for detecting connection status between client and server
Method.
Background technology
In the program of CS frameworks, server mainly provides data management, data sharing, data and system maintenance and simultaneously
Hair control client.Client, which needs to set up with server for the specific business of user, to be connected, and is connected in client and server
Before connecing or in connection, business processing will be caused to fail if disconnecting, and cause the waste of resource, more severe patient may
Cause client obstruction collapse.
For above-mentioned situation, conventional mode is that client timing sends heartbeat frame to server, to confirm that client is
No to keep with server be connected, however, timing transmission heartbeat frame occurs a problem, such as client is every 20 seconds to service
Device, which sends a heartbeat frame, to be ensured online, if being disconnected connection after connection is confirmed, this will cause client to have one 20 seconds
Error condition (client thinks online, but actual broken), it is necessary to wait state after 20 seconds could be correct.In this rank
If section user's operation client, it is easy to because the problem of state is not to causing to block or collapsing.
If the transmission interval of heartbeat frame shortened, for example, sent by 20 seconds and be revised as sending for 5 seconds, then frequently sent and hold
The competition and waste of resource are easily caused, increases the probability of system fault.
If by the transmission time lengthening of heartbeat frame, the renewal delay of state is more serious.
The content of the invention
The purpose of the present invention, is to provide a kind of client and the detection method of server connection state, and it can reduced
Reach balance between the wasting of resources and elimination connection delay.
In order to reach above-mentioned purpose, solution of the invention is:
Whether the detection method of a kind of client and server connection state, judge the status attribute of client in the free time
State, if client is in idle condition, timing sends heartbeat frame;If client and server are just in data interaction,
Immediately heartbeat frame is sent.
The particular content that above-mentioned timing sends heartbeat frame is:Client timing sends heartbeat frame to server, and judgement is
It is no within a specified time to receive the message back of server feedback, if receiving, then it represents that client is connected normally with server;If
Do not receive, then client resends heartbeat frame after waiting setting time to server.
Above-mentioned client resends heartbeat frame after waiting setting time to server, and client is within a specified time received
The message back of server, then it represents that client is connected normally with server, waits timing next time to send heartbeat frame;If client
End does not receive the message back of server within a specified time, then judges client and server disconnecting, then timing automatic
Reconnect server.
Above-mentioned client is with server just in data interaction, then sending the particular content of heartbeat frame immediately is:If client
End is with server just in data interaction, then client sends heartbeat frame to server in real time, and judges whether at the appointed time
The message back of server feedback is inside received, if receiving, then it represents that client is normal with server communication, then starts client
With the data interaction of server;If not receiving, client resends heartbeat frame after waiting setting time to server.
Above-mentioned client resends heartbeat frame after waiting setting time to server, and client is within a specified time received
The message back of server, then it represents that client is connected normally with server, waits timing next time to send heartbeat frame;If client
End does not receive the message back of server within a specified time, then judges client and server disconnecting, then timing automatic
Reconnect server.
After such scheme, the present invention sends heartbeat frame in the timing of client idle phase, and when needing to interact i.e.
When send heartbeat frame, so, resource can be saved in idle phase, and connection delay can be then eliminated when needing to interact, prevented
Because server and client side obtains the inconsistent situation of state caused by delay.This invention removes the transmission of heartbeat frame timing
Caused latency issue, solving frequently transmission heartbeat frame causes the waste and competition of resource, can functionally reduce resource wave
Take and eliminate delay balance, it is not necessary to be concise in overall structure, it is not necessary to increase in order to which which function sacrifices another
The complexity of system.
Brief description of the drawings
Fig. 1 is the schematic diagram of the present invention.
Embodiment
Below with reference to accompanying drawing, technical scheme and beneficial effect are described in detail.
As shown in figure 1, the present invention provides a kind of client and the detection method of server connection state, including following step
Suddenly:
Step 1, first determine whether client status attribute whether in idle condition (client access server when
Waiting acquiescence original state attribute is:It is idle not with server communication;When client and server data interaction, client shape
State attribute is:With in server communication, it is busy), if client be in idle condition, 2 are gone to step, if client and server
Just in data interaction, then 4 are gone to step;
Step 2, when client is in idle condition, when there is no operational interaction demand with server, sent out using timing
Send the mode of heartbeat frame:I.e. client timing sends the message (i.e. heartbeat frame) of a specific format to server, subsequently into
One timing waiting for server replys operation;If client is connected normally with server, server can after message is received, to
Client feedback connection is normal to reply, when client within a specified time receives the reply, confirms that both connections are normal, and
The status attribute of client is updated to:It is idle not with server communication, return again to step 1;If client is connected with server
Abnormal, then client will not within a specified time receive the message back of server, then go to step 3;
Step 3, client is sent after heartbeat frame, does not receive the message back of server within a specified time, then to
During up to the specified time, client (can be set to 1s) after setting time and resend heartbeat frame to server, to confirm client
The signal intelligence (because the heartbeat frame that may be sent for the first time generates packet loss phenomenon) of end and server.If retransmitting heartbeat frame
Afterwards, client within a specified time has successfully received the response message of server, then confirms that client is connected normally with server, will
The status attribute of client is updated to:It is idle not with server communication, return again to step 1;If retransmitting after heartbeat frame, specifying
Still fail to receive the response message of server in time, then illustrate that client and server communication occurs abnormal, update client
Attribute status be:With server disconnecting, while client can every setting time (such as 5s) Auto-reconnect server, if
Client reconnects server success, then reenters step 1;
Step 4, when client needs to carry out data interaction with server, client sends heartbeat to server first
Frame, inquiry and the connection status of server.If client receives the response of server within the specified time after sending heartbeat frame,
Prove that client is normal with server communication, then start the data interaction of client and server, while updating client
Status attribute is:With in server communication, it is busy;If client is after heartbeat frame is sent, specifies in the time and do not receive server
Response message, then go to step 5;
Step 5, client is sent after heartbeat frame, if not receiving the response message of server, client within a specified time
(such as 1s) a heartbeat frame can be retransmitted after setting time, confirm the signal intelligence of client and server (because of possible first
The heartbeat frame of secondary transmission generates packet loss phenomenon).If retransmitting after heartbeat frame, client has successfully received the response message of server,
Then prove that client is normal with server communication, starts data interaction, while the status attribute for updating client is:With server
It is busy in communication;If still failing within a specified time to receive the response message of server after retransmitting heartbeat frame, illustrate client
There is exception with server communication, the attribute status for updating client is:With server disconnecting, while client can be every
Setting time (such as 5s) Auto-reconnect server;If client reconnects server success, step 1 is reentered.
The technological thought of above example only to illustrate the invention, it is impossible to which protection scope of the present invention is limited with this, it is every
According to technological thought proposed by the present invention, any change done on the basis of technical scheme each falls within the scope of the present invention
Within.
Claims (5)
1. the detection method of a kind of client and server connection state, it is characterised in that:Judging the status attribute of client is
No to be in idle condition, if client is in idle condition, timing sends heartbeat frame;If client is with server just in data
In interaction, then heartbeat frame is sent immediately.
2. the detection method of a kind of client as claimed in claim 1 and server connection state, it is characterised in that:It is described fixed
When send heartbeat frame particular content be:Client timing sends heartbeat frame to server, and judges whether within a specified time
The message back of server feedback is received, if receiving, then it represents that client is connected normally with server;If not receiving, client
End resends heartbeat frame after waiting setting time to server.
3. the detection method of a kind of client as claimed in claim 2 and server connection state, it is characterised in that:The visitor
Heartbeat frame is resend to server after family end wait setting time, the message that client within a specified time receives server is returned
It is multiple, then it represents that client is connected normally with server, wait timing next time to send heartbeat frame;If client is within a specified time
The message back of server is not received, then judges client and server disconnecting.
4. the detection method of a kind of client as claimed in claim 1 and server connection state, it is characterised in that:The visitor
Family end is with server just in data interaction, then sending the particular content of heartbeat frame immediately is:If client and server are
In data interaction, then client sends heartbeat frame to server in real time, and judges whether within a specified time to receive server anti-
The message back of feedback, if receiving, then it represents that client is normal with server communication, then starts client and the data of server
Interaction;If not receiving, client resends heartbeat frame after waiting setting time to server.
5. the detection method of a kind of client as claimed in claim 4 and server connection state, it is characterised in that:The visitor
Heartbeat frame is resend to server after family end wait setting time, the message that client within a specified time receives server is returned
It is multiple, then it represents that client is connected normally with server, wait timing next time to send heartbeat frame;If client is within a specified time
The message back of server is not received, then judges client and server disconnecting.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710720070.8A CN107317731A (en) | 2017-08-21 | 2017-08-21 | A kind of detection method of client and server connection state |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710720070.8A CN107317731A (en) | 2017-08-21 | 2017-08-21 | A kind of detection method of client and server connection state |
Publications (1)
Publication Number | Publication Date |
---|---|
CN107317731A true CN107317731A (en) | 2017-11-03 |
Family
ID=60177361
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710720070.8A Pending CN107317731A (en) | 2017-08-21 | 2017-08-21 | A kind of detection method of client and server connection state |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107317731A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108447161A (en) * | 2018-03-29 | 2018-08-24 | 董亮 | Lockset control method and device |
CN108966288A (en) * | 2018-06-28 | 2018-12-07 | 郑州云海信息技术有限公司 | A kind of communication means, client, server-side and communication system |
CN110336708A (en) * | 2019-05-24 | 2019-10-15 | 重庆科技学院 | A kind of elastic keep-alive system and method for Virtual cross-domain communication |
CN111294256A (en) * | 2020-02-21 | 2020-06-16 | 宁波海大物联科技有限公司 | On-line detection method for performance of communication module |
Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1411247A (en) * | 2001-09-29 | 2003-04-16 | 华为技术有限公司 | Method of realizing |
CN101234017A (en) * | 2008-02-26 | 2008-08-06 | 中兴通讯股份有限公司 | Method, system and central processing element for testing heartbeat |
CN101552740A (en) * | 2009-05-14 | 2009-10-07 | 腾讯科技(北京)有限公司 | Instant communication system, clients, server and method for judging on-line state |
CN102036349A (en) * | 2009-09-29 | 2011-04-27 | 联想(北京)有限公司 | Method for maintaining connection of terminal and network server, terminal and network server |
CN102647314A (en) * | 2012-05-16 | 2012-08-22 | 深圳市乐唯科技开发有限公司 | Client side on-line state judgment method and system |
US20140066063A1 (en) * | 2012-08-30 | 2014-03-06 | Samsung Electronics Co., Ltd. | Heartbeat period determination method and apparatus for push service in wireless network |
CN103685241A (en) * | 2013-11-26 | 2014-03-26 | 中国科学院计算技术研究所 | Adaptive heartbeat method and adaptive heartbeat system for maintaining long connection of TCP (transmission control protocol) |
CN103701667A (en) * | 2013-12-27 | 2014-04-02 | 乐视网信息技术(北京)股份有限公司 | Method, device and system for monitoring heartbeat of server |
CN104113883A (en) * | 2014-07-09 | 2014-10-22 | 深圳市双赢伟业科技股份有限公司 | Dormancy and wakeup method and system for wireless network |
CN105142175A (en) * | 2015-06-09 | 2015-12-09 | 刘芳 | Method for quickly detecting state of link between wireless network equipment |
CN105610913A (en) * | 2015-12-22 | 2016-05-25 | 用友网络科技股份有限公司 | Heartbeat keep-alive method and apparatus for long connection in communication network |
-
2017
- 2017-08-21 CN CN201710720070.8A patent/CN107317731A/en active Pending
Patent Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1411247A (en) * | 2001-09-29 | 2003-04-16 | 华为技术有限公司 | Method of realizing |
CN101234017A (en) * | 2008-02-26 | 2008-08-06 | 中兴通讯股份有限公司 | Method, system and central processing element for testing heartbeat |
CN101552740A (en) * | 2009-05-14 | 2009-10-07 | 腾讯科技(北京)有限公司 | Instant communication system, clients, server and method for judging on-line state |
CN102036349A (en) * | 2009-09-29 | 2011-04-27 | 联想(北京)有限公司 | Method for maintaining connection of terminal and network server, terminal and network server |
CN102647314A (en) * | 2012-05-16 | 2012-08-22 | 深圳市乐唯科技开发有限公司 | Client side on-line state judgment method and system |
US20140066063A1 (en) * | 2012-08-30 | 2014-03-06 | Samsung Electronics Co., Ltd. | Heartbeat period determination method and apparatus for push service in wireless network |
CN103685241A (en) * | 2013-11-26 | 2014-03-26 | 中国科学院计算技术研究所 | Adaptive heartbeat method and adaptive heartbeat system for maintaining long connection of TCP (transmission control protocol) |
CN103701667A (en) * | 2013-12-27 | 2014-04-02 | 乐视网信息技术(北京)股份有限公司 | Method, device and system for monitoring heartbeat of server |
CN104113883A (en) * | 2014-07-09 | 2014-10-22 | 深圳市双赢伟业科技股份有限公司 | Dormancy and wakeup method and system for wireless network |
CN105142175A (en) * | 2015-06-09 | 2015-12-09 | 刘芳 | Method for quickly detecting state of link between wireless network equipment |
CN105610913A (en) * | 2015-12-22 | 2016-05-25 | 用友网络科技股份有限公司 | Heartbeat keep-alive method and apparatus for long connection in communication network |
Non-Patent Citations (2)
Title |
---|
周凤石: ""基于Windows Socket的网络通信中的心跳机制原理及其实现"", 《沙洲职业工学院学报》 * |
鄢锋;桂卫华;胡志坤;冯怀成: ""一种网络节点通信控制的心跳模型"", 《信息与控制》 * |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108447161A (en) * | 2018-03-29 | 2018-08-24 | 董亮 | Lockset control method and device |
CN108966288A (en) * | 2018-06-28 | 2018-12-07 | 郑州云海信息技术有限公司 | A kind of communication means, client, server-side and communication system |
CN110336708A (en) * | 2019-05-24 | 2019-10-15 | 重庆科技学院 | A kind of elastic keep-alive system and method for Virtual cross-domain communication |
CN111294256A (en) * | 2020-02-21 | 2020-06-16 | 宁波海大物联科技有限公司 | On-line detection method for performance of communication module |
CN111294256B (en) * | 2020-02-21 | 2022-05-20 | 宁波海大物联科技有限公司 | On-line detection method for performance of communication module |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107317731A (en) | A kind of detection method of client and server connection state | |
CN102957623B (en) | A kind of maintaining method of neighborhood of border gate protocol and equipment | |
CN111901076B (en) | Vehicle diagnosis data forwarding method and device and gateway | |
CN109040295B (en) | Method and device for determining abnormal disconnection, terminal and storage medium | |
CN110995617B (en) | MQTT-based data transmission method and device, computer equipment and storage medium | |
CN104468380A (en) | Interface communication method of access point device and server interaction | |
CN107508916B (en) | Server link management method for intelligent robot | |
CN107948063B (en) | Method for establishing aggregation link and access equipment | |
CN105183687A (en) | Time-sharing serial communication method and system | |
CN113986501A (en) | Real-time database API (application program interface) uninterrupted calling method, system, storage medium and server | |
CN101207617A (en) | Method for data transmission of network storing system | |
CN104821889B (en) | A kind of processing method and equipment of backup message | |
CN112887416B (en) | Frequency adjustment method and device for sending keep-alive packets | |
CN112839106A (en) | Communication method and apparatus, electronic device, and medium | |
CN102868945A (en) | Upgrading method optical network unit (ONU) in Ethernet passive optical network (EPON) | |
CN113992740B (en) | Middleware based on autonomous control and data transmission method | |
CN113301103B (en) | Data processing system, method and device | |
KR101407597B1 (en) | System and method for providing push service | |
CN112087341B (en) | Communication method, system, electronic equipment and storage medium based on multichannel compensation | |
CN113965495A (en) | Method and device for detecting activity of terminal application program, electronic equipment and storage medium | |
CN110572440B (en) | Method and device for data transmission, household appliance and storage medium | |
CN110119111B (en) | Communication method and device, storage medium, and electronic device | |
US10491544B2 (en) | Consistency control of a logical path passing through a relay device | |
CN110166506B (en) | Method for connecting hypertext transfer protocol Http and node equipment | |
CN114095361B (en) | Equipment convergence maintenance method, device and network system |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20171103 |
|
RJ01 | Rejection of invention patent application after publication |