Method and apparatus for managing long connection resources
By publishing messages in the cloud server cluster to broadcast and parse terminal device information, actively recycling long-connected resources, the problem of cloud resource waste caused by the inability to sense network exceptions or TBOX terminal exceptions in the existing technology is solved, and timely recycling and saving of resources is achieved.
Patent Information
- Application Number
- CN202110950810.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-18
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2041-08-18
AI Technical Summary
In the prior art, the fixed-period heartbeat packet detection method reported by vehicle timing vehicle condition signal acquisition cannot sense network abnormalities or TBOX terminal abnormalities in real time, resulting in waste of cloud resources.
By posting message broadcasts in the cloud server cluster, analyzing terminal device information and determining whether to store the device information, it actively recycles long-connected resources and avoids waiting for a fixed heartbeat cycle for recycling.
It realizes timely recycling of long-connected resources, saves resource consumption of cloud servers, and improves resource utilization efficiency.
Smart Images

Figure CN115714803B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to vehicle communication technologies, and in particular, to a management method and a management device for long connection resources. Background Art
[0002] With the development of vehicle networking technologies, in-vehicle TBOX (Telematics BOX) has become an essential part of the vehicle networking system. TBOX is a communication component installed in a vehicle, mainly responsible for vehicle communication work, including the collection and reporting of information such as vehicle conditions.
[0003] Currently, for the timed collection and reporting of vehicle condition signals, the TCP / IP network control protocol is generally used as the underlying communication bearer protocol. In the prior art, the signal collection of timed vehicle conditions is usually reported according to a fixed collection frequency. For example, it is collected every 5 seconds and reported every 30 seconds. Based on the business characteristics of the existing timed collection and reporting of vehicle conditions, generally, the TBOX terminal will use TCP to maintain a long connection to reduce the resource consumption and time consumption caused by short connections in communication. The TCP long connection maintains a long connection with the cloud server by sending heartbeats. If the cloud server does not receive the heartbeat from the TBOX terminal within a fixed time, the cloud will actively interrupt the connection. For example, the heartbeat duration is 60 seconds, that is, keepalive = 60 seconds. If the cloud server does not receive a heartbeat packet within 60 seconds, it will disconnect the connection with TCP.
[0004] However, the management method of heartbeat packet detection according to a fixed period in the prior art has the problem that it cannot achieve real-time perception. The current management method of heartbeat packet detection according to a fixed period cannot real-time perceive the problems in the following scenarios: (1) Network anomaly, resulting in reconnection after the TBOX is interrupted; (2) TBOX processing anomaly, resulting in the initiation of a new TCP connection. For example, the TBOX terminal connects to the cloud server A at 15:00:00, the fixed heartbeat keepalive = 60 seconds, and reconnects to the server B abnormally at 15:00:05. However, in the prior art, the cloud server A can recycle the TCP long connection only at 15:01:00, which results in the waste of cloud resources of the cloud server A during the time period from 15:00:05 to 15:01:00.
[0005] In order to solve the above problems existing in the prior art, there is an urgent need in the art for a management method and a management device for long connection resources, which are used to actively recycle the long connection resources of a terminal connecting to other node servers, so as to realize the timely recycling of long connection resources and achieve the effect of saving cloud resources. Summary of the Invention
[0006] A brief overview of one or more aspects is given below to provide a basic understanding of these aspects. This overview is not an exhaustive survey of all contemplated aspects, and is neither intended to identify key or decisive elements of all aspects nor to delimit the scope of any or all aspects. Its sole purpose is to present some concepts of one or more aspects in a simplified form as a prelude to a more detailed description that follows.
[0007] In order to solve the above problems existing in the prior art, the present invention provides a method and a device for managing long connection resources, which can obtain message broadcasts from a cluster, determine whether a corresponding terminal is connected to other node servers according to the message broadcasts, and perform an operation of actively reclaiming long connection resources for the terminals connected to other node servers, so as to realize timely reclamation of long connection resources and achieve the effect of saving cloud resources.
[0008] Specifically, a method for managing long connection resources provided by the first aspect of the present invention includes the following steps: in response to a message broadcast obtained from a cluster, parsing the message broadcast to obtain device information therein; determining whether the device information is stored in the present node; and in response to a determination result that the device information is stored in the present node, reclaiming long connection resources provided to the corresponding terminal. By implementing this method, the present invention can obtain message broadcasts from a cluster, determine whether a corresponding terminal is connected to other node servers according to the message broadcasts, and perform an operation of actively reclaiming long connection resources for the terminals connected to other node servers, so as to realize timely reclamation of long connection resources and achieve the effect of saving cloud resources.
[0009] A device for managing long connection resources provided by the second aspect of the present invention includes a memory and a processor. The processor is connected to the memory and is configured to implement the method for managing long connection resources provided by the first aspect of the present invention. By implementing the above management method, the device for managing long connection resources can obtain message broadcasts from a cluster, determine whether a corresponding terminal is connected to other node servers according to the message broadcasts, and perform an operation of actively reclaiming long connection resources for the terminals connected to other node servers, so as to realize timely reclamation of long connection resources and achieve the effect of saving cloud resources.
[0010] The above computer-readable storage medium provided by the third aspect of the present invention stores computer instructions. When the computer instructions are executed by a processor, the method for managing long connection resources provided by the first aspect of the present invention is implemented. By implementing the above management method, the computer-readable storage medium can obtain message broadcasts from a cluster, determine whether a corresponding terminal is connected to other node servers according to the message broadcasts, and perform an operation of actively reclaiming long connection resources for the terminals connected to other node servers, so as to realize timely reclamation of long connection resources and achieve the effect of saving cloud resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] After reading the detailed description of the embodiments of the present disclosure in conjunction with the following drawings, the above features and advantages of the present invention can be better understood. In the drawings, the components are not necessarily drawn to scale, and components having similar relevant characteristics or features may have the same or similar reference numerals.
[0012] Figure 1 The structural schematic diagram of the management device for long connection resources provided according to some embodiments of the present invention is shown.
[0013] Figure 2 The flowchart of the management method for long connection resources provided according to some embodiments of the present invention is shown.
[0014] Figure 3 The schematic diagram of a normal TCP long connection between a terminal device and a cloud server is shown.
[0015] Figure 4 The schematic diagram of an abnormal TCP long connection between a terminal device and a cloud server is shown.
[0016] Reference numerals:
[0017] 100: Management device for long connection resources;
[0018] 110: Memory; and
[0019] 120: Processor. Detailed embodiments
[0020] The following specific embodiments illustrate the embodiments of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Although the description of the present invention will be introduced in conjunction with the preferred embodiments, this does not mean that the features of this invention are limited to this embodiment. On the contrary, the purpose of introducing the invention in conjunction with the embodiments is to cover other alternatives or modifications that may be extended based on the claims of the present invention. In order to provide a deep understanding of the present invention, many specific details will be included in the following description. The present invention can also be implemented without using these details. In addition, in order to avoid confusing or obscuring the focus of the present invention, some specific details will be omitted in the description.
[0021] In the description of the present invention, it should be noted that unless otherwise clearly specified and defined, the terms "installed", "connected", and "coupled" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium, and it can be the communication inside two components. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0022] In addition, the "upper", "lower", "left", "right", "top", "bottom", "horizontal", and "vertical" used in the following description should be understood as the orientations shown in this section and the relevant drawings. This relative term is only for convenience of description and does not represent that the device described needs to be manufactured or operated in a specific orientation. Therefore, it should not be construed as a limitation to the present invention.
[0023] It can be understood that although terms such as "first", "second", "third", etc. can be used here to describe various components, regions, layers, and / or parts, these components, regions, layers, and / or parts should not be limited by these terms, and these terms are only used to distinguish different components, regions, layers, and / or parts. Therefore, the first component, region, layer, and / or part discussed below can be referred to as the second component, region, layer, and / or part without departing from some embodiments of the present invention.
[0024] As described above, in the prior art, for the timed vehicle condition signal acquisition and reporting, generally, the TCP / IP network control protocol is used as the underlying communication bearer protocol, and the reporting is performed at a fixed acquisition frequency. For example, the acquisition is performed every 5 seconds and the reporting is performed every 30 seconds, etc. Based on the business characteristics of the existing timed vehicle condition acquisition and reporting, in order to reduce the resource consumption and time consumption caused by short connections in communication, generally, the TBOX terminal will use TCP to maintain a long connection. The TCP long connection maintains a long connection with the cloud server by sending heartbeats. If the cloud server does not receive the heartbeat sent by the TBOX terminal within a fixed time, the cloud server will actively interrupt the TCP long connection.
[0025] However, the management method of heartbeat packet detection according to a fixed period in the prior art cannot achieve real-time perception of abnormal connection conditions. The current management method of heartbeat packet detection with a fixed period cannot real-time perceive the problems in the following scenarios: (1) Network anomaly, resulting in reconnection after the TBOX is interrupted; (2) Abnormal processing of the TBOX, resulting in a new TCP connection being initiated again. For example, the TBOX terminal connects to the cloud server A at 15:00:00, with a fixed heartbeat keepalive = 60 seconds, and reconnects to the server B abnormally at 15:00:05. However, in the prior art, the cloud server A can recycle the TCP long connection only at 15:01:00, which leads to waste of cloud resources during the time period from 15:00:05 to 15:01:00 on the cloud server A.
[0026] To solve the above problems existing in the prior art, the present invention provides a management method and a management device for long connection resources, as well as a computer-readable storage medium, which can obtain message broadcasts from a cluster, determine whether a corresponding terminal is connected to other node servers according to the message broadcasts, and perform an operation of actively recycling long connection resources for the terminal connected to other node servers, so as to achieve timely recycling of long connection resources and achieve the effect of saving cloud resources.
[0027] Please refer to Figure 1 , Figure 1 which shows a schematic structural diagram of a management device for long connection resources provided according to some embodiments of the present invention.
[0028] In some non-limiting embodiments, the above-mentioned management method for long connection resources provided by the first aspect of the present invention can be implemented by the above-mentioned management device 100 for long connection resources provided by the second aspect of the present invention. Specifically, the management device 100 for long connection resources is configured with a memory 110 and a processor 120. The memory 110 includes but is not limited to the above-mentioned computer-readable storage medium provided by the third aspect of the present invention, on which computer instructions are stored. The processor 120 is connected to the memory 110 and is configured to execute the computer instructions stored on the memory 110 to implement the above-mentioned management method for long connection resources provided by the first aspect of the present invention.
[0029] The working principle of the long - connection resource management device 100 will be described below in combination with some embodiments of the management method for long - connection resources. Those skilled in the art can understand that these embodiments of the management method for long - connection resources are only some non - restrictive implementation manners provided by the present invention, aiming to clearly show the main concept of the present invention and provide some specific solutions for the public to implement, rather than restricting all working modes and all functions of the long - connection resource management device 100. Similarly, the long - connection resource management device 100 is also a non - restrictive implementation manner provided by the present invention and does not limit the implementation subject of each step in these long - connection resource management methods.
[0030] In some embodiments of the present invention, during the process of periodically collecting and reporting vehicle condition signals, the terminal device usually uses TCP to maintain a long - connection with the cloud server to avoid resource and time consumption problems caused during the short - connection process. The terminal device refers to a mobile terminal configured in a vehicle and capable of communication, such as a TBOX terminal, etc.
[0031] The TBOX terminal (Telematic Box) generally refers to an intelligent in - vehicle terminal in a vehicle networking system. The TBOX terminal is one of the main ways to collect data during the vehicle networking process. By obtaining various vehicle condition data through the TBOX terminal, uploading these data to the background, and / or receiving instructions sent by the background and returning the execution results, users can remotely monitor and control the vehicle. In the embodiments of the present invention, the vehicle condition information of the vehicle is collected in real - time through the in - vehicle TBOX terminal, and this information data is uploaded to the cloud at a fixed collection frequency, such as collecting every 5 seconds and reporting every 30 seconds.
[0032] Please refer to Figure 2 , Figure 2 which shows a flowchart of the long - connection resource management method provided according to some embodiments of the present invention.
[0033] In some embodiments of the present invention, first, the unique ID of the distributed cluster is initialized. The cluster refers to a server cluster configured in the cloud.
[0034] In response to the startup of each node server in the cloud, these distributed node servers generate their unique node ID information in the server cluster. The node ID information of each node server is cached in the corresponding node server as the local node information of the node server.
[0035] For example, there are N node servers distributed in the server cluster of the cloud. When a node server is started, such as starting node server A, the started node server A will generate a unique node ID information corresponding to node server A, and cache the node ID information of node server A in node server A. The node ID information cached in node server A is the local node information of node server A.
[0036] The TBOX terminal on the vehicle side initiates a request to establish a TCP long connection to the cloud through the TCP / IP network protocol.
[0037] When the network communication adopts TCP protocol, a connection must be established between the server and the client before the actual reading and writing operation. When the reading and writing operation is completed, the two parties no longer need this connection and can release this connection. The establishment of the connection requires three handshakes, while the release requires four handshakes, so the establishment of each connection consumes resources and time.
[0038] TCP persistent connection means that the client initiates a connection to the server, the server accepts the client's connection request, and the two parties establish a connection. After the client and the server complete a read and write operation, the connection between them will not be actively closed, and subsequent read and write operations will continue to use this connection. Therefore, TCP persistent connection can reduce the consumption of resources and time during the connection process.
[0039] The keep-alive function of TCP is mainly used to detect the survival status of its long connection. The detection cycle of the TCP keep-alive function is relatively long, generally a heartbeat cycle of 60 seconds. In the application scenario of long connection, the client generally does not actively close the connection between them. However, if the connection between the client and the server is not closed, as more and more clients are connected to the server, the server resources will not be able to support it. At this time, the server usually needs to close some connections that have no read or write events for a long time to avoid damage to the server's service.
[0040] Please see Figure 3 , Figure 3 Figure 1 shows a schematic diagram of a normal TCP long connection between a terminal device and a cloud server. Figure 3 As shown, a normal TCP long connection is established between the TBOX terminal on the vehicle side and a node server in the server cluster on the cloud side.
[0041] When the connection between the TBOX terminal and the cloud server is interrupted, it is necessary to re - establish the TCP long - connection between the TBOX terminal and the cloud server. The abnormal situations of the TBOX terminal and the cloud server side include: (1) The TBOX terminal fails to send heartbeat information beyond the monitoring time. At this time, the cloud server reclaims the long - connection resources, and the cloud server no longer provides the multiplexing function for the same TBOX terminal; (2) The temporary interruption and re - connection of the TBOX due to network anomalies. At this time, the original cloud server has not reclaimed the long - connection resources. In this case, the cloud server should support providing the multiplexing function for the TBOX terminal.
[0042] In the prior art, due to the above - mentioned abnormal situations, the TBOX terminal is interrupted during the heartbeat detection period, and the TCP long - connection will remain alive until the end of the entire heartbeat detection time, and then the interruption problem of the TBOX terminal will be detected.
[0043] Please refer to Figure 4 , Figure 4 which shows a schematic diagram of an abnormal TCP long - connection between the terminal device and the cloud server. As Figure 4 shown, at the initial stage, the TBOX on the in - vehicle device, such as at 15:00:00, establishes a TCP long - connection with the node server A in the cloud, and the TCP long - connection takes a heartbeat period as the detection period, with a fixed heartbeat keepalive = 60 seconds.
[0044] Due to certain reasons, such as poor network signal caused by the vehicle passing through an underground tunnel, or abnormal processing function of the vehicle's TBOX terminal, etc., the TBOX terminal disconnects from the node server A at 15:00:05 and initiates a new TCP long - connection, connecting to the cloud server B. In the prior art, it takes a complete heartbeat cycle of 60 seconds, that is, the cloud server A can reclaim the TCP long - connection at 15:01:00. This results in that during the time period from 15:00:05 to 15:01:00, while the TBOX terminal maintains an effective TCP long - connection with the cloud server B, the TBOX terminal also maintains an invalid TCP long - connection with the cloud server A. This will undoubtedly lead to waste of cloud resources of the node server A.
[0045] Please continue to refer to Figure 2 , in some embodiments of the present invention, after any node server in the cloud receives the long - connection request sent by the TBOX terminal, the node server will parse the received long - connection request to obtain the device information of the TBOX terminal device that sent the request, and cache the device information of the TBOX terminal in this node server.
[0046] After that, the node server that receives the long connection request will, based on the local node information cached in this node server and the device information of the TBOX terminal obtained, broadcast a message to all node servers in the server cluster in the cloud. The broadcast message includes the device information of the TBOX terminal and the node ID information of the node server that has established a TCP long connection with this TBOX terminal. Each node server in the cloud server cluster will listen to the message broadcasts issued by all nodes to determine whether it is necessary to actively recycle the previously allocated long connection resources.
[0047] Taking the initial connection of the TBOX terminal to node server A as an example, when the connection between the TBOX terminal and node server A is interrupted due to network anomalies or TBOX terminal anomalies, in response to the reconnection request of the TBOX terminal, the cloud server cluster still allocates this reconnection request to the original node server A to provide long connection services.
[0048] At this time, node server A parses the long connection request sent by this TBOX terminal and broadcasts a message to all node servers in the cloud server cluster. The broadcast message includes the device information of this TBOX terminal and the node ID information cached in node server A that has established a TCP long connection with this TBOX terminal at this time.
[0049] Each node server in the cloud server cluster listens to the message broadcast issued by this node server A. After each node server receives the node ID information of node server A and the device information of this TBOX terminal in the message broadcast, it compares its own unique local node ID information with the node ID information of node server A received in the message broadcast.
[0050] In the first embodiment, after node server A in the cloud server cluster listens to this message broadcast and determines that its local node ID signal is consistent with the node ID information in the message broadcast, it indicates that this node server is the node server for this TBOX terminal's current connection, so there is no need to perform the operation of recycling long connection resources.
[0051] Furthermore, the node server A will continue to determine whether the device information of the TBOX terminal included in the message broadcast is stored in this node. When it is determined that the device information of the TBOX terminal in the message broadcast is cached in the node server A of this node, it indicates that the node server A has connected to the TBOX terminal before. Therefore, there is no need to provide a new long connection resource to the TBOX terminal again, and the original long connection resource can be directly reused to provide long connection services. By further determining whether the device information of the TBOX terminal in the message broadcast is cached in the node server A of this node, the node server A can avoid repeatedly configuring long connection resources for the TBOX terminal and save the long connection resources of the cloud in the form of reuse.
[0052] In the second embodiment of the present invention, after the node server B in the cloud server cluster listens to the message broadcast issued by the node server A, it is determined that the local node ID signal is inconsistent with the node ID information in the message broadcast. At this time, it is necessary to further determine whether to actively recycle the previously allocated long connection resources according to the device information of the TBOX terminal included in the message broadcast. In response to determining that the device information of the TBOX terminal in the message broadcast is not cached in the node server B of this node, the node server B will determine that this node has not allocated a long connection resource to the TBOX terminal before, and there is no long connection resource in this node that needs to be recycled, and no operation is required.
[0053] In some other embodiments of the present invention, continue to take the above-mentioned TBOX terminal initially connecting to the node server A as an example. After the connection between the TBOX terminal and the node server A is interrupted due to network anomalies or TBOX terminal anomalies, in response to the reconnection request of the TBOX terminal, the cloud server cluster allocates the reconnection request to the new node server B to provide long connection services.
[0054] At this time, the node server B parses the long connection request sent by the TBOX terminal and publishes a message broadcast to all node servers in the cloud server cluster. The message broadcast includes the device information of the TBOX terminal and the node ID information cached in the node server B that has established a TCP long connection with the TBOX terminal at this time.
[0055] Each node server in the cloud server cluster listens to the message broadcast issued by the node server B. After each node server receives the node ID information of the node server B in the message broadcast and the device information of the TBOX terminal, it compares its own unique local node ID information with the node ID information of the node server B received in the message broadcast.
[0056] In the third embodiment, after node server A in the cloud server cluster listens to the message broadcast issued by node server B, it determines that its local node ID signal is inconsistent with the node ID information in the message broadcast. Therefore, it is necessary to further determine whether to actively recycle the previously allocated long connection resources according to the device information of the TBOX terminal included in the message broadcast.
[0057] In response to the device information of the TBOX terminal in the message broadcast being cached in this node, node server A will determine that this node has previously allocated long connection resources to the TBOX terminal. At this time, node server A will immediately recycle the long connection resources previously provided by this node server A and delete the device information of the TBOX terminal cached previously.
[0058] In this way, by obtaining the message broadcast from the cluster, judging whether the corresponding terminal is connected to other node servers according to the message broadcast, and performing the operation of actively recycling the long connection resources for the terminal connected to other node servers, node server A can recycle the long connection resources allocated by this node for the TBOX terminal while the TBOX terminal establishes a long connection communication with node server B, without waiting until the above 60 - second heartbeat period to recycle, thus achieving the effect of saving cloud resources.
[0059] In the fourth embodiment of the present invention, after node server B in the cloud server cluster listens to the message broadcast issued by node server B, it determines that its node ID signal is the same as the node ID information in the message broadcast, and this node is the node server to which this node server connects the TBOX terminal this time, so there is no need to perform the operation of recycling long connection resources.
[0060] Furthermore, node server B will continue to judge whether the device information of the TBOX terminal included in the message broadcast is stored in this node. In response to the device information of the TBOX terminal in the message broadcast not being cached in this node server, node server B will determine that this node has not previously allocated long connection resources to the TBOX terminal. Therefore, it is necessary to allocate new long connection resources to the TBOX terminal. After allocating the long connection resources, node server B that allocates the new long connection resources caches the device information of the TBOX terminal.
[0061] Preferably, in some other embodiments of the present invention, each node server can also directly judge the device information of the TBOX terminal in this node server by omitting the judgment of the node ID information in the message broadcast, thereby improving the recycling efficiency of the long connection resources in the management method of the present invention.
[0062] In the fifth embodiment of the present invention, continue to take the above-mentioned TBOX terminal's initial connection to node server A as an example. After the connection between the TBOX terminal and node server A is interrupted, in response to the reconnection request of the TBOX terminal, the cloud server cluster still allocates the reconnection request to the original node server A to provide long connection services.
[0063] After receiving the TCP long connection request sent by the TBOX terminal after reconnection, node server A parses the long connection request and obtains the device information of the TBOX terminal device. After that, node server A publishes the device information of the TBOX terminal to the cloud server cluster and blocks the message broadcast of this node server A. In this way, all other node servers in the cloud server cluster except the node server A that publishes the message will receive this message broadcast.
[0064] In the fifth embodiment, node server A that publishes the message broadcast cannot monitor the message broadcast sent by itself. In this case, it is equivalent to directly defaulting that the node ID information in the message broadcast is inconsistent with the node ID information of all node servers in the cloud server cluster. Therefore, the steps of parsing node information and comparing node information can be directly omitted, and it can be directly determined whether the device information of the TBOX terminal included in the message broadcast is stored in other node servers.
[0065] For example, in response to the message broadcast sent by node server A, node server B will directly determine whether the device information of the TBOX terminal included in this message broadcast is stored in this node. In response to the fact that the device information of the TBOX terminal in this message broadcast is not cached in this node server, node server B will determine that this node has not allocated long connection resources to this TBOX terminal before, and this node has no long connection resources to recycle, so no operation is required.
[0066] In the sixth embodiment of the present invention, continue to take the above-mentioned TBOX terminal's initial connection to node server A as an example. After the connection between the TBOX terminal and node server A is interrupted due to network anomalies or TBOX terminal anomalies, in response to the reconnection request of the TBOX terminal, the cloud server cluster allocates the reconnection request to a new node server B to provide long connection services.
[0067] After receiving the TCP long connection request sent by the TBOX terminal after reconnection, node server B parses the long connection request and obtains the device information of the TBOX terminal device. Node server B publishes the device information of the TBOX terminal to the cloud server cluster and blocks the message broadcast of this node server B. In this way, all other node servers in the cloud server cluster except the node server B that publishes the message will receive this message broadcast.
[0068] In the sixth embodiment, the local node server B that broadcasts the message cannot monitor the message broadcast sent by itself. In this case, it is equivalent to directly defaulting that the node ID information in the message broadcast is inconsistent with the node ID information of all node servers in the cloud server cluster. Therefore, the steps of parsing and comparing node information can be omitted, and it can be directly determined whether the device information of the TBOX terminal included in the message broadcast is stored in the remaining node servers.
[0069] For example, in response to the message broadcast sent by node server B, node server A will directly determine whether the device information of the TBOX terminal included in the message broadcast is stored in this local node server. In response to the device information of the TBOX terminal in the message broadcast being cached in this local node server, node server A will determine that this local node has previously allocated long connection resources to the TBOX terminal. At this time, node server A will immediately reclaim the long connection resources previously provided by this local node server and delete the previously cached device information of the TBOX terminal.
[0070] By obtaining the message broadcast from the cluster, determining whether the corresponding terminal is connected to other node servers based on the message broadcast, and actively reclaiming the long connection resources for the terminal connected to other node servers, node server A can reclaim the long connection resources allocated by this local node for the TBOX terminal while the TBOX terminal establishes a long connection communication with node server B, without waiting until the above 60 - second heartbeat period to perform the reclaim, thereby achieving the effect of saving cloud resources.
[0071] Furthermore, the above - mentioned preferred embodiment provides a preferred broadcast scheme for shielding the local node server. By omitting the steps of parsing and comparing node information during the process of determining whether long connection resources need to be reclaimed, the reclaim efficiency of long connection resources in the management method of the present invention is further improved.
[0072] Based on the above description, the present invention provides a management method and management device for long connection resources, which can obtain the message broadcast from the cluster, determine whether the corresponding terminal is connected to other node servers based on the message broadcast, and actively perform the operation of reclaiming long connection resources for the terminal connected to other node servers, thereby realizing the timely reclaim of long connection resources to achieve the effect of saving cloud resources.
[0073] Although the above methods are illustrated and described as a series of actions for simplicity of explanation, it should be understood and appreciated that these methods are not limited by the order of the actions, because according to one or more embodiments, some actions may occur in a different order and / or concurrently with other actions that are illustrated and described herein or that are not illustrated and described herein but are understood by those skilled in the art.
[0074] In addition, althoughFigure 1 The processor 120 described in the above embodiments can be implemented by a combination of software and hardware. However, it can be understood that the processor 120 can also be implemented in software or hardware. For hardware implementation, the processor 120 can be implemented in one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), processors, controllers, microcontrollers, microprocessors, other electronic devices for performing the above functions, or a selected combination of the above devices. For software implementation, the controller 40 can be implemented by independent software modules such as procedures and functions running on a general-purpose chip, where each module performs one or more of the functions and operations described herein.
[0075] Those skilled in the art will appreciate that information, signals, and data can be represented using any of a variety of different technologies and techniques. For example, the data, instructions, commands, information, signals, bits, symbols, and chips described throughout the above description can be represented by voltage, current, electromagnetic waves, magnetic fields or magnetic particles, optical fields or optical particles, or any combination thereof.
[0076] Those skilled in the art will further appreciate that the various illustrative logical blocks, modules, circuits, and algorithmic steps described in connection with the embodiments disclosed herein can be implemented as electronic hardware, computer software, or a combination of both. To clearly illustrate this interchangeability of hardware and software, the various illustrative components, blocks, modules, circuits, and steps are described above in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and the design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
[0077] The various illustrative logical modules and circuits described in connection with the embodiments disclosed herein can be implemented or executed using a general-purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A general-purpose processor may be a microprocessor, but in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. The processor may also be implemented as a combination of computing devices, such as a combination of a DSP and a microprocessor, multiple microprocessors, one or more microprocessors cooperating with a DSP core, or any other such configuration.
[0078] The previous description of the present disclosure is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to the present disclosure will be apparent to those skilled in the art, and the general principles defined herein can be applied to other variations without departing from the spirit or scope of the present disclosure. Thus, the present disclosure is not intended to be limited to the examples and designs described herein, but should be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for managing long connection resources, characterized in that, Including the following steps: In response to an abnormal interruption of the long connection between the terminal and this node, initiate a long connection request to other nodes again via the terminal; In response to receiving the long connection request, parse the received long connection request via the other node to obtain the device information of the terminal, and broadcast the message to the cluster; In response to the message broadcast obtained from the cluster, parse the message broadcast to obtain the device information therein; Determine whether this node stores the device information; And In response to the judgment result that this node stores the device information, recycle the long connection resources provided to the corresponding terminal.
2. The management method according to claim 1, wherein, Before performing the step of parsing the message broadcast to obtain the device information therein, the management method further includes the following steps: Listen to the message broadcasts issued by all nodes in the cluster.
3. The management method according to claim 2, wherein, The step of parsing the message broadcast to obtain the device information therein includes: parsing the message broadcast to obtain the node information and device information therein, The step of determining whether this node stores the device information includes: comparing the node information with the local node information stored in this node; and determining whether this node stores the device information in response to the comparison result that the node information is inconsistent with the local node information.
4. The management method according to claim 3, further includes the following steps: In response to receiving a long connection request sent by a terminal device, parse the long connection request to obtain the device information of the terminal device; And According to the local node information cached in this node and the device information of the terminal device, broadcast the message to all nodes in the cluster.
5. The management method according to claim 4, wherein, Before performing the step of broadcasting the message to all nodes in the cluster according to the local node information cached in this node and the device information of the terminal device, the management method further includes the following steps: In response to the startup of this node, generate the unique node information of this node in the cluster; and Cache the unique node information in this node as the local node information of this node.
6. The management method according to claim 4, wherein, After performing the step of parsing the long connection request to obtain the device information of the terminal device, the management method further includes the following steps: Determine whether this node stores the device information; In response to the judgment result that this node stores the device information, provide the original long connection resources for the terminal device; and In response to the judgment result that this node does not store the device information, allocate new long connection resources for the terminal device.
7. The management method according to claim 1, wherein, Before performing the step of parsing the message broadcast to obtain the device information therein, the management method further includes the following steps: Listen to the message broadcasts issued by the remaining nodes in the cluster except this node.
8. The management method according to claim 7, further includes the following steps: In response to receiving a long connection request sent by a terminal device, parse the long connection request to obtain the device information of the terminal device; And According to the device information of the terminal device, broadcast a message to the cluster to block this node.
9. The management method according to claim 1, wherein, The terminal includes a TBOX terminal configured in a vehicle, the cluster includes a server cluster configured in the cloud, and the node includes a node server in the server cluster.
10. A management device for long connection resources, characterized in that, Comprising: A memory; And A processor, the processor is connected to the memory and is configured to implement the management method of the long connection resource as described in any one of claims 1 to 9.
11. A computer-readable storage medium having computer instructions stored thereon, characterized in that, When the computer instructions are executed by the processor, the management method of the long connection resource as described in any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Method and system of communication between client-side and application server
CN103516766A
Long connection message sending method, server and storage medium
CN111083193A