CN115766823A - Method and system for realizing disconnection reconnection of terminal APP and server based on TCP - Google Patents

Method and system for realizing disconnection reconnection of terminal APP and server based on TCP Download PDF

Info

Publication number
CN115766823A
CN115766823A CN202211315118.4A CN202211315118A CN115766823A CN 115766823 A CN115766823 A CN 115766823A CN 202211315118 A CN202211315118 A CN 202211315118A CN 115766823 A CN115766823 A CN 115766823A
Authority
CN
China
Prior art keywords
terminal
server
communication
terminal server
communication connection
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
Application number
CN202211315118.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.)
Inspur Software Co Ltd
Original Assignee
Inspur Software 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 Inspur Software Co Ltd filed Critical Inspur Software Co Ltd
Priority to CN202211315118.4A priority Critical patent/CN115766823A/en
Publication of CN115766823A publication Critical patent/CN115766823A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Abstract

The invention provides a method and a system for realizing disconnection and reconnection of a terminal APP and a server based on TCP (Transmission control protocol), wherein the method for realizing disconnection and reconnection of the terminal APP and the server based on TCP comprises the following steps: establishing communication connection with a terminal server according to the communication identifier and a transmission control protocol; the communication identifier represents an identifier fed back by an application program when the application program pushes application data to the terminal server; when the communication connection is established, establishing a heartbeat detection mechanism with the terminal server; and when the heartbeat detection mechanism represents that the communication connection is disconnected, the heartbeat detection mechanism is communicated with the terminal server again. The invention can solve the problem that the communication interruption can not be reconnected in time.

Description

Method and system for realizing disconnection reconnection of terminal APP and server based on TCP
Technical Field
The invention relates to the technical field of communication, in particular to a method and a system for realizing disconnection reconnection of a terminal APP and a server based on TCP.
Background
At present, most of the ways for realizing the APP communication from the terminal server to the terminal in the market are modes in which the terminal of the APP continuously sends a network request to the server so as to judge whether the server receives the third party information, and if so, the information is returned from the network response. This conventional model brings with it obvious disadvantages that the browser needs to send requests to the server continuously, however, HTTP requests may contain a long header, where the really valid data may be only a small part, which obviously wastes much resources such as bandwidth. Moreover, when other application programs are called by the terminal of the APP, communication connection cannot be established in time, and after the communication connection is established, the situation of communication interruption cannot be reconnected in time, so that information pushing is not in time.
Disclosure of Invention
The invention provides a method and a system for realizing disconnection reconnection of a terminal APP and a server based on TCP (Transmission control protocol), which can solve the problem that the reconnection cannot be carried out in time under the condition of communication interruption.
According to one aspect of the invention, the embodiment of the invention provides a method for realizing disconnection reconnection of a terminal APP and a server by a TCP (Transmission control protocol). The method comprises the steps of establishing communication connection with a terminal server according to a communication identifier and a transmission control protocol; the communication identifier represents an identifier fed back by an application program when the application program is called; when the communication connection is established, establishing a heartbeat detection mechanism with the terminal server; and when the heartbeat detection mechanism represents that the communication connection is disconnected, carrying out communication connection with the terminal server again.
In an embodiment, when the communication connection is established, establishing a heartbeat detection mechanism with the terminal server includes: sending heartbeat data packets to the terminal server according to preset interval time; wherein the step of detecting when the communication connection is disconnected comprises: and when the receipt data packet returned by the terminal server is not received within a first preset time period, determining that the communication connection is disconnected.
In an embodiment, before establishing a communication connection with a terminal server according to a communication identifier and a transmission control protocol, the method for achieving disconnection reconnection between a terminal APP and the server based on TCP further includes: generating the communication identifier according to a user instruction; wherein the user instruction comprises an instruction to invoke the application.
In an embodiment, the generating the communication identifier according to the user instruction includes: acquiring the call feedback of the application program according to the user instruction; acquiring the communication identifier according to the calling feedback; the communication identification represents the identity information of the terminal, and one communication identification corresponds to the unique terminal.
In an embodiment, the establishing a communication connection with the terminal server according to the communication identifier and the transmission control protocol further includes: establishing a communication preparation state with the terminal server according to the communication identifier and the transmission control protocol; and when receiving the application data pushed by the application program from the terminal server, establishing communication connection with the terminal server.
In an embodiment, the re-establishing the communication connection with the terminal server includes: according to the communication identifier and the transmission control protocol, establishing a communication preparation state with the terminal server again; and when the application data pushed by the application program is received from the terminal server, establishing communication connection with the terminal server.
In an embodiment, the transmission control protocol includes a three-way handshake protocol, and establishing a communication connection with the terminal server according to the communication identifier and the transmission control protocol includes: establishing a one-way communication channel or a two-way communication channel with the terminal server based on the three-way handshake protocol according to the communication identifier; the unidirectional communication channel is used for receiving the application data pushed by the terminal server, and the bidirectional communication channel is used for receiving the application data pushed by the terminal server and sending feedback data to the terminal server.
In an embodiment, the method for achieving disconnection and reconnection of the terminal APP and the server based on the TCP further includes: and when the terminal server does not receive the heartbeat data packet sent by the terminal APP in a second preset time period, terminating the communication connection with the terminal server.
In one embodiment, terminating the communication connection with the terminal server comprises: the connection is terminated by a four-way handshake with the terminal server.
According to another aspect of the present invention, a system for implementing disconnection and reconnection of a terminal APP and a server based on TCP is provided, which includes: the connection module is used for establishing communication connection with the terminal server according to the communication identifier and the transmission control protocol; the communication identifier represents an identifier fed back by an application program when the application program pushes application data to the terminal server; the establishing module is used for establishing a heartbeat detection mechanism with the terminal server when the communication connection is established; and the reconnection module is used for reestablishing the communication connection with the terminal server when the heartbeat detection mechanism represents that the communication connection is disconnected.
The invention provides a method and a system for realizing disconnection reconnection of a terminal APP and a server by TCP (Transmission control protocol), which can realize real-time communication between a terminal and a terminal server, can quickly detect and reconnect when the terminal is disconnected with the terminal server, better save server resources and bandwidth, and improve the information transmission stability of the terminal and the terminal server.
Drawings
The above and other objects, features and advantages of the present invention will become more apparent by describing in more detail embodiments of the present invention with reference to the attached drawings. In the drawings, like reference numbers generally represent like parts or steps.
Fig. 1 is a flowchart illustrating a method for implementing disconnection and reconnection of a terminal APP and a server based on TCP according to an exemplary embodiment of the present invention.
Fig. 2 is a schematic diagram of a heartbeat detection mechanism provided in an exemplary embodiment of the present invention.
Fig. 3 is a schematic diagram illustrating a principle of a method for achieving disconnection and reconnection of a terminal APP and a server based on TCP according to an exemplary embodiment of the present invention.
Fig. 4 is a flowchart of a system for implementing disconnection and reconnection of a terminal APP and a server based on TCP according to an exemplary embodiment of the present invention.
Detailed Description
Hereinafter, example embodiments according to the present invention will be described in detail with reference to the accompanying drawings.
Summary of The Invention
The terminal includes mobile terminal, binds the information and carries out the information interaction with the terminal server that this APP corresponds on mobile terminal's APP (Application, uses, indicates the Application of smart mobile phone generally) to make the user carry mobile terminal and can realize functions such as business registration in arbitrary time place, not only bring convenient operation for the user and experience, can also improve business processing efficiency. For example, the APPs on the terminal may include market supervision full-range electronization APPs (signature APPs) for implementing services such as market main body service registration and electronic signature confirmation, and a user may bind a market main body electronic business license certificate on the mobile terminal, perform services such as electronic signature confirmation on the mobile terminal, and interface with other third-party applications (such as a WeChat applet), so that electronic business license information of the market main body can be synchronized with a WeChat account through a mobile phone, and perform subsequent service handling by synchronizing to the signature APPs. Therefore, the APP of the terminal can be in communication connection with the terminal server corresponding to the APP and other third-party application programs, information interaction is carried out, and data are shared mutually, so that the mobile terminal can handle services.
However, when the terminal that signs the APP at present performs information interaction with the terminal server corresponding to the APP and the third-party application, the terminal that needs to sign the APP continuously sends a network request to the terminal server to determine whether the terminal server receives data requests sent by other third-party applications, but frequent request to the terminal server may cause overload of the terminal server, thereby causing delay of information transmission time, and frequent requests easily cause data redundancy, wasting a lot of resources such as bandwidth, and communication interruption due to some sudden network conditions and other reasons during communication, and failing to repair and reconnect communication in time, requiring much time to check and transmit information again. The current communication connection method can reduce the practicability and convenience of the terminal APP, so that users and processors can not finish services efficiently.
Therefore, the method and the system for realizing disconnection reconnection of the terminal APP and the server by the TCP can realize real-time communication between the terminal of the APP and the terminal server, can quickly detect and reconnect when the terminal is disconnected with the terminal server, better save server resources and bandwidth, and improve the information transmission stability of the terminal and the terminal server.
Exemplary method
Fig. 1 is a schematic flow chart of a method for achieving disconnection reconnection of a terminal APP and a server based on TCP according to an exemplary embodiment of the present invention, and as shown in fig. 1, the embodiment of the present invention provides a method for achieving disconnection reconnection of a terminal APP and a server based on TCP, including
Step 100: and establishing communication connection with the terminal server according to the communication identifier and the transmission control protocol.
The communication identifier represents an identifier fed back by the application program when the application program is called.
The terminal server can identify the APP identity of the terminal through the communication identifier or identify the terminal identity, each terminal corresponds to one communication identifier, and the terminal server can establish communication with the corresponding APP terminal through searching the communication identifiers. For example, when a signature APP is opened on a terminal and the signature APP calls a wechat applet, an interface calling the wechat applet returns an identifier, the identifier correspondingly returns when the wechat applet is awakened every time, the identifier has uniqueness, the identifier is used as a communication identifier, the identity of the terminal initiating a call request can be distinguished, and when a terminal server corresponds to a plurality of terminals, the terminal identity can be distinguished and communication connection can be established in real time. The terminal of the signature APP establishes a communication connection with the terminal server through a Transmission Control Protocol (TCP), for example, a three-way handshake Protocol is used to establish the communication connection.
In order to further reduce system data redundancy, when the terminal server receives application data pushed by a third-party application program, the corresponding terminal is searched through a communication identifier returned by the third-party application program, and the application data is sent to an APP of the terminal after communication connection is established. For example, the signature APP needs to call a wechat applet to perform data docking, a third-party server of the wechat applet performs data pushing to a terminal server through a private network, the terminal server searches a corresponding terminal through a communication identifier and pushes the application data to the signature APP of the terminal, and communication connection and data exchange are achieved. One server terminal can correspondingly serve a plurality of terminals and push application data to the plurality of terminals, so that the identity of each terminal can be distinguished through the communication identifier, and accurate one-way or two-way information transmission can be carried out.
Step 200: and when the communication connection is established, establishing a heartbeat detection mechanism with the terminal server.
After the terminal server establishes communication connection with the terminal of the APP through the transmission control protocol, the terminal of the APP immediately establishes a heartbeat detection timer for sending heartbeat data packets to the terminal server at regular time. The heartbeat detection mechanism is mainly used for detecting whether a connection link is normal in real time, and if no data exchange exists between the terminal server and the terminal, because the transmission control protocol connection is a state machine, for the condition, whether the terminal or the terminal server can not sense whether the connection with the other side is normal, the heartbeat detection mechanism is required to be adopted for detecting the communication connection in real time.
Step 300: and when the heartbeat detection mechanism indicates that the communication connection is disconnected, the heartbeat detection mechanism is in communication connection with the terminal server again.
After receiving the heartbeat data packet, the terminal server usually sends a receipt data packet to the terminal of the APP, and therefore, the condition that the heartbeat detection mechanism indicates that the communication connection is disconnected may include that the terminal does not receive the receipt data packet sent by the terminal server within a specified time, and at this time, it may be considered that the current connection is abnormal or has been interrupted, and the communication connection needs to be reestablished.
Fig. 2 is a schematic diagram illustrating a heartbeat detection mechanism according to an exemplary embodiment of the present invention, as shown in fig. 2, after the terminal establishes a connection with the terminal server (step 21), the terminal starts heartbeat detection (step 22), sends a heartbeat data packet to the terminal server (step 23), and detects whether the terminal receives a response piece data packet within a specified time period (step 24), and if the response piece data packet is received, performs a service operation (step 25). If the receipt data packet is not received, the communication connection can be disconnected, and at the moment, the terminal is in communication connection with the terminal server again.
The method for realizing disconnection reconnection of the terminal APP and the server by the TCP can realize real-time communication between the terminal and the terminal server, can quickly detect and reconnect when the terminal is disconnected with the terminal server, better saves server resources and bandwidth, and improves the information transmission stability between the terminal and the terminal server.
In an embodiment, the step 200 may include: sending heartbeat data packets to a terminal server according to preset interval time; wherein, when the communication detection mechanism indicates that the communication connection is disconnected, the method comprises: and when the receipt data packet returned by the terminal server is not received within the first preset time period, determining that the communication connection is disconnected.
The heartbeat packet comprises a data packet with a preset format, a heartbeat detection timer is established at the terminal and is sent at regular time, and the heartbeat detection timer can automatically set preset interval time. The condition that the heartbeat detection mechanism indicates that the communication connection is disconnected may include that the terminal does not receive a receipt data packet sent by the terminal server within a first preset time period, and at this time, it may be considered that the current connection is abnormal or has been interrupted, and the communication connection needs to be reestablished. The first preset time period can also be set autonomously according to requirements.
In an embodiment, before step 100, the method for implementing disconnection and reconnection of the terminal APP and the server based on TCP may further include: generating a communication identifier according to a user instruction; wherein the user instruction comprises an instruction to invoke an application.
The user instruction comprises that a user wants to call a third-party application program, or the user opens the application program needed to be used, the application program needs to call the third-party application program independently, according to the call instruction of the user or the application program in use, the call interface returns a unique corresponding identifier, and the identifier returned by the interface is used as a communication identifier and is used as an identifier for mutual identification of the terminal, the application program and the terminal server.
In one embodiment, generating the communication identifier according to the user instruction may include: acquiring the call feedback of the application program according to the user instruction; acquiring a communication identifier according to the calling feedback; the communication identification represents the identity information of the terminal, and one communication identification corresponds to the unique terminal.
The user instruction comprises that a user wants to call a third-party application program, or the user opens the application program needed to be used, the application program needs to call the third-party application program independently, the third-party application program can generate call feedback, namely an identifier returned by a call interface is unique, and the identifier is used as a communication identifier, so that the identity of a terminal initiating a call request can be distinguished and used as an identifier for mutually identifying the terminal, the application program and a terminal server. For example, when a user opens the signature APP, the signature APP automatically calls the wechat applet, an interface calling the wechat applet returns a corresponding identifier, the identifier serves as a communication identifier of the user terminal and also can serve as identity information of the user terminal, and when the terminal server needs to transmit data, the application data are transmitted to the terminal of the corresponding signature APP by searching and identifying the communication identifier.
In an embodiment, the step 100 may further include: establishing a ready communication state with a terminal server according to the communication identifier and a transmission control protocol; and when the application data pushed by the application program is received from the terminal server, establishing communication connection with the terminal server.
The method comprises the steps that a terminal of an application program in use of a user is connected with a terminal server according to a communication identifier and a transmission control protocol, the terminal enters a state of communication preparation, a third-party application program pushes a data request to the terminal server through a private network, after the terminal server receives third-party request data, the terminal is searched according to the unique communication identifier to carry out communication connection, and the third-party application data are sent to the terminal of the application program through the communication connection. For example, fig. 3 is a schematic diagram of a method for achieving disconnection and reconnection of a terminal APP and a server based on TCP according to an exemplary embodiment of the present invention, for example, as shown in fig. 3, a user opens a signature APP and needs to perform services such as electronic signature, the signature APP needs to call an associated wechat applet for information verification, at this time, the signature APP invokes the wechat applet, the wechat applet returns a unique communication identifier, and the wechat applet pushes an authentication result to a third-party server corresponding to the wechat applet, the third-party server pushes a data request to the terminal server through a dedicated network, at this time, the terminal server searches for the unique communication identifier, performs communication connection with the terminal that opens the signature APP, and sends application data of the wechat applet to the terminal through the internet, that is, the application data is synchronized to the signature APP, and executes services such as real-time signature. The WeChat applet can also synchronously sign information in the APP, and bidirectional information interaction is achieved. When the pushed application data exist, the actual communication connection is established for transmission, so that the server resource and the bandwidth can be saved.
In one embodiment, the step of reconnecting the communication connection with the terminal server comprises: according to the communication identifier and the transmission control protocol, establishing a communication preparation state with the terminal server again; and when receiving the application data pushed by the application program from the terminal server, establishing communication connection with the terminal server.
After receiving the heartbeat data packet, the terminal server usually sends a receipt data packet to the terminal of the APP, and therefore, the condition that the heartbeat detection mechanism indicates that the communication connection is disconnected may include that the terminal does not receive the receipt data packet sent by the terminal server within a specified time, and at this time, it may be considered that the current connection is abnormal or has been interrupted, and the communication connection needs to be reestablished. And the communication connection is carried out with the terminal server again, namely the terminal is positioned again according to the communication identifier, and the communication connection is established again based on the three-way handshake protocol in the transmission control protocol.
In one embodiment, the transmission control protocol includes a three-way handshake protocol, and the step 100 may include: establishing a one-way communication channel or a two-way communication channel with the terminal server based on a three-way handshake protocol according to the communication identifier; the unidirectional communication channel represents to receive application data pushed by the terminal server, and the bidirectional communication channel represents to receive the application data pushed by the terminal server and send feedback data to the terminal server.
The terminal and the terminal server can establish a one-way or two-way communication channel so as to perform information transmission and information synchronization, for example, the terminal and the terminal server independently receive application data transmitted by the terminal server in one way, or the terminal and the terminal server send feedback data to the two-way communication channel so as to complete information interaction between the terminal and the terminal server. And one server can correspond to a plurality of terminals, so that the server needs to search the corresponding terminal through a unique communication identifier, and the mess of information transmission in the plurality of terminals is prevented. Based on the communication identification, one server corresponds to a plurality of terminals, and establishes a one-way or two-way communication channel, so that a plurality of information synchronization and information transmission can be realized simultaneously, the data processing efficiency is improved, the service processing speed is improved, and the timeliness and the stability of information are ensured.
In an embodiment, the method for achieving disconnection and reconnection of the terminal APP and the server based on the TCP further includes: and when the terminal server does not receive the heartbeat data packet sent by the terminal APP in a second preset time period, terminating the communication connection with the terminal server.
Because the tcp connection is a state machine, for this situation, no matter the terminal or the terminal server can not sense whether the connection with the other party is normal, if the terminal does not receive the receipt data packet of the terminal server, it can be determined that the connection is abnormal or the connection is interrupted, and the terminal server does not receive the heartbeat data packet sent by the terminal or the terminal APP within a certain time, it can be considered that the terminal does not perform data exchange with the terminal server any more, and the terminal or the terminal server automatically closes the connection and releases resources, thereby preventing the communication connection from occupying too many network resources. For example, after the user uses the signature APP, the user closes the signature APP, at this time, the terminal and the terminal server are disconnected, the terminal does not send a heartbeat data packet to the terminal server any more, the terminal server does not return a receipt data packet to the terminal any more, and in this state, the duration exceeds a second preset time period (for example, five minutes), so that it can be determined that the user has finished using, the connection is automatically closed, resources are saved, and consumption is reduced.
In one embodiment, terminating the communication connection with the terminal server comprises: the connection is terminated by a four-way handshake with the terminal server.
When the terminal or the terminal server automatically closes the connection and releases the resources, the terminal can terminate the connection by performing four-way handshake with the terminal server, and the server resources are released.
Exemplary devices
Fig. 4 is a schematic flowchart of a system for achieving reconnection of a terminal APP and a server based on TCP according to an exemplary embodiment of the present invention, and as shown in fig. 4, the system 8 for achieving reconnection of a terminal APP and a server based on TCP includes: the connection module 81 is used for establishing communication connection with the terminal server according to the communication identifier and the transmission control protocol; the communication identifier represents an identifier fed back by the application program when the application program pushes application data to the terminal server; the establishing module 82 is used for establishing a heartbeat detection mechanism with the terminal server when the communication connection is established; and a reconnection module 83, configured to reestablish a communication connection with the terminal server when the heartbeat detection mechanism indicates that the communication connection is disconnected.
The system for realizing disconnection and reconnection of the terminal APP and the server by the TCP can realize real-time communication between the terminal and the terminal server, can quickly detect and reconnect when the terminal is disconnected with the terminal server, better saves server resources and bandwidth, and improves the information transmission stability of the terminal and the terminal server.
In an embodiment, the establishing module 82 may be further configured to: sending heartbeat data packets to a terminal server according to preset interval time; wherein, when the communication detection mechanism indicates that the communication connection is disconnected, the method comprises: and when the receipt data packet returned by the terminal server is not received within the first preset time period, determining that the communication connection is disconnected.
In an embodiment, the system 8 for implementing disconnection and reconnection of the terminal APP and the server based on TCP may be further configured to: generating a communication identifier according to a user instruction; wherein the user instruction comprises an instruction to invoke an application.
In an embodiment, the system 8 for achieving disconnection and reconnection of the terminal APP and the server based on the TCP may be further configured to: acquiring call feedback of an application program according to a user instruction; acquiring a communication identifier according to the calling feedback; the communication identification represents the identity information of the terminal, and one communication identification corresponds to the unique terminal.
In an embodiment, the connection module 81 may be further configured to: establishing a ready communication state with a terminal server according to the communication identifier and a transmission control protocol; and when the application data pushed by the application program is received from the terminal server, establishing communication connection with the terminal server.
In an embodiment, the reconnecting module 83 may be further configured to: according to the communication identifier and the transmission control protocol, establishing a communication preparation state with the terminal server again; and when the application data pushed by the application program is received from the terminal server, establishing communication connection with the terminal server.
In an embodiment, the connection module 81 may be further configured to: establishing a one-way communication channel or a two-way communication channel with the terminal server based on a three-way handshake protocol according to the communication identifier; the unidirectional communication channel represents to receive application data pushed by the terminal server, and the bidirectional communication channel represents to receive the application data pushed by the terminal server and send feedback data to the terminal server.
In an embodiment, the system 8 for achieving disconnection and reconnection of the terminal APP and the server based on the TCP may be further configured to: and when the terminal server does not receive the heartbeat data packet sent by the terminal APP in a second preset time period, terminating the communication connection with the terminal server.
In an embodiment, the system 8 for achieving disconnection and reconnection of the terminal APP and the server based on the TCP may be further configured to: the connection is terminated by a four-way handshake with the terminal server.
According to another aspect of the present invention, a computer-readable storage medium is provided, where the storage medium stores a computer program for executing the method for achieving disconnection and reconnection of a terminal APP and a server based on TCP according to any of the above embodiments.
According to another aspect of the present invention, there is provided an electronic apparatus including: a processor; a memory for storing processor-executable instructions; and the processor is used for executing the method for realizing disconnection and reconnection of the terminal APP and the server based on the TCP in any embodiment.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (10)

1. A method for realizing disconnection reconnection of a terminal APP and a server based on TCP is characterized by comprising the following steps:
establishing communication connection with a terminal server according to the communication identifier and a transmission control protocol; the communication identifier represents an identifier fed back by the application program when the application program is called;
when the communication connection is established, establishing a heartbeat detection mechanism with the terminal server;
and when the heartbeat detection mechanism represents that the communication connection is disconnected, the heartbeat detection mechanism is communicated with the terminal server again.
2. The method for achieving disconnection and reconnection of a terminal APP and a server based on TCP according to claim 1, wherein when the establishment of the communication connection is completed, establishing a heartbeat detection mechanism with the terminal server comprises:
sending heartbeat data packets to the terminal server according to preset interval time;
wherein the step of detecting when the communication connection is disconnected comprises:
and when the receipt data packet returned by the terminal server is not received within a first preset time period, determining that the communication connection is disconnected.
3. The method for achieving reconnection of a terminal APP to a server based on TCP as claimed in claim 1, wherein before establishing a communication connection with a terminal server according to a communication identifier and a transmission control protocol, the method for achieving reconnection of a terminal APP to a server based on TCP further comprises:
generating the communication identifier according to a user instruction; wherein the user instruction comprises an instruction to invoke the application.
4. The method for achieving disconnection and reconnection of a terminal APP and a server based on TCP according to claim 3, wherein the generating the communication identifier according to a user instruction comprises:
acquiring the call feedback of the application program according to the user instruction;
acquiring the communication identifier according to the calling feedback; the communication identification represents the identity information of the terminal, and one communication identification corresponds to the unique terminal.
5. The method for achieving disconnection and reconnection of a terminal APP and a server based on TCP according to claim 1, wherein establishing a communication connection with the terminal server according to a communication identifier and a transmission control protocol further comprises:
establishing a communication preparation state with the terminal server according to the communication identifier and the transmission control protocol;
and when receiving the application data pushed by the application program from the terminal server, establishing communication connection with the terminal server.
6. The method for achieving disconnection and reconnection of a terminal APP and a server based on TCP according to claim 5, wherein said reconnecting the communication connection with the terminal server comprises:
according to the communication identifier and the transmission control protocol, establishing a communication preparation state with the terminal server again;
and when the application data pushed by the application program is received from the terminal server, establishing communication connection with the terminal server.
7. The method for achieving disconnection and reconnection of a terminal APP and a server based on TCP as claimed in claim 1, wherein the TCP includes a three-way handshake protocol, and the establishing of the communication connection with the terminal server according to the communication identifier and the TCP includes:
establishing a one-way communication channel or a two-way communication channel with the terminal server based on the three-way handshake protocol according to the communication identifier; the unidirectional communication channel is used for receiving the application data pushed by the terminal server, and the bidirectional communication channel is used for receiving the application data pushed by the terminal server and sending feedback data to the terminal server.
8. The method for achieving reconnection of a terminal APP to a server based on TCP as claimed in claim 1, wherein the method for achieving reconnection of a terminal APP to a server based on TCP further comprises:
and when the terminal server does not receive the heartbeat data packet sent by the terminal APP within a second preset time period, terminating the communication connection with the terminal server.
9. The method for achieving disconnection and reconnection of a terminal APP and a server based on TCP according to claim 8, wherein terminating the communication connection with the terminal server comprises:
the connection is terminated by a four-way handshake with the terminal server.
10. System for realizing disconnection reconnection of terminal APP and server based on TCP comprises:
the connection module is used for establishing communication connection with the terminal server according to the communication identifier and the transmission control protocol; the communication identifier represents an identifier fed back by an application program when the application program pushes application data to the terminal server;
the establishing module is used for establishing a heartbeat detection mechanism with the terminal server when the communication connection is established;
and the reconnection module is used for reestablishing the communication connection with the terminal server when the heartbeat detection mechanism shows that the communication connection is disconnected.
CN202211315118.4A 2022-10-26 2022-10-26 Method and system for realizing disconnection reconnection of terminal APP and server based on TCP Pending CN115766823A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211315118.4A CN115766823A (en) 2022-10-26 2022-10-26 Method and system for realizing disconnection reconnection of terminal APP and server based on TCP

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211315118.4A CN115766823A (en) 2022-10-26 2022-10-26 Method and system for realizing disconnection reconnection of terminal APP and server based on TCP

Publications (1)

Publication Number Publication Date
CN115766823A true CN115766823A (en) 2023-03-07

Family

ID=85353202

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211315118.4A Pending CN115766823A (en) 2022-10-26 2022-10-26 Method and system for realizing disconnection reconnection of terminal APP and server based on TCP

Country Status (1)

Country Link
CN (1) CN115766823A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103428287A (en) * 2013-08-09 2013-12-04 华为技术有限公司 Method and device for establishing connection
CN104270339A (en) * 2014-09-01 2015-01-07 腾讯科技(深圳)有限公司 Reconnection method, equipment and system for TCP (Transmission Control Protocol) connection
CN109413612A (en) * 2018-10-22 2019-03-01 深圳市元征科技股份有限公司 A kind of communication connection method for building up and equipment
CN112202626A (en) * 2020-08-04 2021-01-08 长春创世麒麟科技有限公司 Real-time data communication heartbeat packet pushing method
CN113726731A (en) * 2021-07-15 2021-11-30 浪潮软件股份有限公司 Method and system for realizing real-time communication between terminal APP and server based on TCP
CN113746910A (en) * 2021-08-25 2021-12-03 湖北美和易思教育科技有限公司 H5 page reconnection server method, terminal and readable storage medium
CN114422571A (en) * 2021-12-31 2022-04-29 广东国腾量子科技有限公司 Quantum communication client disconnection reconnection system and method

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103428287A (en) * 2013-08-09 2013-12-04 华为技术有限公司 Method and device for establishing connection
CN104270339A (en) * 2014-09-01 2015-01-07 腾讯科技(深圳)有限公司 Reconnection method, equipment and system for TCP (Transmission Control Protocol) connection
CN109413612A (en) * 2018-10-22 2019-03-01 深圳市元征科技股份有限公司 A kind of communication connection method for building up and equipment
CN112202626A (en) * 2020-08-04 2021-01-08 长春创世麒麟科技有限公司 Real-time data communication heartbeat packet pushing method
CN113726731A (en) * 2021-07-15 2021-11-30 浪潮软件股份有限公司 Method and system for realizing real-time communication between terminal APP and server based on TCP
CN113746910A (en) * 2021-08-25 2021-12-03 湖北美和易思教育科技有限公司 H5 page reconnection server method, terminal and readable storage medium
CN114422571A (en) * 2021-12-31 2022-04-29 广东国腾量子科技有限公司 Quantum communication client disconnection reconnection system and method

Similar Documents

Publication Publication Date Title
US8848893B2 (en) Method and apparatus for callback processing in telecommunication capability opening
KR101042745B1 (en) System and method for reestablishing the session between terminal and server
WO2019075863A1 (en) Service response method and terminal therefor
RU2501178C2 (en) Background service process unit, agent system and call control method in said system
JP2015535414A (en) Unprepared terminal call
CN106686056A (en) Android client communication device and method allowing Android client communication device to connect and communicate with server
WO2008074244A1 (en) An instant messaging method, system and apparatus
CN105407008A (en) Reconnecting method and system for interrupted TCP (Transmission Control Protocol) connection, terminal and server
WO2013189313A1 (en) Method and device for achieving remote manipulation
CN109286593A (en) Transmit method and device, computer equipment and the storage medium of reconnection
KR100498361B1 (en) Synchronization method for wireless internet in mobile communication device
CN106657076B (en) TCP service implementation method and device for network name space
CN106231538B (en) Method and device for binding OneM2M architecture equipment
EP2536067B1 (en) Apparatus and method for implementing point to point protocol data service link-disconnect
CN110337079B (en) 5G network communication method, terminal, network equipment and server
CN115766823A (en) Method and system for realizing disconnection reconnection of terminal APP and server based on TCP
CN116743624A (en) Communication connection method, device, terminal equipment and storage medium
WO2013123688A1 (en) Method and device for data access
CN106488537B (en) Sending method, device and mobile terminal
CN113726731A (en) Method and system for realizing real-time communication between terminal APP and server based on TCP
CN108174458B (en) Method and device for wireless connection between mobile terminal and wearable device, mobile terminal and wearable device
JP4697594B2 (en) PDP context control system, method, program, and portable terminal
WO2019029297A1 (en) Method and device for establishing data channel, and non-volatile computer readable storage medium
CN104811426A (en) Method for sending registration request through user agency client and user agency client
CN114095280B (en) Cloud platform server communication channel construction method, communication method, device and server

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