A long connection control method and device

By monitoring and restoring the long-lived connection state of instant messaging applications in real time, the message delay problem caused by the disconnection of TCP long-lived connections was solved, thus improving the user experience.

CN120301797BActive Publication Date: 2026-04-14HONOR DEVICE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-04
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

In instant messaging applications, message delays or lack of notifications due to the disconnection of TCP long connections negatively impact user experience.

Method used

By monitoring the persistent connection status of instant messaging applications and immediately controlling the re-establishment of the connection when a disconnection is detected, long-term disconnections are avoided, and real-time connection recovery is achieved using monitoring and sensing units in electronic devices.

Benefits of technology

Ensure the real-time communication of instant messaging applications, prevent message delays or lack of notifications, and improve user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120301797B_ABST
    Figure CN120301797B_ABST
Patent Text Reader

Abstract

The application discloses a long connection control method and device, and is applied to an electronic device. The long connection control method provided by the application comprises the following steps: firstly, after a long connection of a target process is disconnected, a target application to which the target process belongs is determined. Then, indication information is sent to the target application to indicate that the long connection of the target process is re-established. Through the implementation scheme, after the long connection of any process is disconnected, the corresponding application can immediately re-establish the long connection of the process. Thus, the long connection can be avoided from being disconnected for a long time, the situation that instant messaging application message prompt is delayed or not prompted can be prevented, and the real-time performance of communication is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of terminal technology, and in particular to a long-connection control method and device. Background Technology

[0002] When sending and receiving messages through instant messaging applications, users often encounter delayed or nonexistent message notifications, impacting the user experience. Analysis revealed that the root cause is the breakage of the persistent connection between the application and the server, preventing communication and timely message reception. Summary of the Invention

[0003] The purpose of this invention is to provide a long-connection control method and device to solve the problem of delayed or non-existent message reminders in certain types of applications (such as instant messaging applications, applications with integrated instant messaging functions, or applications with integrated push notification functions) by monitoring and controlling the long-connection status, thereby improving the user experience.

[0004] In a first aspect, the present invention provides a long connection control method applied to an electronic device. The long connection control method provided by the present invention includes: detecting the disconnection of a long connection of a target process, determining the target application to which the target process belongs, and sending an indication message to the target application, the indication message being used to instruct the re-establishment of the long connection of the target process.

[0005] In the above implementation, the electronic device can monitor the long-connection status of the target process. Once it detects that the long-connection of the target process has been broken, it can determine the application to which the target process belongs and immediately notify the corresponding application to re-establish the long-connection. This avoids prolonged long-connection breaks, preventing delayed or non-existent message notifications in instant messaging applications, ensuring real-time communication, and improving user experience.

[0006] In some implementations of the long connection control method described above, the electronic device includes a listening unit and an execution unit; upon detecting the disconnection of a long connection of a target process and determining the target application to which the target process belongs, the listening unit receives a first notification message sent by the execution unit, the first notification message being used to notify the target process of the long connection disconnection and the identification information of the target process; the listening unit determines the target application to which the target process belongs based on the identification information of the target process.

[0007] In the above implementation scheme, the monitoring unit can be used to monitor the long-connection status of each process through the execution unit. After detecting that the long-connection of any process has been broken, it can determine the application to which the process belongs and then immediately control the corresponding application to re-establish the long-connection of the process. This can avoid long-term disconnection of long-connections, prevent situations where instant messaging applications experience delayed or no message prompts, ensure real-time communication, and improve user experience.

[0008] In one implementation of the long connection control method described above, the listening unit determines the target application to which the target process belongs based on the identification information of the target process, including: the listening unit queries a target mapping table based on the identification information of the target process, the target mapping table containing the mapping relationship between each created process and its respective application; and the listening unit determines the target application to which the target process belongs based on the query result.

[0009] In some implementations of the long connection control method described above, the long connection control method provided by the present invention further includes: a listening unit acquiring the identification information of each created process and the application identification information of the application to which each created process belongs; and the listening unit generating a target mapping relationship table based on the identification information of each created process and the application identification information of the application to which each created process belongs.

[0010] In this implementation, the monitoring unit can establish a mapping table between applications and processes after any application creates a process. Therefore, when a long connection for any process is detected to be broken, the application to which the current process belongs can be determined based on the mapping table, facilitating precise control over the corresponding application to re-establish the long connection.

[0011] In some implementations of the long connection control method described above, the electronic device provided by the present invention further includes a sensing unit; the listening unit acquires the identification information of each created process and the application identification information of the application to which each created process belongs, including: the sensing unit receiving the application identification information and the identification information of the created process sent by each application; the sensing unit sending the application identification information and the identification information of the created process to the listening unit.

[0012] In this implementation, a sensing unit is added to the application layer of the electronic device. The sensing unit directly interacts with various applications to obtain the information required by the monitoring unit. This avoids third-party applications from directly accessing the monitoring unit of the electronic device, which helps to enhance the security and reliability of the device.

[0013] In some implementations of the long-connection control method described above, the aforementioned applications are instant messaging applications, or applications that integrate instant messaging functionality.

[0014] In some implementations of the long connection control method described above, before the listening unit receives the first notification message sent by the execution unit, the long connection control method provided by the present invention further includes: the listening unit sending a first prompt message to the sensing unit, the first prompt message being used to prompt the establishment of the target process of the target application; the sensing unit generating a first timestamp in response to the first prompt message; and the sensing unit sending a first event message to the target management platform, the first event message including the first timestamp and information on the establishment of the long connection of the target process of the target application.

[0015] In this implementation, the sensing unit can send events indicating the establishment of long connections for each application process to the target management platform, thereby enabling the target management platform to perform statistical analysis on the long connection status of each application process in the live network.

[0016] In some implementations of the long connection control method described above, before the monitoring unit sends the first prompt information to the sensing unit, the long connection control method provided by the present invention further includes: the monitoring unit receiving a second notification message sent by the execution unit, the second notification message being used to notify the target process of the establishment of a long connection and the identification information of the target process.

[0017] In some implementations of the long connection control method described above, after the listening unit receives the first notification message sent by the execution unit, the long connection control method provided by the present invention further includes: the listening unit sending a second prompt message to the sensing unit; the sensing unit generating a second timestamp in response to the second prompt message; and the sensing unit sending a second event message to the target management platform, the second event message including the second timestamp and information about the long connection being disconnected in the target process of the target application.

[0018] In this implementation, the sensing unit can send an event indicating that a long connection of an application process has been disconnected to the target management platform, thereby enabling the target management platform to perform statistical analysis on the long connection status of each application process in the current network.

[0019] In some implementations of the long connection control method described above, the first event information and the second event information are used by the target management platform to implement long connection information statistics.

[0020] In some implementations of the long connection control method described above, sending instruction information to the target application includes: the sensing unit responding to a second prompt message sent by the listening unit and sending an instruction message to the target application to re-establish a long connection to the target process.

[0021] In this implementation, by having the sensing unit directly interact with various applications, the direct access of third-party applications to the electronic device's listening unit can be avoided, which helps to enhance the device's security and reliability.

[0022] In some implementations of the long-connection control method described above, the listening unit includes the network daemon netd.

[0023] In some implementations of the long-connection control method described above, the identification information of the target process includes a user identifier (UID) and a process identifier (PID).

[0024] Secondly, this technical solution provides an electronic device, including: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs include instructions that, when executed by the device, cause the device to perform the method of the first aspect or any possible implementation thereof.

[0025] Thirdly, the present invention also provides a chip, the chip including a processor and a data interface, wherein the processor reads instructions stored in a memory through the data interface and executes the method in the first aspect or any possible implementation thereof.

[0026] Optionally, as one implementation, the chip may further include a memory storing instructions, and the processor is configured to execute the instructions stored in the memory. When the instructions are executed, the processor is configured to perform the method in the first aspect or any possible implementation thereof.

[0027] Fourthly, the present invention also provides a computer-readable storage medium storing program code for execution by a device, the program code including instructions for performing the method in the first aspect or any possible implementation thereof. Attached Figure Description

[0028] Figure 1 This is a schematic diagram of a network address translation scenario provided in an embodiment of this application;

[0029] Figure 2 This is a timing diagram of a NAT timeout scenario provided in an embodiment of this application;

[0030] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;

[0031] Figure 4This is a schematic diagram of the software structure of an electronic device provided in an embodiment of this application;

[0032] Figure 5 This is a schematic flowchart of a long connection control method provided in an embodiment of this application;

[0033] Figure 6 This is a schematic diagram of a scenario for the long connection control method provided in an embodiment of this application;

[0034] Figure 7 This is another schematic flowchart of the long connection control method provided in the embodiments of this application;

[0035] Figure 8 This is another schematic flowchart of the long connection control method provided in the embodiments of this application. Detailed Implementation

[0036] Nowadays, there are more and more instant messaging applications, or applications that integrate instant messaging functions, and people's communication largely depends on these applications. In scenarios where users communicate with each other using instant messaging applications, users always hope to receive messages sent by others in a timely manner to ensure real-time communication. However, in reality, users often encounter situations where message notifications are delayed or even nonexistent, resulting in the inability to view messages in a timely manner and potentially delaying important matters.

[0037] Analysis revealed that the delay or absence of message notifications was caused by the disconnection of the long-lived Transmission Control Protocol (TCP) connection between the application and the server, preventing the application from communicating with the server and receiving messages from the other end in a timely manner.

[0038] The following is a detailed explanation.

[0039] Specifically, instant messaging applications typically rely on persistent TCP connections for communication. A persistent TCP connection is a connection that needs to be established between communicating parties when using the TCP protocol. After a persistent TCP connection is established, it remains open after the parties complete a read / write operation, allowing subsequent read / write operations to continue using this connection; hence the name "persistent connection." However, in real-world scenarios, many factors can cause persistent connections to break abruptly. These include Network Address Translation (NAT) timeouts, changes in network status, and the killing of the process running the persistent connection. Once a persistent connection is broken, the application will be unable to communicate with the server, and neither party will be able to receive messages from the other, leading to delayed or absent message notifications in instant messaging applications.

[0040] To facilitate understanding, the following explanation, with reference to the accompanying diagram, uses the scenario of a long connection being disconnected due to a NAT timeout as an example to illustrate the reasons for delayed or absent message notifications in instant messaging applications.

[0041] It should be understood that the following description of NAT timeout scenarios is merely an illustrative example of the reasons that cause long-lived connections to break, and is not intended to limit this application.

[0042] Specifically, such as Figure 1 As shown, when a local area network (LAN) device accesses an internet server, it needs to translate its private IP address into a public IP address. After a long-lived connection is established between the two communicating parties, the gateway server's routing table stores the mapping between internal network address ports and public network address ports. During communication, both parties can use this mapping to translate their private IP addresses into public IP addresses; this process is called "Network Address Translation" (NAT).

[0043] If a persistent connection receives no data communication within a set timeout period, the gateway server will remove the mapping from its routing table, causing the connection to break. This set timeout period is the NAT timeout period. Therefore, once a persistent connection is established, the instant messaging application needs to periodically send heartbeat packets to the server to maintain the connection. The heartbeat packet sending interval must be shorter than the NAT timeout period; otherwise, the persistent connection will break.

[0044] Figure 2 This describes a specific scenario that triggers a NAT timeout.

[0045] like Figure 2 As shown, instant messaging applications include two types of heartbeats: NAT heartbeats and wake-up heartbeats. NAT heartbeats are used to periodically send heartbeat packets to the server to prevent NAT timeouts. Wake-up heartbeats are used for periodic system wake-ups, thus saving system power consumption while ensuring that all applications within the system can receive messages promptly.

[0046] like Figure 2 As shown, assuming the NAT heartbeat interval is 210 seconds and the sleep-wake heartbeat interval is 300 seconds, in real-world scenarios, the NAT heartbeat node resets upon receiving a message from the peer device. Specifically, as... Figure 2 As shown, if an instant messaging application receives a message from the peer device at time node B1, the heartbeat node will be reset based on time node B1, and the next heartbeat will be reset to time node B2, which is 210 seconds after time node B1. In other words, to avoid NAT timeouts, the instant messaging application needs to send a heartbeat packet to the server before time node B2.

[0047] However, when the instant messaging application receives a message from the peer device at time node B1, it is in a sleep state and therefore cannot detect the message. It's not until time node A2 that the sleep-wake heartbeat is triggered, and the instant messaging application misinterprets time node A2 as the time the message was received. Furthermore, based on the aforementioned principle of NAT heartbeat node reset, the instant messaging application determines time node B3, 210 seconds after time node A2, as the next heartbeat node. It's understandable that time node B3 is clearly after time node B2, causing a NAT timeout.

[0048] After a NAT timeout, the mapping relationship stored in the routing table is deleted, and the persistent connection is broken. Consequently, the application cannot communicate with the server and cannot receive messages sent by the peer. With the persistent connection broken, the instant messaging application will only re-establish the persistent connection if the next NAT heartbeat fails. Only after the persistent connection is successfully re-established can the server deliver messages previously sent by the peer device to the application. Understandably, because a considerable amount of time has passed since the peer device sent the message, the user may experience delayed message notifications or even no notifications at all.

[0049] This application is submitted to address the aforementioned issues.

[0050] This application utilizes relevant unit modules within an electronic device to monitor the long-lived connection status of various instant messaging applications within the device. For example, a network daemon (netd) between the kernel layer and framework layer of the electronic device can be used to monitor the long-lived connection status of each instant messaging application. Upon detecting a long-lived connection break in any process, the target application to which that process belongs can be determined, and then an instruction message can be immediately sent to the target application to instruct it to re-establish the long-lived connection for that process.

[0051] The above technical solution enables immediate reconnection of any instant messaging application when a long connection is lost, without waiting for the next failed heartbeat. This shortens the waiting time between connection loss and reconnection, preventing delayed or nonexistent message notifications in instant messaging applications and maintaining the real-time nature of communication.

[0052] Figure 3 A schematic diagram of the structure of the electronic device 100 provided in an embodiment of this application is shown.

[0053] Electronic device 100 may include processor 110, external memory interface 120, internal memory 121, universal serial bus (USB) interface 130, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and subscriber identification module (SIM) card interface 195, etc.

[0054] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0055] Processor 110 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). These different processing units may be independent devices or integrated into one or more processors.

[0056] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.

[0057] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0058] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0059] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple I2C buses. The processor 110 can couple to the touch sensor 180K, charger, flash, camera 193, etc., through different I2C bus interfaces. For example, the processor 110 can couple to the touch sensor 180K through the I2C interface, enabling the processor 110 and the touch sensor 180K to communicate through the I2C bus interface, thereby realizing the touch function of the electronic device 100.

[0060] The MIPI interface can be used to connect the processor 110 and the display screen 194. The processor 110 and the display screen 194 communicate through the DSI interface to realize the display function of the electronic device 100.

[0061] It is understood that the interface connection relationships between the modules illustrated in the embodiments of the present invention are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.

[0062] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0063] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.

[0064] Internal memory 121 can be used to store computer executable program code, which includes instructions. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as a long-connection status reporting function), etc. The data storage area may store data created during the use of electronic device 100 (such as process identifiers), etc. In addition, internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. Processor 110 executes various functional applications and data processing of electronic device 100 by running instructions stored in internal memory 121 and / or instructions stored in memory disposed in the processor.

[0065] Figure 4 This is a software structure block diagram of the electronic device 100 according to an embodiment of the present invention.

[0066] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the electronic device 100 may include, from top to bottom, an application layer, an application framework layer, and a kernel layer.

[0067] The application layer can include a series of application packages.

[0068] like Figure 4 As shown, the application package may include at least one instant messaging application, calling, map, navigation, SMS and other applications.

[0069] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.

[0070] like Figure 4 As shown, the application framework layer may include a notification manager, content provider, view system, phone manager, resource manager, window manager, etc.

[0071] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager is used for message notifications in instant messaging applications. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting alert sounds, vibrating electronic devices, and flashing indicator lights.

[0072] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0073] The kernel layer is the layer between hardware and software. The kernel layer contains at least an execution unit, which can be used to establish long-lived connections between instant messaging applications and the server based on instructions from the upper layer.

[0074] Between the kernel layer and the framework layer, there may also be a listening unit, which can be used to monitor the long-lived connection status of various applications in the application layer. Specifically, the listening unit can be netd.

[0075] The following embodiments of this application will be used to illustrate having Figure 3 , Figure 4 Taking the electronic device with the structure shown as an example, the long connection control method provided in the embodiments of this application will be specifically described.

[0076] Figure 5 This is a schematic flowchart of a long-connection control method provided in an embodiment of this application, such as... Figure 5 As shown, the long-connection control method provided in this application includes:

[0077] 101. The listening unit receives the first notification message sent by the execution unit. The first notification message is used to notify the target process that the long connection has been broken and to provide the target process's identification information.

[0078] 102. The monitoring unit determines the target application to which the target process belongs based on the identification information of the target process.

[0079] 103. The monitoring unit controls the target application to re-establish a long connection to the target process.

[0080] In this embodiment of the application, the listening unit may pre-register events to be listened to for a specific application.

[0081] The specific type of application can be determined based on the actual scenario or user needs. For example, a specific application can be an application in the actual scenario where the user has high requirements for real-time communication. For example, it can include any instant messaging application, or it can also include applications that integrate instant messaging functions, applications that integrate message push functions, etc.

[0082] In this embodiment of the application, the aforementioned specific applications can be set before the electronic device leaves the factory, or they can be set by the user.

[0083] For user-defined implementation methods, please refer to [link / reference]. Figure 6 For example, a message notification control can be displayed in the application settings interface 61 of the electronic device. In response to a triggering operation on the message notification control, the electronic device can display a message notification mode settings interface 62. The message notification mode settings interface 62 can contain application icons for each application within the electronic device. In response to a triggering operation on any application icon, the electronic device can display a real-time notification toggle control, which can be used to enable or disable the real-time notification function for that application. When enabled, the electronic device identifies that application as a specific application.

[0084] The events to be monitored can include long connection establishment events and long connection termination events for the aforementioned specific applications. Therefore, during the operation of the electronic device, the monitoring unit can be used to monitor the long connection status of these specific applications.

[0085] Specifically, taking any specific application (hereinafter referred to as "Application A") as an example, after any process in Application A (hereinafter referred to as "Process 1") is created, if Application A determines that the business corresponding to Process 1 needs to establish a long connection, then Application A can send a control message to the execution unit to establish a long connection. This control message may carry the identification information of Process 1, including at least the Process Identification (PID) and User Identification (UID). This control message can be used to instruct the execution unit to establish a long connection for Process 1.

[0086] After receiving the control message for establishing a long connection sent by application A, the execution unit first communicates with the server to establish the long connection for process 1. The specific establishment process can be found in existing technologies and will not be elaborated upon here. After the long connection for process 1 is established, the execution unit sends a notification message to the listening unit, which may carry the identification information of process 1. Based on the identification information of process 1, the listening unit can determine the application A corresponding to process 1 according to the pre-obtained correspondence between each created process and application.

[0087] Furthermore, due to any possible factors, when the long connection of process 1 is broken, the execution unit can send a notification message to the listening unit indicating that the long connection of process 1 has been broken. This notification message may carry the identification information of process 1. Similarly, based on the identification information of process 1, the listening unit can determine the application A corresponding to process 1 according to the pre-obtained correspondence between each created process and application. The breaking of the long connection of process 1 can be initiated by application A instructing the execution unit to disconnect, or it can be initiated by the server side.

[0088] When the long connection of process 1 is broken, since the monitoring unit has pre-obtained the correspondence between each created process and application, in this embodiment, the monitoring unit can determine the application corresponding to process 1 based on the identification information of process 1, and immediately control application A corresponding to process 1 to re-establish the long connection of process 1. Specifically, the monitoring unit can send indication information to the application corresponding to process 1. This indication information can be used to indicate the re-establishment of the long connection of process 1, or it can be used to indicate that the long connection of process 1 is broken, thereby triggering the application to re-establish the long connection of process 1.

[0089] In the above technical solution, the monitoring unit listens to the long-connection status of each specific application. After any process's long-connection is broken, it quickly identifies the application to which the process belongs and immediately controls that application to re-establish the long-connection. This avoids long-term disconnections of long-connections and prevents delays or even no message notifications from the user's perspective due to the application's inability to receive messages from the server for an extended period.

[0090] In another embodiment of this application, Figure 4 The application layer of the electronic device shown may also include a sensing unit, which may be an application or management tool provided in the embodiments of this application.

[0091] Figure 7 This is another schematic flowchart of the long connection control method provided in the embodiments of this application, such as... Figure 7 As shown, the long-connection control method provided in this application includes:

[0092] 201. The sensing unit receives application identification information and target process identification information sent by the target application.

[0093] 202. The sensing unit sends the application identification information and the target process identification information to the listening unit.

[0094] 203. The monitoring unit generates a mapping relationship between application identification information and target process identification information.

[0095] The implementation methods provided in this application are applicable to any of the specific applications. For ease of description and understanding, this application uses any of the specific applications as an example to illustrate the implementation flow of the method provided in this application. Hereinafter, any of the specific applications will be referred to as the "target application".

[0096] After the target application starts, it can create a target process related to the instant messaging service. The target application can then send process creation information to the sensing unit, including its own application identifier and the identifier of the created target process. The sensing unit can then send the received process creation information to the monitoring unit. Based on the received information, the monitoring unit can generate a mapping relationship between the target application and the target process. Based on this mapping relationship, the monitoring unit can determine that the target process is a process created by the target application.

[0097] Through the above implementation, the monitoring unit can obtain the mapping relationship between each created process and application, so as to accurately determine the application to which the process belongs when the long connection of any process is broken, and control the application to re-establish the long connection. Furthermore, by adding a sensing unit, direct access to the monitoring unit by third-party applications can be prevented, ensuring the reliability of device operation.

[0098] 204. The target application sends a first control message to the execution unit. The first control message is used to instruct the establishment of a long connection for the target process and the identification information of the target process.

[0099] 205. The execution unit sends a second notification message to the listening unit. The second notification message is used to notify the target process of the establishment of a long connection and the identification information of the target process.

[0100] 206. The target application sends a second control message to the execution unit. The second control message is used to instruct the disconnection of the long connection of the target process and the identification information of the target process.

[0101] 207. The execution unit sends a first notification message to the listening unit. The first notification message is used to notify the target process that the long connection has been broken and to provide the target process's identification information.

[0102] In this embodiment of the application, the monitoring unit can be used to monitor the long connection status of the target process of the target application, including long connection establishment and long connection termination.

[0103] Specifically, when establishing a long-lived connection to the target process, the target application can send a control message to the execution unit to instruct the establishment of the long-lived connection. For example, this control message could be a socket creation message, such as a Synchronize Sequence Numbers (SYN) message. In response to the received control message, the execution unit can send a SYN message to the server, triggering the establishment of the long-lived connection to the target process. After the long-lived connection to the target process is established, the execution unit can send a notification message to the listening unit indicating that the long-lived connection to the target process has been established.

[0104] When disconnecting a long-lived connection to the target process, the target application can send a control message to the execution unit to instruct the disconnection of the long-lived connection. For example, this control message can be a socket disconnection message, such as a Function Item Number (FIN) or a Reset the connection (RST) message. The FIN message can be used for normal connection closure, while the RST message can be used for abnormal connection closure. The execution unit can then send the received control message to the server, triggering the disconnection of the target process's long-lived connection. After the target process's long-lived connection is disconnected, the execution unit can send a notification message to the listening unit indicating that the target process's long-lived connection has been disconnected.

[0105] 208. The monitoring unit determines the target application corresponding to the target process based on the mapping relationship between the application identification information and the target process identification information.

[0106] In this embodiment, when the monitoring unit detects that the long connection of the target process has been broken, it can determine the application to which the target process belongs based on the generated mapping relationship. Specifically, as can be understood from the foregoing description, the monitoring unit can store the mapping relationship between each created process and its corresponding application. After determining that the long connection of the target process has been broken, the monitoring unit can query the above mapping relationship according to the identification information of the target process, thereby determining the application to which the target process belongs.

[0107] 209. The listening unit sends a notification message to the sensing unit indicating that the long connection of the target application's target process has been disconnected.

[0108] 210. The sensing unit sends an instruction message to the target application to re-establish the long connection of the target process.

[0109] 211, the target application sends the first control message to the execution unit again.

[0110] After the monitoring unit determines the application to which the target process belongs, it can control the application to which the target process belongs to re-establish the long connection of the target process through the sensing unit.

[0111] Specifically, the monitoring unit can send an indication message to the sensing unit that the target process of the target application has been disconnected. Then, the sensing unit can send an indication message to the target application to re-establish the long connection of the target process. Subsequently, the target application can resend the first control message to the execution unit to re-establish the long connection of the target process.

[0112] In the above implementation, if any process's long connection is broken, the listening unit can determine the application to which the process belongs. This allows for targeted control of the corresponding application to immediately re-establish the long connection, preventing message notification delays. Furthermore, the function of instructing the application to re-establish the long connection can be implemented by the sensing unit provided in this embodiment, thereby preventing third-party applications from directly accessing the listening unit and ensuring device operational reliability.

[0113] Figure 8 This is another schematic flowchart of the long connection control method provided in the embodiments of this application, such as... Figure 8 As shown, the long-connection control method provided in this application includes:

[0114] 301, The sensing unit receives application identification information and target process identification information sent by the target application.

[0115] 302. The sensing unit sends the application identification information and the target process identification information to the listening unit.

[0116] 303, The monitoring unit generates a mapping relationship between application identification information and target process identification information.

[0117] 304. The target application sends a first control message to the execution unit. The first control message is used to instruct the establishment of a long connection for the target process and the identification information of the target process.

[0118] 305. The execution unit sends a second notification message to the listening unit. The second notification message is used to notify the target process of the establishment of a long connection and the identification information of the target process.

[0119] 306. The monitoring unit determines the target application corresponding to the target process based on the mapping relationship between the application identification information and the target process identification information.

[0120] 307. The listening unit sends a notification message to the sensing unit indicating that a long connection has been established for the target process of the target application.

[0121] 308. The sensing unit sends the first event information to the target management platform.

[0122] In this embodiment, after receiving a notification message indicating the establishment of a long connection by any process, the monitoring unit can determine the application to which the process belongs based on the stored mapping relationship. Then, the monitoring unit can send first event information to the target management platform through the sensing unit. Specifically, the monitoring unit can send a prompt message indicating the establishment of a long connection by the target process to the sensing unit. The sensing unit can then generate a timestamp and send the first event information to the target management platform. The first event information may include event information about the establishment of a long connection by the target process of the target application, and the timestamp information of that event.

[0123] 309. The target application sends a second control message to the execution unit. The second control message is used to instruct the disconnection of the long connection of the target process and the identification information of the target process.

[0124] 310. The execution unit sends a first notification message to the listening unit. The first notification message is used to notify the target process that the long connection has been broken and to provide the target process's identification information.

[0125] 311. The monitoring unit determines the target application corresponding to the target process based on the mapping relationship between the application identification information and the target process identification information.

[0126] 312. The monitoring unit sends a notification message to the sensing unit indicating that the long connection of the target application's target process has been disconnected.

[0127] 313, The sensing unit sends the second event information to the target management platform.

[0128] 314. The sensing unit sends an instruction message to the target application to re-establish the long connection of the target process.

[0129] 315, the target application sends the first control message to the execution unit again.

[0130] Similar to the aforementioned long-connection establishment process, in this embodiment, after receiving a notification message that a long connection of any process has been broken, the monitoring unit can determine the application to which the process belongs based on the stored mapping relationship. Furthermore, on one hand, the monitoring unit can send second event information to the target management platform through the sensing unit. Specifically, the monitoring unit can send a prompt message indicating that the target process's long connection has been broken to the sensing unit, and the sensing unit can generate a timestamp and send the second event information to the target management platform. The second event information may include event information about the target application's target process being broken, as well as the timestamp information of that event. On the other hand, after receiving the prompt message sent by the monitoring unit, the sensing unit can also instruct the target application to re-establish the long connection of the target process.

[0131] 316. The target management platform performs long-connection information statistics based on the first event information and the second event information.

[0132] Based on the above explanation, it can be understood that the target management platform can receive long-connection establishment event information and long-connection disconnection event information for various specific applications. Based on this information, the target management platform can statistically analyze information such as connection duration, reconnection time, and number of reconnections for different processes within different applications. Furthermore, this can be used to assist R&D managers in making targeted updates and adjustments to different applications.

[0133] The above technical solution allows the monitoring unit to monitor the long-connection status of each specific application, and the sensing unit to report long-connection establishment and disconnection events of each specific application to the target management platform. Therefore, based on the statistical function of the target management platform, it is possible to statistically analyze the long-connection status of different applications in the live network, which is beneficial for R&D managers to implement targeted updates and adjustments to application-related functions.

[0134] It should be understood that the electronic device of this application is embodied in the form of functional units. The term "unit" here can be implemented in software and / or hardware, without specific limitation. For example, a "unit" can be a software program, hardware circuit, or a combination of both that implements the above-described functions. The hardware circuit may include application-specific integrated circuits (ASICs), electronic circuits, a processor (e.g., a shared processor, a proprietary processor, or a group processor, etc.) and memory for executing one or more software or firmware programs, integrated logic circuits, and / or other suitable components supporting the described functions. Whether a function is implemented in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments.

[0135] The module division in this embodiment is illustrative and represents only one logical functional division. In actual implementation, other division methods are possible. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into a single processing module. The integrated modules described above can be implemented in hardware.

[0136] This application also provides an electronic device, which includes a storage medium and a central processing unit. The storage medium may be a non-volatile storage medium, which stores a computer-executable program. The central processing unit is connected to the non-volatile storage medium and executes the computer-executable program to implement the above-described long connection control method.

[0137] This application also provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform various steps of the long connection control method of this application.

[0138] This application also provides a computer program product containing instructions that, when run on a computer or any at least one processor, causes the computer to execute the various steps of the long connection control method of this application.

[0139] This application also provides a chip including a processor and a data interface. The processor reads instructions stored in a memory through the data interface to execute corresponding operations and / or processes performed by the long connection control method provided in this application.

[0140] Optionally, the chip further includes a memory connected to the processor via a circuit or wire, the processor being used to read and execute computer programs stored in the memory. Further optionally, the chip includes a communication interface to which the processor is connected. The communication interface is used to receive data and / or information that needs to be processed, the processor obtaining the data and / or information from the communication interface and processing the data and / or information. The communication interface can be an input / output interface.

[0141] The memory can be read-only memory (ROM), other types of static storage devices that can store static information and instructions, random access memory (RAM), or other types of dynamic storage devices that can store information and instructions. It can also be electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, or other magnetic storage devices. Alternatively, it can be any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer.

[0142] In this embodiment, "and / or" describes the relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent the existence of A alone, the simultaneous existence of A and B, or the existence of B alone. A and B can be singular or plural. The character " / " generally indicates that the preceding and following associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, and c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.

[0143] Those skilled in the art will recognize that the units and algorithm steps described in the embodiments disclosed herein can be implemented using electronic hardware, computer software, or a combination of electronic hardware and software. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0144] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0145] In the several embodiments provided in this application, any function, if implemented as a software functional unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0146] The above description is merely a specific embodiment of this application. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application. The protection scope of this application should be determined by the protection scope of the claims.

Claims

1. A long-connection control method, characterized in that, Applied to electronic devices, the method includes: Upon detecting the disconnection of a long-lived connection in the target process, the target application to which the target process belongs is determined. Send an instruction message to the target application, the instruction message being used to instruct the re-establishment of the long connection of the target process; The electronic device includes a monitoring unit and an execution unit; the process of detecting the disconnection of a long connection of a target process and determining the target application to which the target process belongs includes: The monitoring unit receives a first notification message sent by the execution unit. The first notification message is used to notify the target process that the long connection has been disconnected and to provide the identification information of the target process. The monitoring unit determines the target application to which the target process belongs based on the identification information of the target process.

2. The method according to claim 1, characterized in that, The monitoring unit determines the target application to which the target process belongs based on the identification information of the target process, including: The monitoring unit queries the target mapping table based on the identification information of the target process. The target mapping table contains the mapping relationship between each created process and its corresponding application. The monitoring unit determines the target application to which the target process belongs based on the query results.

3. The method according to claim 2, characterized in that, The method further includes: The monitoring unit acquires the identification information of each created process and the application identification information of the application to which each created process belongs; The monitoring unit generates the target mapping table based on the identification information of each created process and the application identification information of the application to which each created process belongs.

4. The method according to claim 3, characterized in that, The electronic device further includes a sensing unit; the monitoring unit acquires the identification information of each created process and the application identification information of the application to which each created process belongs, including: The sensing unit receives application identification information and identification information of created processes sent by each application. The sensing unit sends the application identification information and the identification information of the created process to the listening unit.

5. The method according to claim 4, characterized in that, The applications mentioned are instant messaging applications, or applications that integrate instant messaging functionality.

6. The method according to claim 1, characterized in that, The electronic device further includes a sensing unit; before the listening unit receives the first notification message sent by the execution unit, the method further includes: The monitoring unit sends a first prompt message to the sensing unit, the first prompt message being used to prompt the target application to establish the target process; The sensing unit responds to the first prompt information and generates a first timestamp; The sensing unit sends a first event information to the target management platform. The first event information includes the first timestamp and information on the establishment of a long connection between the target application and the target process.

7. The method according to claim 6, characterized in that, Before the monitoring unit sends the first prompt information to the sensing unit, the method further includes: The monitoring unit receives a second notification message sent by the execution unit. The second notification message is used to notify the target process of the establishment of a long connection and the identification information of the target process.

8. The method according to claim 6, characterized in that, After the monitoring unit receives the first notification message sent by the execution unit, the method further includes: The monitoring unit sends a second prompt message to the sensing unit; The sensing unit responds to the second prompt information and generates a second timestamp; The sensing unit sends a second event information to the target management platform. The second event information includes the second timestamp and information about the long connection of the target process of the target application being disconnected.

9. The method according to claim 8, characterized in that, The first event information and the second event information are used by the target management platform to implement long connection information statistics.

10. The method according to claim 8, characterized in that, Sending indication information to the target application, including: In response to the second prompt information sent by the monitoring unit, the sensing unit sends an instruction message to the target application.

11. The method according to claim 1, characterized in that, The monitoring unit includes the network daemon netd.

12. The method according to claim 1, characterized in that, The identification information of the target process includes the user identifier (UID) and the process identifier (PID).

13. An electronic device, characterized in that, include: One or more processors; Memory; And one or more computer programs, wherein the one or more computer programs are stored in the memory, the one or more computer programs including instructions that, when executed by the electronic device, cause the electronic device to perform the method as described in any one of claims 1-12.

14. A chip, characterized in that, The chip includes a processor and a data interface. The processor reads instructions stored in the memory through the data interface and executes the method as described in any one of claims 1-12.

15. A storage medium, characterized in that, The storage medium stores program instructions that, when run on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-12.

Citation Information

Patent Citations

  • Duration management method, device and equipment, readable storage medium and program product

    CN117014489A