Long connection control method and device
By monitoring and managing the long connection status of instant messaging applications, the message delay or no prompting caused by long connection disconnection of TCP is solved, real-time communication of instant messaging applications is realized, and user experience is improved.
Patent Information
- Application Number
- CN202410011263.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-04
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2044-01-04
AI Technical Summary
In real-time messaging applications, messages delays or no prompts caused by disconnection of TCP long connections, affecting the user experience.
By monitoring the long connection status of the instant messaging application and controlling the application to re-establish the long connection immediately when a disconnect is detected, avoiding long disconnection, use the monitoring unit and perception unit in the electronic device for status monitoring and management.
Ensure real-time communication of instant messaging applications, prevent message delays or no prompts, and improve user experience.
Smart Images

Figure CN120301797A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of terminals, and particularly to a long connection control method and device. Background Art
[0002] During the process of sending and receiving messages through an instant messaging application, users often encounter the situation of delayed message reminders or no reminders, which affects the user experience. Through analysis, it is found that the reason for the above problems is that the long connection between the application and the server is disconnected, resulting in the inability to communicate with the server and the inability to receive messages in a timely manner. Summary of the Invention
[0003] The purpose of the present invention is to provide a long connection control method and device, which can solve the problem of delayed message reminders or no reminders for specific types of applications (such as instant messaging applications, or applications integrated with instant messaging functions, or applications integrated with message push functions, etc.) by monitoring and controlling the long connection status, and improve 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: when it is monitored that the long connection of a target process is disconnected, determining the target application to which the target process belongs; and sending an indication message to the target application, where the indication message is used to indicate to re - establish the long connection of the target process.
[0005] In the above implementation solution, the electronic device can monitor the long connection status of the target process. After it is monitored that the long connection of the target process is disconnected, the application to which the target process belongs can be determined, and the corresponding application can be immediately notified to re - establish the long connection of the target process. Thus, the long connection can be prevented from being disconnected for a long time, and the situation of delayed message reminders or no reminders in the instant messaging application can be prevented, ensuring the real - time communication and improving the user experience.
[0006] In a long connection control method as described above, in some implementation manners of the first aspect, the electronic device includes a monitoring unit and an execution unit; when it is monitored that the long connection of a target process is disconnected and the target application to which the target process belongs is determined, it includes: the monitoring unit receives a first notification message sent by the execution unit, where the first notification message is used to notify that the long connection of the target process is disconnected and the identification information of the target process; and the monitoring unit determines the target application to which the target process belongs according to the identification information of the target process.
[0007] In the above implementation solution, the monitoring unit can be used to monitor the long connection status of each process through the execution unit. After it is monitored that the long connection of any process is disconnected, the application to which the process belongs can be determined, and then the corresponding application can be immediately controlled to re - establish the long connection of the process. Thus, the long connection can be prevented from being disconnected for a long time, and the situation of delayed message reminders or no reminders in the instant messaging application can be prevented, ensuring the real - time communication and improving the user experience.
[0008] A long connection control method as described above. In some implementations of the first aspect, the monitoring unit determines the target application to which the target process belongs according to the identification information of the target process, including: the monitoring unit queries the target mapping table according to the identification information of the target process, and the target mapping table contains the mapping relationships between each created process and the application to which it belongs; the monitoring unit determines the target application to which the target process belongs according to the query result.
[0009] A long connection control method as described above. In some implementations of the first aspect, the long connection control method provided by the present invention further includes: the monitoring unit obtains 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 a target mapping table according to 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 manner, the monitoring unit can establish a mapping relationship table between the application and the process after any application creates a process. Then, when it is detected that the long connection of any process is disconnected, the application to which the current process belongs can be determined according to the above mapping relationship table, which is beneficial to accurately controlling the corresponding application to re - establish a long connection.
[0011] A long connection control method as described above. In some implementations of the first aspect, the electronic device provided by the present invention further includes a sensing unit; the monitoring unit obtains 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 the application identification information and the identification information of the created process sent by each application; the sensing unit sends the application identification information and the identification information of the created process to the monitoring unit.
[0012] In this implementation manner, by adding a sensing unit at the application layer of the electronic device, the sensing unit directly interacts with each application to obtain the information required by the monitoring unit, so that third - party applications can be prevented from directly accessing the monitoring unit of the electronic device, which is beneficial to enhancing the security and reliability of the device.
[0013] A long connection control method as described above. In some implementations of the first aspect, each of the above applications is an instant messaging application or an application integrated with an instant messaging function.
[0014] As described above, in some implementation manners of the first aspect, before the monitoring unit receives the first notification message sent by the execution unit, the long connection control method provided by the present invention further includes: the monitoring unit sends a first prompt message to the sensing unit, where the first prompt message is used to prompt the establishment of the target process of the target application; the sensing unit generates a first timestamp in response to the first prompt message; the sensing unit sends a first event message to the target management platform, and the first event message includes the first timestamp and the information about the establishment of the long connection of the target process of the target application.
[0015] In this implementation manner, the sensing unit can send an event of the establishment of the long connection of each application process to the target management platform, so that the target management platform can be used to statistically analyze the long connection status of each application process in the live network.
[0016] As described above, in some implementation manners of the first aspect, before the monitoring unit sends the first prompt message to the sensing unit, the long connection control method provided by the present invention further includes: the monitoring unit receives a second notification message sent by the execution unit, where the second notification message is used to notify the establishment of the long connection of the target process and the identification information of the target process.
[0017] As described above, in some implementation manners of the first aspect, after the monitoring unit receives the first notification message sent by the execution unit, the long connection control method provided by the present invention further includes: the monitoring unit sends a second prompt message to the sensing unit; the sensing unit generates a second timestamp in response to the second prompt message; the sensing unit sends a second event message to the target management platform, and the second event message includes the second timestamp and the information about the disconnection of the long connection of the target process of the target application.
[0018] In this implementation manner, the sensing unit can send an event of the disconnection of the long connection of each application process to the target management platform, so that the target management platform can be used to statistically analyze the long connection status of each application process in the live network.
[0019] As described above, in some implementation manners of the first aspect, the first event message and the second event message are used for the target management platform to implement long connection information statistics.
[0020] As described above, in some implementation manners of the first aspect, sending an indication message to the target application includes: the sensing unit sends an indication message for re - establishing the long connection of the target process to the target application in response to the second prompt message sent by the monitoring unit.
[0021] In this implementation, by directly interacting with each application through the sensing unit, direct access of third-party applications to the listening unit of the electronic device can be avoided, which is beneficial to enhancing the security and reliability of the device.
[0022] In some implementations of the first aspect, for the long connection control method described above, the listening unit includes the network daemon netd.
[0023] In some implementations of the first aspect, for the long connection control method described above, the identification information of the target process includes the user identifier UID and the process identifier PID.
[0024] In a second aspect, the present 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 execute the method in the first aspect or any possible implementation manner of the first aspect.
[0025] In a third aspect, the present invention further provides a chip, where the chip includes a processor and a data interface, and the processor reads instructions stored on a memory through the data interface and executes the method in the first aspect or any possible implementation manner of the first aspect.
[0026] Optionally, as an implementation manner, the chip may further include a memory, and instructions are stored in the memory. The processor is configured to execute the instructions stored on the memory, and when the instructions are executed, the processor is configured to execute the method in the first aspect or any possible implementation manner of the first aspect.
[0027] In a fourth aspect, the present invention further provides a computer-readable storage medium, where the computer-readable medium stores program code for device execution, and the program code includes instructions for executing the method in the first aspect or any possible implementation manner of the first aspect. Description of the Drawings
[0028] Figure 1 is a schematic diagram of a scenario of network address translation provided by an embodiment of the present application;
[0029] Figure 2 is a timing schematic diagram of a NAT timeout scenario provided by an embodiment of the present application;
[0030] Figure 3 is a schematic structural diagram of an electronic device provided by an embodiment of the present application;
[0031] Figure 4It is a schematic diagram of the software structure of the electronic device provided by the embodiment of the present application;
[0032] Figure 5 It is a schematic flowchart of the long connection control method provided by the embodiment of the present application;
[0033] Figure 6 It is a schematic diagram of a scenario of the long connection control method provided by the embodiment of the present application;
[0034] Figure 7 It is another schematic flowchart of the long connection control method provided by the embodiment of the present application;
[0035] Figure 8 It is another schematic flowchart of the long connection control method provided by the embodiment of the present application. Detailed implementation manners
[0036] Nowadays, there are more and more various instant messaging applications or applications integrated with instant messaging functions, and people's communication with each other largely depends on the above-mentioned applications. In the scenario of using instant messaging applications to communicate with each other, users always hope to be able to receive the messages sent by the other party in a timely manner to ensure the real-time nature of communication. However, in the actual scenario, users often encounter the situation of message prompt delay or even no message prompt, resulting in the inability to view the messages in a timely manner and possibly delaying important matters.
[0037] After analysis, it is found that the reason for the message prompt delay or no message prompt is that the Transmission Control Protocol (TCP) long connection between the application and the server is disconnected, resulting in the application being unable to communicate with the server and unable to receive the messages sent by the peer in a timely manner.
[0038] The following is a detailed description.
[0039] Specifically, instant messaging applications usually rely on TCP long connections to achieve two-way communication. A TCP long connection is a connection that needs to be established between two communication parties when communicating using the TCP protocol. After the TCP long connection is established, after the two communication parties complete a read / write operation, the connection will not be closed, and subsequent read / write operations can still be completed based on this connection, so it is called a "long connection". However, in the real scenario, many reasons can cause the long connection between the two communication parties to be abnormally disconnected. For example: Network Address Translation (NAT) timeout, network status change, the process where the long connection is located is killed, etc. After the long connection is disconnected, the application will be unable to communicate with the server, and the two communication parties will be unable to receive the messages sent by the peer, thus causing the situation of message prompt delay or no prompt in the instant messaging application.
[0040] For ease of understanding, hereinafter, with reference to the accompanying drawings, taking the case where a long connection is disconnected due to NAT timeout as an example, the reasons for message prompt delay or non-prompt in an instant messaging application will be described.
[0041] It should be understood that the following description of the NAT timeout scenario is only an exemplary illustration of the reasons for the disconnection of the long connection, and does not constitute a limitation to this application.
[0042] Specifically, as Figure 1 shown, when a local area network device accesses an Internet server, it is necessary to perform the conversion between the private address and the public network address. After the long connection between the two communication parties is established, the mapping relationship between the internal network address port and the public network address port will be stored in the routing table of the gateway server. During the communication process, the two communication parties can complete the conversion between the private address and the public network address based on this mapping relationship, which is called "network address translation".
[0043] If there is no data communication on the long connection link within the set duration, the gateway server will eliminate the mapping relationship stored in the routing table, thus causing the link to be interrupted. This set duration is the NAT timeout duration. Therefore, after the long connection is established, the instant messaging application needs to send heartbeat packets to the server regularly to maintain the long connection link. Among them, the sending interval of the heartbeat packet must be less than the NAT timeout duration, otherwise, the long connection link will be interrupted.
[0044] Figure 2 Describes a specific scenario that triggers NAT timeout.
[0045] As Figure 2 shown, the instant messaging application includes two types of heartbeats: NAT heartbeat and sleep wake-up heartbeat. Among them, the NAT heartbeat is used to send heartbeat packets to the server regularly to prevent NAT timeout. The sleep wake-up heartbeat is used for the system to wake up regularly, so as to save system power consumption while ensuring that each application in the system can receive messages in a timely manner.
[0046] As Figure 2 shown, assume that the heartbeat interval of the NAT heartbeat is 210 seconds, and the heartbeat interval of the sleep wake-up heartbeat is 300 seconds. In an actual scenario, the heartbeat node of the NAT heartbeat will be reset when a message sent by the peer device is received. Specifically, as Figure 2 shown, if the instant messaging application receives a message sent by the peer device at time node B1, then 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. That is to say, in order to avoid NAT timeout, the instant messaging application needs to send a heartbeat packet to the server before time node B2.
[0047] However, when a message sent by a peer device is received at time node B1, since the instant messaging application is in a dormant state, the instant messaging application cannot perceive the message sent by the peer device. It is not until time node A2 that the dormant wake-up heartbeat is triggered, and the instant messaging application misjudges time node A2 as the time when the message is received. Furthermore, based on the relevant principle of resetting the NAT heartbeat node mentioned above, the instant messaging application determines time node B3, which is 210 seconds after time node A2, as the next heartbeat node. It can be understood that time node B3 is obviously after time node B2, and the NAT times out.
[0048] After the NAT times out, the mapping relationship stored in the routing table is deleted, and the long connection is disconnected. Furthermore, the application cannot communicate with the server and cannot receive messages sent by the peer. In the case of the long connection being disconnected, only when the next NAT heartbeat of the instant messaging application fails will the instant messaging application re-establish the long connection. After the long connection is successfully re-established, the server can deliver the messages that the peer device has sent before to the application. It can be understood that since a relatively long time has passed since the peer device sent the message, there will be a situation of message delay prompt or even no prompt from the user's perspective.
[0049] To solve the above problems, this application is proposed.
[0050] This application can utilize relevant unit modules in the electronic device to monitor the long connection status of each instant messaging application in the electronic device. Exemplarily, the NetworkDaemon (netd) between the kernel layer and the framework layer of the electronic device can be utilized to monitor the long connection status of each instant messaging application in the electronic device. After it is monitored that the long connection of any process is disconnected, the target application to which the process belongs can be determined, and then, an indication message is immediately sent to the target application to indicate re-establishing the long connection of the process.
[0051] Through the above technical solution, when the long connection of any instant messaging application is disconnected, there is no need to wait for the next heartbeat failure, and the long connection of the application is immediately controlled to be reconnected. Thus, the waiting duration from the disconnection of the long connection to the reconnection of the long connection is shortened, preventing the situation of message delay prompt or even no prompt of the instant messaging application and maintaining the real-time nature of the communication process.
[0052] Figure 3 FIG. shows the structural schematic diagram of the electronic device 100 provided by the embodiment of this application.
[0053] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
[0054] It can be understood that the structure illustrated in the embodiments of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than those illustrated, or combine certain components, or split certain components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0055] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.
[0056] The controller may generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching and executing instructions.
[0057] A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory may save the instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can directly call it 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. The 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 two-way synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be respectively coupled to the touch sensor 180K, the charger, the flashlight, the camera 193, etc. through different I2C bus interfaces. For example, the processor 110 may be coupled to the touch sensor 180K through the I2C interface, enabling the processor 110 to communicate with the touch sensor 180K through the I2C bus interface to implement the touch function of the electronic device 100.
[0060] The MIPI interface may be used to connect the processor 110 to the display screen 194. The processor 110 and the display screen 194 communicate through the DSI interface to implement the display function of the electronic device 100.
[0061] It can be understood that the interface connection relationship between the modules illustrated in the embodiments of the present invention is only illustrative and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0062] The electronic device 100 implements the display function through the GPU, the display screen 194, the application processor, etc. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to execute mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.
[0063] The external memory 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 memory interface 120 to implement the data storage function. For example, files such as music and videos are saved in the external memory card.
[0064] The internal memory 121 can be used to store computer-executable program code, and the executable program code includes instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store the operating system, application programs required for at least one function (such as the long connection status reporting function, etc.). The data storage area can store the data created during the use of the electronic device 100 (such as process identifiers, etc.). In addition, the 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, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121 and / or the instructions stored in the memory provided in the processor.
[0065] Figure 4 It is the software structure block diagram of the electronic device 100 in the embodiment of the present invention.
[0066] The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the electronic device 100 may include an application layer, an application framework layer, and a kernel layer from top to bottom.
[0067] The application layer may include a series of application packages.
[0068] Such as Figure 4 shown, the application package may include at least one instant messaging application, call, map, navigation, short message and other application programs.
[0069] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The application framework layer includes some predefined functions.
[0070] As Figure 4 shown, the application framework layer may include a notification manager, a content provider, a view system, a telephone manager, a resource manager, a window manager, etc.
[0071] Among them, the notification manager enables the application to display notification information in the status bar, can be used to convey notification-type messages, and can automatically disappear after a short stay without user interaction. For example, the notification manager is used for message reminders in instant messaging applications, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or a scroll bar text, such as the notification of a background-running application, and can also be a notification that appears on the screen in the form of a dialogue window. For example, prompt text information in the status bar, emit a prompt sound, the electronic device vibrates, the indicator light flashes, etc.
[0072] The application layer and the application framework layer run in the virtual machine. The virtual machine executes the java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0073] The kernel layer is the layer between the hardware and the software. The kernel layer at least includes an execution unit, and the execution unit can at least be used to establish a long connection between the instant messaging application and the server side based on the instructions of the upper layer.
[0074] Between the kernel layer and the framework layer, a monitoring unit may also be included. The monitoring unit can be used to monitor the long connection status of each application in the application layer. The monitoring unit can specifically be netd.
[0075] In the following embodiments of the present application, an electronic device with the Figure 3 , Figure 4 shown structure will be taken as an example to specifically elaborate on the long connection control method provided by the embodiments of the present application.
[0076] Figure 5 is a schematic flowchart of the long connection control method provided by the embodiments of the present application. As Figure 5 shown, the long connection control method provided by the embodiments of the present application includes:
[0077] 101, The monitoring unit receives a first notification message sent by the execution unit. The first notification message is used to notify that the long connection of the target process is disconnected and the identification information of the target process.
[0078] 102. The monitoring unit determines the target application to which the target process belongs according to the identification information of the target process.
[0079] 103. The monitoring unit controls the target application to re - establish the long connection of the target process.
[0080] In the embodiment of the present application, the monitoring unit can pre - register the events to be monitored for specific applications.
[0081] Among them, the specific type of the specific application can be determined based on the actual scenario or user requirements. Exemplarily, the specific application can be an application with high requirements for communication real - time performance in the actual scenario. For example, it can include any instant messaging application, or can also include an application integrated with an instant messaging function, an application integrated with a message push function, etc.
[0082] In the embodiment of the present application, the above - mentioned various specific applications can be set before the electronic device leaves the factory, or can be set by the user himself / herself.
[0083] For the implementation method of user - self - setting, specifically, refer to Figure 6 , for example, a message prompt control can be displayed in the interface 61 of the application settings of the electronic device. In response to the triggering operation on the message prompt control, the electronic device can display a message prompt method setting interface 62. The message prompt method setting interface 62 may include the application icons of each application in the electronic device. In response to the triggering operation on any one of the application icons, the electronic device can display a real - time prompt switch control, and the real - time prompt switch control can be used to set the on - off of the real - time prompt function of the application. When set to on, the electronic device determines that the application is a specific application.
[0084] The events to be monitored can include long - connection establishment events, long - connection disconnection events, etc. of the above - mentioned specific applications. Thus, during the operation of the electronic device, the monitoring unit can be used to monitor the long - connection status of the above - mentioned specific applications.
[0085] Specifically, taking any one of the specific applications (hereinafter referred to as "Application A") as an example, after any one of the processes in Application A (hereinafter referred to as "Process 1") is created, if Application A determines that the service corresponding to Process 1 needs to establish a long connection, then Application A can send a control message for establishing a long connection to the execution unit. The control message may carry the identification information of Process 1, at least including the Process Identification (PID) and the User Identification (UID). The 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, first, the execution unit can communicate with the server side to complete the establishment of the long connection for Process 1. The specific establishment process can refer to the prior art and will not be elaborated in this application. After the long connection for Process 1 is established, the execution unit can send a notification message indicating the establishment of the long connection for Process 1 to the monitoring unit, and the identification information of Process 1 can be carried in the notification message. Based on the identification information of Process 1, the monitoring unit can determine Application A corresponding to Process 1 according to the pre-obtained corresponding relationship between each created process and the application.
[0087] Further, affected by any possible factors, when the long connection of Process 1 is disconnected, the execution unit can send a notification message indicating the disconnection of the long connection for Process 1 to the monitoring unit, and the identification information of Process 1 can be carried in the notification message. Similarly, based on the identification information of Process 1, the monitoring unit can determine Application A corresponding to Process 1 according to the pre-obtained corresponding relationship between each created process and the application. Among them, the disconnection of the long connection of Process 1 can be actively instructed by Application A to the execution unit to disconnect, or it can also be actively disconnected by the server side.
[0088] After the long connection of Process 1 is disconnected, since the monitoring unit has pre-obtained the corresponding relationship between each created process and the application, in the embodiments of this application, 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 for Process 1. Specifically, the monitoring unit can send an indication message to the application corresponding to Process 1, and the indication message can be used to indicate re-establishing the long connection for Process 1, or the indication message can be used to indicate the disconnection of the long connection for Process 1, thereby triggering the application to re-establish the long connection for Process 1.
[0089] In the above technical solution, by the monitoring unit monitoring the long connection status of each specific application, and after the long connection of any process is disconnected, quickly determining the application to which the process belongs and immediately controlling the application to re-establish the long connection for the process. Thus, it is possible to avoid the long connection being disconnected for a long time, and prevent the message prompt from being delayed or even not prompted from the user's perspective due to the application being unable to receive messages from the server side for a long time.
[0090] In another embodiment of this application, Figure 4 The application layer of the shown electronic device may further include a sensing unit, and the sensing unit can be an application program or management tool provided in the embodiments of this application.
[0091] Figure 7 is another schematic flowchart of the long connection control method provided in the embodiments of this application. As Figure 7 shown, the long connection control method provided in the embodiments of this application includes:
[0092] 201. The sensing unit receives the application identification information sent by the target application and the identification information of the target process.
[0093] 202. The sensing unit sends the application identification information and the identification information of the target process to the monitoring unit.
[0094] 203. The monitoring unit generates the mapping relationship between the application identification information and the identification information of the target process.
[0095] For any one of the various specific applications, the implementation methods provided in the embodiments of the present application are applicable. For the convenience of description and understanding, in the embodiments of the present application, any one of the various specific applications is taken as an example to illustrate the implementation process of the method provided in the embodiments of the present application. Hereinafter, this arbitrary specific application will be referred to as the "target application".
[0096] After the target application is started, it can create a target process related to the instant messaging service. Furthermore, the target application can send the relevant information of the process creation to the sensing unit, including the application identification information of the target application itself and the identification information of the created target process. The sensing unit can send the received relevant information of the process creation to the monitoring unit. Furthermore, the monitoring unit can generate the mapping relationship between the target application and the target process based on the received information. Based on this mapping relationship, the monitoring unit can determine that the target process is the process created by the target application.
[0097] Through the above implementation method, the monitoring unit can obtain the mapping relationship between each created process and the application, so as to accurately determine the application to which the process belongs when the long connection of any process is disconnected, and control the application to re - establish the long connection. And by adding a sensing unit, it can prevent third - party applications from directly accessing the monitoring unit, ensuring the reliability of device operation.
[0098] 204. The target application sends a first control message to the execution unit, and the first control message is used to indicate the establishment of the long connection of the target process and the identification information of the target process.
[0099] 205. The execution unit sends a second notification message to the monitoring unit, and the second notification message is used to notify the establishment of the long connection of the target process and the identification information of the target process.
[0100] 206. The target application sends a second control message to the execution unit, and the second control message is used to indicate 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 monitoring unit, and the first notification message is used to notify the disconnection of the long connection of the target process and the identification information of the target process.
[0102] In an embodiment of the present 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 disconnection.
[0103] Specifically, when establishing the long - connection of the target process, the target application can send a control message for instructing to establish the long - connection of the target process to the execution unit. Exemplarily, the control message can be a message for creating a socket, 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 to trigger the establishment of the long - connection of the target process. After the long - connection of the target process is established, the execution unit can send a notification message indicating that the long - connection of the target process is established to the monitoring unit.
[0104] When disconnecting the long - connection of the target process, the target application can send a control message for instructing to disconnect the long - connection of the target process to the execution unit. Exemplarily, the control message can be a message for disconnecting the socket, such as a FunctionItem Number (FIN) message, a Reset the connection (RST) message, etc. Among them, the FIN message can be used to normally close the long - connection, and the RST message can be used to abnormally close the long - connection. Further, the execution unit can send the received control message to the server to trigger the disconnection of the long - connection of the target process. After the long - connection of the target process is disconnected, the execution unit can send a notification message indicating that the long - connection of the target process is disconnected to the monitoring unit.
[0105] 208. The monitoring unit determines the target application corresponding to the target process according to the mapping relationship between the application identification information and the identification information of the target process.
[0106] In an embodiment of the present application, when the monitoring unit monitors that the long - connection of the target process is disconnected, it can determine the application to which the target process belongs based on the generated mapping relationship. Specifically, based on the foregoing description, it can be understood that the monitoring unit can store the mapping relationship between each created process and its corresponding application. After the monitoring unit determines that the long - connection of the target process is disconnected, it can query the above - mentioned mapping relationship according to the identification information of the target process, so as to determine the application to which the target process belongs.
[0107] 209. The monitoring unit sends a prompt message indicating that the long - connection of the target process of the target application is disconnected to the sensing unit.
[0108] 210. The sensing unit sends an indication message for re - establishing the long - connection of the target process to the target application.
[0109] 211. The target application sends a 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 that the target process of the target application is disconnected to the sensing unit. Furthermore, the sensing unit can send an indication message to the target application to re - establish the long - connection of the target process. Furthermore, the target application can send a first control message to the execution unit again to re - establish the long - connection of the target process.
[0112] In the above implementation, when any process long - connection is disconnected, the application to which the process belongs can be determined through the monitoring unit. Furthermore, targeted control can be implemented to immediately re - establish the long - connection of the corresponding application, preventing message prompt delay. And the function of instructing the application to re - establish the long - connection can be implemented by the sensing unit provided in the embodiments of the present application, thus avoiding direct access of third - party applications to the monitoring unit and ensuring the reliability of device operation.
[0113] Figure 8 It is another schematic flowchart of the long - connection control method provided by the embodiments of the present application. As Figure 8 shown, the long - connection control method provided by the embodiments of the present application includes:
[0114] 301. The sensing unit receives the application identification information and the identification information of the target process sent by the target application.
[0115] 302. The sensing unit sends the application identification information and the identification information of the target process to the monitoring unit.
[0116] 303. The monitoring unit generates a mapping relationship between the application identification information and the identification information of the target process.
[0117] 304. The target application sends a first control message to the execution unit. The first control message is used to indicate the establishment of the long - connection of the target process and the identification information of the target process.
[0118] 305. The execution unit sends a second notification message to the monitoring unit. The second notification message is used to notify the establishment of the long - connection of the target process and the identification information of the target process.
[0119] 306. The monitoring unit determines the target application corresponding to the target process according to the mapping relationship between the application identification information and the identification information of the target process.
[0120] 307. The monitoring unit sends a prompt message that the long - connection of the target process of the target application is established to the sensing unit.
[0121] 308. The sensing unit sends the first event information to the target management platform.
[0122] In an embodiment of the present application, after the monitoring unit receives a notification message indicating the establishment of a long connection of any process, it can determine the application to which the process belongs based on the stored mapping relationship. Furthermore, 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 the long connection of the target process to the sensing unit. Then, the sensing unit can generate a timestamp and send the first event information to the target management platform. The first event information may include event information indicating the establishment of the target process of the target application and the timestamp information of this event.
[0123] 309. The target application sends a second control message to the execution unit. The second control message is used to instruct to disconnect 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 monitoring unit. The first notification message is used to notify the disconnection of the long connection of the target process and the identification information of the target process.
[0125] 311. The monitoring unit determines the target application corresponding to the target process according to the mapping relationship between the application identification information and the identification information of the target process.
[0126] 312. The monitoring unit sends a prompt message indicating the disconnection of the long connection of the target process of the target application to the sensing unit.
[0127] 313. The sensing unit sends 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 a first control message to the execution unit again.
[0130] Similar to the aforementioned long - connection establishment process, in an embodiment of the present application, after the monitoring unit receives a notification message indicating the disconnection of a long connection of any process, it can determine the application to which the process belongs based on the stored mapping relationship. Furthermore, on the 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 the disconnection of the long connection of the target process to the sensing unit. Then, 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 indicating the disconnection of the target process of the target application and the timestamp information of this 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 according to the first event information and the second event information.
[0132] Based on the above description, it can be understood that the target management platform can receive the process long connection establishment event information and the process long connection disconnection event information of each specific application. Based on the above information, the target management platform can count information such as the connection duration, reconnection time duration, and reconnection times of the long connections of different applications and different processes. Furthermore, it can be used to assist R & D management personnel in making targeted updates and adjustments to different applications.
[0133] Through the above technical solution, the long connection status of each specific application can be monitored by the monitoring unit, and the long connection establishment event and the long connection disconnection event of each specific application can be reported to the target management platform by the sensing unit. Thus, based on the statistical function of the target management platform, the statistics of the long connection situations of different applications in the live network can be realized, which is beneficial for R & D management personnel to targetedly update and adjust the application-related functions.
[0134] It should be understood that the electronic device of the present application is embodied in the form of functional units. The term "unit" here can be implemented in the form of software and / or hardware, and no specific limitation is made thereto. For example, the "unit" can be a software program, a hardware circuit, or a combination of the two to implement the above functions. The hardware circuit may include an application specific integrated circuit (ASIC), an electronic circuit, a processor (such as a shared processor, a dedicated processor, or a group of processors, etc.) for executing one or more software or firmware programs, and a memory, a merged logic circuit, and / or other suitable components supporting the described functions. Whether a certain function is executed in the way of hardware or 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 combination with the embodiments.
[0135] The division of modules in this embodiment is illustrative, merely a logical function division, and there may be other division methods in actual implementation. For example, each function module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware.
[0136] The embodiment of the present application also provides an electronic device, which includes a storage medium and a central processing unit. The storage medium can be a non-volatile storage medium, and a computer executable program is stored in the storage medium. The central processing unit is connected to the non-volatile storage medium and executes the computer executable program to implement the above long connection control method.
[0137] The embodiments of the present application also provide a computer-readable storage medium, in which instructions are stored. When the instructions run on a computer, the computer is enabled to execute the respective steps of the long connection control method according to the embodiments of the present application.
[0138] The embodiments of the present application also provide a computer program product containing instructions. When the computer program product runs on a computer or any at least one processor, the computer is enabled to execute the respective steps of the long connection control method according to the embodiments of the present application.
[0139] The embodiments of the present application also provide a chip, including a processor and a data interface. The processor reads instructions stored on a memory through the data interface to execute the corresponding operations and / or processes performed by the long connection control method provided by the present application.
[0140] Optionally, the chip further includes a memory, which is connected to the processor through a circuit or wire. The processor is configured to read and execute the computer program in the memory. Further optionally, the chip further includes a communication interface, and the processor is connected to the communication interface. The communication interface is configured to receive data and / or information to be processed. The processor obtains the data and / or information from the communication interface and processes the data and / or information. The communication interface may be an input / output interface.
[0141] The memory may be a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM), or other types of dynamic storage devices that can store information and instructions. It may also be an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM), or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, or other magnetic storage devices. Or it may also be any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer.
[0142] In the embodiments of the present application, "and / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent the situations of existing A alone, existing A and B simultaneously, and existing B alone. Here, A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one of the following" and its 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, a - b, a - c, b - c, or a - b - c, where a, b, and c can be single or multiple.
[0143] Those of ordinary skill in the art can realize that the various units and algorithm steps described in the embodiments disclosed herein can be implemented by a combination of electronic hardware, computer software, and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered to exceed the scope of the present application.
[0144] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.
[0145] In several embodiments provided by the present application, if any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this 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 for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program codes.
[0146] The above is only the specific implementation manner of the present application. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application and should be covered by the protection scope of the present application. The protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A long connection control method, characterized in that, Applied to an electronic device, the method includes: Upon detecting that the long connection of a target process is disconnected, determining the target application to which the target process belongs; Sending indication information to the target application, where the indication information is used to indicate re - establishing the long connection of the target process.
2. The method according to claim 1, characterized in that, The electronic device includes a monitoring unit and an execution unit; detecting that the long connection of a target process is disconnected 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, where the first notification message is used to notify that the long connection of the target process is disconnected and the identification information of the target process; The monitoring unit determines the target application to which the target process belongs according to the identification information of the target process.
3. The method according to claim 2, wherein The monitoring unit determining the target application to which the target process belongs according to the identification information of the target process includes: The monitoring unit queries a target mapping relation table according to the identification information of the target process, where the target mapping relation table contains the mapping relations between each created process and the application to which it belongs; The monitoring unit determines the target application to which the target process belongs according to the query result.
4. The method according to claim 3, characterized in that, The method further includes: The monitoring unit obtains 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 relation table according to the identification information of each created process and the application identification information of the application to which each created process belongs.
5. The method according to claim 4, wherein The electronic device further includes a sensing unit; the monitoring unit obtaining the identification information of each created process and the application identification information of the application to which each created process belongs includes: The sensing unit receives the application identification information and the identification information of the created process sent by each application; The sensing unit sends the application identification information and the identification information of the created process to the monitoring unit.
6. The method according to claim 5, wherein Each of the applications is an instant messaging application or an application integrated with an instant messaging function.
7. The method according to claim 2, wherein The electronic device further includes a sensing unit; before the monitoring 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, where the first prompt message is used to prompt the establishment of the target process of the target application; The sensing unit generates a first timestamp in response to the first prompt message; The sensing unit sends a first event message to a target management platform, where the first event message includes the first timestamp and the information about the establishment of the long connection of the target process of the target application.
8. The method according to claim 7, characterized in that, Before the monitoring unit sends the first prompt message to the sensing unit, the method further includes: The monitoring unit receives a second notification message sent by the execution unit, where the second notification message is used to notify the establishment of the long connection of the target process and the identification information of the target process.
9. The method according to claim 7, 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 generates a second timestamp in response to the second prompt message; The sensing unit sends second event information to the target management platform, and the second event information includes the second timestamp and information indicating that the long connection of the target process of the target application is disconnected.
10. The method according to claim 9, 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.
11. The method according to claim 9, wherein Sending an indication message to the target application includes: The sensing unit sends an indication message to the target application in response to the second prompt message sent by the monitoring unit.
12. The method according to claim 2, characterized in that, The monitoring unit includes a network daemon netd.
13. The method according to claim 2, wherein The identification information of the target process includes a user identifier UID and a process identifier PID.
14. An electronic device, characterized in that, 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 execute the method according to any one of claims 1-13.
15. A chip, characterized in that, The chip includes a processor and a data interface, and the processor reads instructions stored on the memory through the data interface and executes the method according to any one of claims 1-13 above.
16. A storage medium, characterized in that, Program instructions are stored in the storage medium, and when running on an electronic device, cause the electronic device to execute the method according to any one of claims 1-13.
Citation Information
Patent Citations
Processing method and device for application programs in terminal
CN105893129A
Mobile terminal power consumption lowering method and device
CN106941713A
Android application host process awakening method, storage medium, equipment and system
CN107704274A
Network communication method and device as well as message pushing method and device
CN107800585A
Instant messaging method, medium, device and computer equipment
CN108363629A