Network long connection method and device with dynamically bound ports, and related equipment
Through the long-connection method of port dynamically bound network connection, the long-connection gateway in the gateway cluster is selected and its internal listening port is dynamically opened, which solves the problems of increasing system complexity and data backlog caused by message queue failure in the gateway cluster, and achieves higher system reliability and response speed.
Patent Information
- Application Number
- CN202411742136.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-11-29
AI Technical Summary
In a gateway cluster, the server opens both the external listening port and the internal communication port, resulting in increased system complexity and difficulty in system recovery in the event of message queue failure, which may lead to data backlog, delay or loss.
Through the long network connection method of port dynamically bound, the load balancing device selects a long connection gateway from the gateway cluster based on the current system status and load balancing policy, and dynamically opens its internal listening port, avoiding dependence on message queues.
Reduces system complexity and maintenance costs, improves system reliability and response speed, and avoids message queues becoming bottlenecks or single-point failure sources.
Smart Images

Figure CN119544722A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network communication technology, and in particular to a network long connection method, device and related equipment for dynamically binding ports. Background Art
[0002] In the process of exchanging financial business messages between financial institutions and third-party institutions through direct network connections, a gateway cluster architecture is often used to handle a large number of concurrent requests and data transmissions. In order to ensure high availability and load balancing, each server in the gateway cluster usually opens both the external listening port and the internal communication port, and maintains data interaction with the third-party institution through a persistent connection. However, in the cluster architecture, although only one server actually holds a persistent connection with the outside, other servers still need to receive and process messages to be forwarded to the third-party institution. In order to achieve this function, a message queue is usually used as a caching mechanism to pass the messages to be processed within the cluster. The server holding the persistent connection reads the message from the message queue and forwards it to the third-party institution, thereby ensuring the timely transmission and processing of the data.
[0003] However, this architectural design increases the complexity of the system, especially when the message queue fails, the recovery of the entire system becomes more difficult. The message queue may become a bottleneck or single point of failure in the system, resulting in data backlog, delay or loss. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a network long connection method, device and related equipment for dynamic port binding to solve the problems of increased system complexity and data backlog caused by each server in a gateway cluster opening an external listening port and an internal communication port at the same time.
[0005] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:
[0006] The first aspect of the present invention discloses a network long connection method for dynamically binding a port, which is applied to an external zone load balancing device, and the method comprises:
[0007] When receiving a persistent connection request from a third-party system, obtain the current system status;
[0008] Determine a persistent connection gateway from multiple gateways in the gateway cluster according to the current system state and the load balancing strategy, and send an opening request to the persistent connection gateway to open the internal listening port of the persistent connection gateway; wherein the external listening port of each gateway in the gateway cluster is in an open state;
[0009] When receiving the transaction request sent by the persistent connection gateway, the transaction request is sent to the third-party system.
[0010] Preferably, the method further comprises:
[0011] When receiving the disconnection request sent by the third-party system, a closing request is sent to the persistent connection gateway to close the internal listening port of the persistent connection gateway.
[0012] Preferably, determining a persistent connection gateway from a plurality of gateways in a gateway cluster according to the current system state and a load balancing strategy includes:
[0013] Obtain resource usage, current health status, number of connections, and response time of each gateway in the gateway cluster included in the current system status;
[0014] Dynamically adjust the load balancing strategy based on each gateway's resource usage, current health status, number of connections, and response time;
[0015] According to the adjusted load balancing strategy, a persistent connection gateway is determined from the gateway cluster.
[0016] A second aspect of the present invention discloses a network long connection method for dynamically binding a port, which is applied to an intranet load balancing device, and the method comprises:
[0017] When receiving a transaction request sent by the intranet transaction system, searching for a persistent connection gateway from the gateway cluster, wherein the persistent connection gateway is a gateway whose internal listening port and external listening port are both open;
[0018] Sending a short connection request to the long connection gateway to establish a TCP short connection with the long connection gateway;
[0019] The transaction request is sent to the long connection gateway based on the TCP short connection, so that the long connection gateway sends the transaction request to the third-party system through the external area load balancing device.
[0020] The third aspect of the present invention discloses a network long connection device with dynamic port binding, which is applied to an external area load balancing device, and the device includes:
[0021] A first acquisition unit, configured to acquire a current system state when receiving a persistent connection request sent by a third-party system;
[0022] A determination unit, configured to determine a persistent connection gateway from a plurality of gateways in a gateway cluster according to the current system state and a load balancing strategy, and send an opening request to the persistent connection gateway to open an internal listening port of the persistent connection gateway; wherein the external listening port of each of the gateways in the gateway cluster is in an open state;
[0023] The first sending unit is configured to send the transaction request to the third-party system when receiving the transaction request sent by the persistent connection gateway.
[0024] Preferably, the device further comprises:
[0025] The second sending unit is used to send a closing request to the persistent connection gateway when receiving the disconnection persistent connection request sent by the third-party system, so as to close the internal listening port of the persistent connection gateway.
[0026] Preferably, the determining unit is specifically used for:
[0027] Obtain resource usage, current health status, number of connections, and response time of each gateway in the gateway cluster contained in the current system status; dynamically adjust the load balancing strategy according to the resource usage, current health status, number of connections, and response time of each gateway; and determine a persistent connection gateway from the gateway cluster according to the adjusted load balancing strategy.
[0028] A fourth aspect of the present invention discloses a network long connection device with dynamic port binding, which is applied to an intranet load balancing device, and the device comprises:
[0029] A search unit, configured to search for a persistent connection gateway from a gateway cluster when receiving a transaction request sent by an intranet transaction system, wherein the persistent connection gateway is a gateway whose internal listening port and external listening port are both in an open state;
[0030] A third sending unit is used to send a short connection request to the long connection gateway to establish a TCP short connection with the long connection gateway;
[0031] The fourth sending unit is used to send the transaction request to the long connection gateway based on the TCP short connection, so that the long connection gateway sends the transaction request to the third-party system through the external area load balancing device.
[0032] A fifth aspect of the present invention discloses an electronic device, comprising: a memory and a processor;
[0033] Wherein, the memory is used to store programs;
[0034] The processor is used to execute the program. When the program is executed, it is specifically used to implement a network long connection method for dynamically binding a port disclosed in the first aspect of the present invention, or a network long connection method for dynamically binding a port disclosed in the second aspect of the present invention.
[0035] The sixth aspect of the present invention discloses a computer storage medium for storing a computer program. When the computer program is executed, it is used to implement a network long connection method for dynamically binding a port disclosed in the first aspect of the present invention, or a network long connection method for dynamically binding a port disclosed in the second aspect of the present invention.
[0036] Based on the above-mentioned embodiment of the present invention, a network long connection method, device and related equipment for dynamic port binding are provided. When the load balancing device in the external connection area receives a long connection request sent by a third-party system, it selects a long connection gateway from the gateway cluster according to the current system status and the preset load balancing strategy, and sends an opening request to activate the internal listening port of the gateway. Once the internal listening port of the long connection gateway is opened, the load balancing device in the intranet area can forward the received transaction request to the gateway, and then send it to the third-party system. At the same time, the load balancing device in the intranet area is responsible for establishing a short connection with the selected long connection gateway to receive and forward transaction requests. By dynamically binding the internal listening port of the gateway cluster, a plug-and-play solution is provided that does not require additional complex systems such as message queues. It is designed with a simple module and relies only on the gateway communication process, which effectively reduces the system complexity and maintenance costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0038] Figure 1 A schematic diagram of a network long connection solution for non-dynamic port binding provided by an embodiment of the present invention;
[0039] Figure 2 A schematic diagram of an application environment provided by an embodiment of the present invention;
[0040] Figure 3 A first flow chart of a network long connection method for dynamically binding a port provided by an embodiment of the present invention;
[0041] Figure 4 A first schematic diagram of a network long connection solution for dynamic port binding provided by an embodiment of the present invention;
[0042] Figure 5 A flowchart for determining a persistent connection gateway provided by an embodiment of the present invention;
[0043] Figure 6 A second schematic diagram of a network long connection solution for dynamic port binding provided by an embodiment of the present invention;
[0044] Figure 7 A third schematic diagram of a network long connection solution for dynamic port binding provided by an embodiment of the present invention;
[0045] Figure 8 A second flow chart of a network long connection method for dynamically binding a port provided by an embodiment of the present invention;
[0046] Fig. 9 A first structural block diagram of a network long connection device for dynamic port binding provided by an embodiment of the present invention;
[0047] Fig.10 A second structural block diagram of a network long connection device for dynamic port binding provided by an embodiment of the present invention;
[0048] Fig.11 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] In this application, the terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element.
[0051] As can be seen from the background technology, in order to ensure high availability and load balancing, each server in the gateway cluster usually opens both the external listening port and the internal communication port, such as Figure 1As shown in the figure, each server (gateway 1 and gateway 2) has opened the external listening port 8107 and the internal communication port 8018 at the same time. They interact with third-party organizations through long connections. Although only one server actually maintains a long connection with the outside, other servers also need to process and forward messages to third-party organizations. In order to achieve this function, message queues are usually used as a caching mechanism. Specifically, after receiving transaction requests, all gateways will cache these requests in the message queue. The gateway holding a long connection will continuously poll the message queue, obtain transaction requests, and forward them to the external third-party system. However, although the introduction of message queues improves the processing capacity of the system, it also increases the complexity and maintenance cost of the system.
[0052] Therefore, an embodiment of the present invention provides a network long connection method, device and related equipment for dynamic port binding. When the load balancing device in the external connection area receives a long connection request sent by a third-party system, it selects a long connection gateway from the gateway cluster according to the current system status and the preset load balancing strategy, and sends an opening request to activate the internal listening port of the gateway. Once the internal listening port of the long connection gateway is opened, the load balancing device in the intranet area can forward the received transaction request to the gateway, and then send it to the third-party system. At the same time, the load balancing device in the intranet area is responsible for establishing a short connection with the selected long connection gateway to receive and forward transaction requests. By dynamically binding the internal listening port of the gateway cluster, a plug-and-play solution is provided that does not require additional complex systems such as message queues. It is designed with a simple module and relies only on the gateway communication process, which effectively reduces the system complexity and maintenance costs.
[0053] See also Figure 2 , which shows a schematic diagram of an application environment applicable to an embodiment of the present invention. The network long connection method for dynamically binding ports provided in an embodiment of the present invention can be applied to Figure 2 The interactive system 100 shown includes an external zone load balancing device 101 and an internal zone load balancing device 102 .
[0054] The external area load balancing device 101 is connected to the third-party system 103. The internal area load balancing device 102 is connected to the internal network transaction system 105. The external area load balancing device 101 is connected to the internal area load balancing device 102 through the gateway cluster 104.
[0055] Specifically, when receiving a persistent connection request initiated by the third-party system 103 , the external zone load balancing device 101 establishes a TCP persistent connection with a gateway server in the gateway cluster 104 according to a certain load balancing strategy.
[0056] It is understandable that the full name of TCP long connection is "Transmission Control Protocol (Transmission Control Protocol) long connection". TCP is a connection-oriented, reliable, byte stream-based transport layer communication protocol, which provides sequential transmission of data packets, error detection and retransmission mechanisms to ensure data integrity and reliability. In a TCP long connection, once a connection is established, it will be maintained until one of the communicating parties explicitly closes it, instead of closing the connection after each communication ends like a short connection. Long connections can reduce the overhead of frequently establishing and closing connections, and are suitable for scenarios that require continuous communication.
[0057] In addition, when receiving a transaction request initiated by the intranet transaction system 105 , the intranet zone load balancing device 102 establishes a TCP short connection with a gateway server that has established a TCP long connection in the gateway cluster 104 according to a certain load balancing strategy.
[0058] It is understandable that the full name of TCP short connection is "Transmission Control Protocol (Transmission Control Protocol) short connection". In TCP short connection, the communicating parties will close the connection after each data transmission is completed, instead of keeping the connection state. This method is suitable for scenarios where continuous communication is not required or the communication interval is long.
[0059] Based on the application scenarios disclosed in the above embodiments of the present invention, Figure 3 As shown, it is a first flow chart of a network persistent connection method for dynamically binding a port provided by an embodiment of the present invention. The network persistent connection method for dynamically binding a port can be applied to the external zone load balancing device 101 in the above application scenario, and mainly includes the following steps:
[0060] Step S301: when receiving a persistent connection request sent by a third-party system, obtaining the current system status.
[0061] In the specific implementation of step S301, when the external zone load balancing device receives a persistent connection request sent by a third-party system, the current state in the system is obtained so as to subsequently determine the persistent connection gateway.
[0062] It is understandable that the external zone load balancing device intelligently distributes traffic according to the load balancing strategy by monitoring CPU and memory usage to ensure that no single gateway fails due to overload. At the same time, the external zone load balancing device will regularly perform health checks to determine which gateways are active and can process requests. Only gateways that pass the health check will be selected as long-connection gateways, thereby ensuring that traffic is reasonably distributed to gateways that can provide stable services. The specific process of determining the long-connection gateway is shown in step S302.
[0063] Step S302: Determine a persistent connection gateway from multiple gateways in the gateway cluster according to the current system state and load balancing strategy, and send an opening request to the persistent connection gateway to open the internal listening port of the persistent connection gateway.
[0064] It is understandable that the external monitoring port is a network access port provided to an external third-party organization, and the internal monitoring port is a network access port provided to the internal business system of an organization.
[0065] It should be noted that the external listening port of each gateway in the gateway cluster is in an open state. That is to say, when there is no persistent connection with the third-party system, and after a persistent connection with the third-party system is established, all gateway servers in the gateway cluster permanently open the external listening port for the third-party system, such as Figure 4 As shown, the external listening port 8107 of all gateway servers is open.
[0066] In the specific implementation of step S302, the external zone load balancing device determines the persistent connection gateway from multiple gateways in the gateway cluster according to the acquired current system status and load balancing strategy. The specific determination process is detailed in the embodiment of the present invention. Figure 5 Based on this, the external zone load balancing device sends an opening request to the persistent connection gateway to open the internal listening port of the persistent connection gateway.
[0067] It is understandable that the embodiments of the present invention Figure 5 Specifically include:
[0068] Step S501: Obtain the resource usage, current health status, number of connections and response time of each gateway in the gateway cluster contained in the current system status.
[0069] In the specific implementation of step S501, the external zone load balancing device obtains the resource usage, current health status, number of connections and response time of each gateway in the gateway cluster contained in the current system status by monitoring the CPU and memory usage.
[0070] Step S502: dynamically adjust the load balancing strategy according to the resource usage, current health status, number of connections and response time of each gateway.
[0071] In the specific implementation of step S502, the external zone load balancing device dynamically adjusts the load balancing strategy according to the resource usage, current health status, number of connections and response time of each gateway.
[0072] It is understandable that the load balancing device in the external area can dynamically adjust the load balancing strategy by monitoring the resource usage, health status, number of connections and response time of each gateway in real time to ensure that the traffic is efficiently and evenly distributed to each gateway. This intelligent adjustment mechanism helps to optimize resource utilization and improve the overall performance and reliability of the system.
[0073] Step S503: According to the adjusted load balancing strategy, a persistent connection gateway is determined from the gateway cluster.
[0074] In the process of implementing step S503, the load balancing device in the external zone intelligently selects the most suitable gateway from the gateway cluster as the long connection gateway based on the adjusted load balancing strategy, taking into account factors such as the resource usage, health status, number of connections and response time of the gateway.
[0075] It should be noted that the gateway for persistent connections is not fixed, but is dynamically determined by the load balancing device based on the current system status. Only the gateway selected to establish a persistent connection will open the internal listening port 8108.
[0076] For example Figure 6 As shown, the load balancing device in the external zone selects gateway 2 from the gateway cluster as the persistent connection gateway, and gateway 2 opens the internal listening port 8108; since gateway 1 is not selected as the persistent connection gateway, gateway 1 only opens the external listening port 8107.
[0077] It is understandable that such a selection mechanism ensures that traffic is distributed efficiently while improving the stability and responsiveness of the service.
[0078] Step S303: When receiving the transaction request sent by the persistent connection gateway, the transaction request is sent to the third-party system.
[0079] In the specific implementation of step S303, when the load balancing device in the external connection zone receives the transaction request sent by the persistent connection gateway, it sends the transaction request to the third-party system.
[0080] For example Figure 7 As shown, gateway 2 receives the transaction request through the internal listening port 8108, and then sends the transaction request to the third-party system.
[0081] It can be understood that this process ensures that transaction requests can be smoothly transmitted from the gateway to the required server, maintaining the smooth operation of the system and the continuity of data.
[0082] It should be noted that if the gateway fails to close the internal listening port 8108 after the persistent connection is disconnected, it may lead to resource waste, reduced service availability, impaired system stability, increased security risks, and traffic distribution issues, and also make monitoring and troubleshooting more difficult. Therefore, ensuring that the internal listening port is closed in time after the persistent connection is disconnected is crucial to maintaining the efficiency, stability, and security of the system.
[0083] Based on this, in some specific embodiments, when the load balancing device in the external zone receives a disconnect request from a third-party system, it sends a close request to the persistent connection gateway to close the internal listening port of the persistent connection gateway.
[0084] It is understandable that, combined with Figure 7 As shown in the figure, if the long connection is disconnected, Gateway 2 will close the internal listening port 8108, but will continue to retain the external listening port 8107 to maintain external services. Such a dynamic management mechanism ensures the reasonable allocation of resources and the efficient operation of the system.
[0085] In the embodiment of the present invention, dynamic binding of the listening port inside the gateway cluster is realized without relying on complex system auxiliary functions such as message queues, which is a plug-and-play solution. The module design of this solution is simple and can be implemented only with the gateway communication process. It is suitable for business scenarios with moderate transaction volume and the need for quick restart to solve problems. By reducing the complexity of the system, it also helps to reduce the maintenance cost of the system.
[0086] Based on the application scenarios disclosed in the above embodiments of the present invention, Figure 8 As shown, it is a second flow chart of a network persistent connection method for dynamically binding a port provided by an embodiment of the present invention. The network persistent connection method for dynamically binding a port can be applied to the intranet zone load balancing device 102 in the above application scenario, and mainly includes the following steps:
[0087] Step S801: When receiving a transaction request sent by the intranet transaction system, searching for a persistent connection gateway from the gateway cluster.
[0088] It can be understood that the persistent connection gateway is a gateway in which both the internal listening port and the external listening port are open.
[0089] In the specific implementation of step S801, when the intranet zone load balancing device receives a transaction request sent by the intranet transaction system, it selects a gateway from the gateway cluster according to the load balancing strategy to establish a TCP short connection.
[0090] In actual applications, since only the long-connection gateway has opened the internal listening port, the load balancing device in the intranet area finds the long-connection gateway from the gateway cluster.
[0091] Step S802: Send a short connection request to the persistent connection gateway to establish a TCP short connection with the persistent connection gateway.
[0092] In the specific implementation of step S802, after finding the persistent connection gateway, the intranet zone load balancing device sends a short connection request to the persistent connection gateway to establish a TCP short connection with the persistent connection gateway.
[0093] It should be noted that the process of the load balancing device in the intranet zone initiating a short connection request to the persistent connection gateway in order to establish a TCP short connection allows for fast data exchange between the intranet zone and the persistent connection gateway while maintaining the efficiency and stability of network communication. In this way, the intranet zone can effectively manage the communication with the persistent connection gateway to ensure the continuity and reliability of data transmission.
[0094] Step S803: Send the transaction request to the persistent connection gateway based on the TCP short connection, so that the persistent connection gateway sends the transaction request to the third-party system through the external zone load balancing device.
[0095] In the specific implementation of step S803, the intranet load balancing device is responsible for forwarding the transaction requests initiated by the intranet transaction system to the persistent connection gateway through the established TCP short connection. In this way, the persistent connection gateway can receive these requests and further send them to the third-party system through the external load balancing device.
[0096] Understandably, this process ensures that transaction requests can be efficiently and securely transmitted from the intranet to the external system, while utilizing load balancing devices to optimize resource allocation and improve system responsiveness.
[0097] In the embodiment of the present invention, this solution realizes the dynamic binding of the listening port inside the gateway cluster, without relying on complex system auxiliary functions such as message queues, and is a plug-and-play solution. The module design of this solution is simple and can be implemented only with the gateway communication process. It is suitable for business scenarios with moderate transaction volume and the need for fast restart to solve problems. By reducing the complexity of the system, it also helps to reduce the maintenance cost of the system.
[0098] The above-mentioned embodiment of the present invention Figure 3 The network long connection method shown in the figure corresponds to a port dynamic binding method, see Fig. 9 , shows a first structural block diagram of a network long connection device for dynamic port binding provided by an embodiment of the present invention, which is applied to an external zone load balancing device. The device includes: a first acquisition unit 901, a determination unit 902 and a first sending unit 903.
[0099] The first acquisition unit 901 is used to acquire the current system state when receiving a long connection request sent by a third-party system.
[0100] The determination unit 902 is used to determine a persistent connection gateway from multiple gateways in the gateway cluster according to the current system status and load balancing strategy, and send an opening request to the persistent connection gateway to open the internal listening port of the persistent connection gateway; wherein the external listening port of each gateway in the gateway cluster is in an open state.
[0101] The determination unit 902 is specifically used to: obtain the resource usage, current health status, number of connections and response time of each gateway in the gateway cluster contained in the current system status; dynamically adjust the load balancing strategy according to the resource usage, current health status, number of connections and response time of each gateway; and determine the long connection gateway from the gateway cluster according to the adjusted load balancing strategy.
[0102] The first sending unit 903 is configured to send the transaction request to a third-party system when receiving the transaction request sent by the persistent connection gateway.
[0103] In the embodiment of the present invention, dynamic binding of the listening port inside the gateway cluster is realized without relying on complex system auxiliary functions such as message queues, which is a plug-and-play solution. The module design of this solution is simple and can be implemented only with the gateway communication process. It is suitable for business scenarios with moderate transaction volume and the need for quick restart to solve problems. By reducing the complexity of the system, it also helps to reduce the maintenance cost of the system.
[0104] Combination Fig. 9 The content shown, the device also includes: a second sending unit, which is used to send a closing request to the long connection gateway when receiving a disconnection request sent by a third-party system to close the internal listening port of the long connection gateway.
[0105] The above-mentioned embodiment of the present invention Figure 8 The network long connection method shown in the figure corresponds to a port dynamic binding method, see Fig.10 , shows a second structural block diagram of a network long connection device for dynamic port binding provided by an embodiment of the present invention, which is applied to an intranet load balancing device. The device includes: a search unit 1001, a third sending unit 1002 and a fourth sending unit 1003.
[0106] The searching unit 1001 is used to search for a persistent connection gateway from a gateway cluster when receiving a transaction request sent by an intranet transaction system, wherein the persistent connection gateway is a gateway whose internal listening port and external listening port are both in an open state.
[0107] The third sending unit 1002 is used to send a short connection request to the long connection gateway to establish a TCP short connection with the long connection gateway.
[0108] The fourth sending unit 1003 is used to send the transaction request to the persistent connection gateway based on the TCP short connection, so that the persistent connection gateway sends the transaction request to the third-party system through the external zone load balancing device.
[0109] In the embodiment of the present invention, dynamic binding of the listening port inside the gateway cluster is realized without relying on complex system auxiliary functions such as message queues, which is a plug-and-play solution. The module design of this solution is simple and can be implemented only with the gateway communication process. It is suitable for business scenarios with moderate transaction volume and the need for quick restart to solve problems. By reducing the complexity of the system, it also helps to reduce the maintenance cost of the system.
[0110] Another embodiment of the present application provides an electronic device, such as Fig.11 As shown, it includes: a memory 1101 and a processor 1102.
[0111] The memory 1101 is used to store programs.
[0112] The processor 1102 is used to execute a program. When the program is executed, it is specifically used to implement a network long connection method for dynamically binding a port as provided in any of the above embodiments.
[0113] Another embodiment of the present application provides a computer storage medium for storing a computer program. When the computer program is executed, it is used to implement a network long connection method for dynamically binding a port as provided in any of the above embodiments.
[0114] Computer storage media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0115] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.
[0116] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0117] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A network long connection method for dynamic port binding, characterized in that: Applied to an external zone load balancing device, the method comprises: When receiving a persistent connection request from a third-party system, obtain the current system status; Determine a persistent connection gateway from multiple gateways in the gateway cluster according to the current system state and the load balancing strategy, and send an opening request to the persistent connection gateway to open the internal listening port of the persistent connection gateway; wherein the external listening port of each gateway in the gateway cluster is in an open state; When receiving the transaction request sent by the persistent connection gateway, the transaction request is sent to the third-party system.
2. The method according to claim 1, characterized in that The method further comprises: When receiving the disconnection request sent by the third-party system, a closing request is sent to the persistent connection gateway to close the internal listening port of the persistent connection gateway.
3. The method according to claim 1, characterized in that The determining of a persistent connection gateway from a plurality of gateways in a gateway cluster according to the current system state and the load balancing strategy includes: Obtain resource usage, current health status, number of connections, and response time of each gateway in the gateway cluster included in the current system status; Dynamically adjust the load balancing strategy based on each gateway's resource usage, current health status, number of connections, and response time; According to the adjusted load balancing strategy, a persistent connection gateway is determined from the gateway cluster.
4. A network long connection method for dynamic port binding, characterized in that: Applied to an intranet load balancing device, the method includes: When receiving a transaction request sent by the intranet transaction system, searching for a persistent connection gateway from the gateway cluster, wherein the persistent connection gateway is a gateway whose internal listening port and external listening port are both open; Sending a short connection request to the long connection gateway to establish a TCP short connection with the long connection gateway; The transaction request is sent to the long connection gateway based on the TCP short connection, so that the long connection gateway sends the transaction request to the third-party system through the external area load balancing device.
5. A network long connection device with dynamic port binding, characterized in that: Applied to an external area load balancing device, the device comprises: A first acquisition unit, configured to acquire a current system state when receiving a persistent connection request sent by a third-party system; A determination unit, configured to determine a persistent connection gateway from a plurality of gateways in a gateway cluster according to the current system state and a load balancing strategy, and send an opening request to the persistent connection gateway to open an internal listening port of the persistent connection gateway; wherein the external listening port of each of the gateways in the gateway cluster is in an open state; The first sending unit is configured to send the transaction request to the third-party system when receiving the transaction request sent by the persistent connection gateway.
6. The device according to claim 5, characterized in that The device also includes: The second sending unit is used to send a closing request to the persistent connection gateway when receiving the disconnection persistent connection request sent by the third-party system, so as to close the internal listening port of the persistent connection gateway.
7. The device according to claim 5, characterized in that The determining unit is specifically used for: Obtain resource usage, current health status, number of connections, and response time of each gateway in the gateway cluster contained in the current system status; dynamically adjust the load balancing strategy according to the resource usage, current health status, number of connections, and response time of each gateway; and determine a persistent connection gateway from the gateway cluster according to the adjusted load balancing strategy.
8. A network long connection device with dynamic port binding, characterized in that: Applied to load balancing equipment in an intranet area, the device comprises: A search unit, configured to search for a persistent connection gateway from a gateway cluster when receiving a transaction request sent by an intranet transaction system, wherein the persistent connection gateway is a gateway whose internal listening port and external listening port are both in an open state; A third sending unit is used to send a short connection request to the long connection gateway to establish a TCP short connection with the long connection gateway; The fourth sending unit is used to send the transaction request to the long connection gateway based on the TCP short connection, so that the long connection gateway sends the transaction request to the third-party system through the external area load balancing device.
9. An electronic device, characterized in that: include: Memory and processor; Wherein, the memory is used to store programs; The processor is used to execute the program, and when the program is executed, it is specifically used to implement a network long connection method for dynamically binding a port as described in any one of claims 1 to 3, or a network long connection method for dynamically binding a port as described in claim 4.
10. A computer storage medium, characterized in that: Used to store a computer program, which, when executed, is used to implement a network long connection method for dynamically binding a port as described in any one of claims 1 to 3, or a network long connection method for dynamically binding a port as described in claim 4.
Citation Information
Patent Citations
Method for solving multi-layer long connection load balance of Internet of Things
CN110098987A
Stateless TCP (Transmission Control Protocol) long connection server side method based on micro-service architecture
CN118075268A
Assigning gateways for heterogeneous wireless mobile networks
US20120294187A1
Internet of Things Communication Method, Apparatus, and System
US20200045546A1
Port management method and server
WO2021143172A1