A communication method based on Netty server cluster

By introducing clustered deployment, load balancing components and cache middleware into Netty servers, the problem of limited number of terminals connected to a stand-alone Netty server is solved, and more efficient terminal connection management and system scalability are achieved.

CN115529314BActive Publication Date: 2025-02-18北京恩吉鸿业能源科技有限责任公司
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211141341.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-20
Publication Date
2025-02-18
Estimated Expiration
2042-09-20

AI Technical Summary

Technical Problem

There is a limit on the number of connected terminals for a stand-alone Netty server and cannot meet the connection needs of a large number of terminals.

Method used

By deploying a stand-alone Netty server in a clustered manner, using load balancing components and cache middleware, load balancing and terminal connection information management between multiple Netty servers.

Benefits of technology

It effectively solves the limit on the number of terminals connected to a stand-alone Netty server, and improves the scalability and processing capabilities of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115529314B_ABST
    Figure CN115529314B_ABST
Patent Text Reader

Abstract

The present application provides a communication method based on a Netty server cluster, including: a load balancing component forwards a communication request received from a terminal device to a target Netty server; the target Netty server creates a communication connection channel with the terminal device and generates current terminal connection information; the terminal device sends a login authentication request to the load balancing component; the load balancing component forwards the login authentication request to the target Netty server through the communication connection channel; the target Netty server transmits the received login authentication request to a business service for verification through an RPC call, and receives a first verification result; the target Netty server judges the first verification result to complete the update of the terminal connection information. The present application solves the limitation on the number of terminals connected to a single Netty server by deploying the single Netty server in a clustered manner.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data communication technology, and in particular to a communication method based on a Netty server cluster. Background Art

[0002] Netty is a Java open source framework provided by JBOSS. Netty provides an asynchronous, event-driven network application framework and tools for quickly developing high-performance, high-reliability network servers and client programs.

[0003] As the business continues to develop, the number of terminals continues to increase. The terminal connections that a single Netty server can carry are limited and cannot meet the connection needs of a large number of terminals. Summary of the invention

[0004] In view of this, the purpose of this application is to provide at least one communication method based on a Netty server cluster, which solves the limitation on the number of terminals connected to a single Netty server by deploying the single Netty server in a clustered manner.

[0005] This application mainly includes the following aspects:

[0006] In a first aspect, an embodiment of the present application provides a communication method based on a Netty server cluster, wherein the Netty server cluster includes multiple Netty servers, a load balancing component, and a cache middleware, and the method includes:

[0007] The load balancing component forwards the communication request sent by the terminal device to the target Netty server according to the preset load balancing strategy; the target Netty server creates a communication connection channel with the terminal device and generates corresponding current terminal connection information; the terminal device responds to the communication connection trigger event and sends a login authentication request to the load balancing component, and the load balancing component forwards the login authentication request to the target Netty server through the communication connection channel; the target Netty server transmits the login authentication request to the business service for verification through the RPC call method, and receives the first verification result of the login authentication request fed back by the business service; the target Netty server judges the first verification result, and if the first verification result is successful, the current terminal connection information is sent to the cache middleware to complete the update of the terminal connection information corresponding to the terminal device.

[0008] In a possible implementation, the login authentication request carries identity information of the terminal device, and the first verification result also includes verification failure, wherein the business service determines the first verification result in the following manner: judging whether there is registration information of the terminal device based on the identity information of the terminal device; if there is registration information of the terminal device, the first verification result is verification success; if there is no registration information of the terminal device, the first verification result is verification failure.

[0009] In a possible implementation, the current terminal connection information includes a current connection object of the terminal device and an identification of the terminal device, wherein the cache middleware completes the update of the terminal connection information corresponding to the terminal device in the following manner: judging whether there is historical terminal connection information corresponding to the terminal device according to the terminal device identification; if there is no historical terminal connection information corresponding to the terminal device, saving the current terminal connection information to complete the update of the terminal connection information corresponding to the terminal device; if there is historical terminal connection information corresponding to the terminal device, judging whether the current connection object corresponding to the terminal device is the same as the historical connection object of the terminal device indicated by the historical terminal connection information; if the current connection object corresponding to the terminal device is different from the historical connection object, using the current connection terminal connection information to replace the historical terminal connection information to complete the update of the terminal connection information corresponding to the terminal device.

[0010] In a possible implementation, the Netty server cluster also includes a message middleware, wherein the method further includes: the business service generates a message instruction for a target terminal device, and publishes the message instruction to the message middleware for broadcast, the message instruction carries a terminal device identifier and a control instruction; each Netty server subscribes to the message instruction from the message middleware; for each Netty server, it is determined whether the Netty server has a communication connection channel corresponding to the terminal device identifier; for each Netty server, if the Netty server has a communication connection channel corresponding to the terminal device identifier, the control instruction is sent to the target terminal device through the corresponding communication connection channel.

[0011] In a possible implementation, each Netty server determines whether there is a communication connection channel corresponding to the terminal device identifier in the following manner: extracting terminal connection information corresponding to the terminal device identifier from the cache middleware according to the terminal device identifier; if the terminal connection information corresponding to the terminal device identifier can be extracted from the cache middleware, it is determined that the Netty server has a communication connection channel corresponding to the terminal device identifier; if the terminal connection information corresponding to the terminal device identifier cannot be extracted from the cache middleware, it is determined that the Netty server does not have a communication connection channel corresponding to the terminal device identifier.

[0012] In a possible implementation, the method further includes: the business service generates a message instruction for the terminal device, and sends the message instruction to the cache middleware, the message instruction carries the terminal device identifier and the control instruction; the cache middleware determines whether there is a communication connection channel corresponding to the terminal device identifier, and if there is a communication connection channel corresponding to the terminal device identifier, sends the control instruction to the target Netty server indicated by the communication connection channel; the target Netty server sends the control instruction to the corresponding terminal device through the communication connection channel.

[0013] In a possible implementation, the method also includes: the terminal device generates a business request, and sends the business request to a target Netty server connected to the terminal device through a corresponding communication connection channel, the business request carries business verification information; the target Netty server sends the business request to the business service through an RPC call; the business service verifies the business verification information, and generates a second verification result, which is fed back to the target Netty server through an RPC call; the business service judges the second verification result, and if the second verification result is a successful verification, a business response corresponding to the business request is generated, and sent to the message middleware for broadcast, and the business response carries a terminal device identifier corresponding to the terminal device.

[0014] In the second aspect, the embodiment of the present application also provides a Netty server cluster, the Netty server cluster includes multiple Netty servers, a load balancing component, a cache middleware and multiple business services, the load balancing component forwards the communication request sent by the terminal device to the target Netty server according to the preset load balancing strategy; the target Netty server creates a communication connection channel with the terminal device and generates corresponding current terminal connection information; the terminal device sends a login authentication request to the load balancing component in response to the communication connection trigger event, and the load balancing component forwards the login authentication request to the target Netty server through the communication connection channel; the target Netty server transmits the login authentication request to the business service for verification through an RPC call, and receives a first verification result of the login authentication request fed back by the business service; the target Netty server judges the first verification result, and if the first verification result is a successful verification, the current terminal connection information is sent to the cache middleware to complete the update of the terminal connection information corresponding to the terminal device.

[0015] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and the machine-readable instructions are executed by the processor to execute the steps of the communication method described in the first aspect or any possible implementation manner of the first aspect.

[0016] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the communication steps described in the first aspect or any possible implementation of the first aspect are executed.

[0017] The present application provides a communication method based on a Netty server cluster, including: a load balancing component forwards a communication request received from a terminal device to a target Netty server according to a preset load balancing strategy; the target Netty server creates a communication connection channel with the terminal device and generates corresponding current terminal connection information; the terminal device responds to a communication connection trigger event and sends a login authentication request to the load balancing component; the load balancing component forwards the login authentication request to the target Netty server through the communication connection channel; the target Netty server transmits the received login authentication request to a business service for verification through an RPC call, and receives a first verification result; the target Netty server judges the first verification result to complete the update of the terminal connection information corresponding to the terminal device. The present application solves the limitation on the number of terminals connected to a single Netty server by deploying the single Netty server in a clustered manner.

[0018] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0020] Figure 1 A flow chart of a communication method based on a Netty server cluster provided in an embodiment of the present application is shown;

[0021] Figure 2A schematic diagram of the structure of a Netty server cluster provided in an embodiment of the present application is shown;

[0022] Figure 3 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0023] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art, under the guidance of the content of the present application, can add one or more other operations to the flowchart, or remove one or more operations from the flowchart.

[0024] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0025] With the continuous development of communication services, the number of terminals continues to increase. The terminal connections that a single Netty server can carry are limited and cannot meet the connection needs of a large number of terminals.

[0026] Based on this, the embodiment of the present application provides a communication method based on a Netty server cluster, which solves the limitation on the number of terminals connected to a single Netty server by deploying the single Netty server in a clustered manner, as follows:

[0027] See also Figure 1 , Figure 1 A flow chart of a communication method based on a Netty server cluster provided in an embodiment of the present application is shown. Figure 2 , Figure 2 A schematic diagram of the structure of a Netty server cluster provided in an embodiment of the present application is shown, Figure 1 and Figure 2As shown, the Netty server cluster includes multiple Netty servers 10, a load balancing component 20 and a cache middleware 30. The method provided in the embodiment of the present application includes the following steps:

[0028] S100, the load balancing component forwards the communication request sent by the terminal device to the target Netty server according to the preset load balancing strategy.

[0029] In a preferred embodiment, if Figure 2 As shown, multiple terminal devices 40 can send communication requests to the load balancing component. The terminal device 40 can be a charging pile. The load balancing component 20 can serve as a unified external interface provided by the Netty server cluster. For each terminal device 40, before it establishes a connection with the Netty server cluster, it can establish a connection with the load balancing component 20 through the pre-set address of the load balancing component 20 to send a communication request to the load balancing component 20 to establish a communication connection.

[0030] After receiving the communication request sent by the terminal device 40, the load balancing component 20 can select a target Netty server from multiple Netty servers 10 according to a preset load balancing strategy to establish a communication connection with the terminal device 40, and forward the communication request to the target Netty server, wherein the communication request carries the identity information of the terminal device, including but not limited to the terminal device device number and the terminal device identifier, and the communication request also carries the terminal device identifier, the terminal device IP address and the terminal device port number of the terminal device 40.

[0031] S110. The target Netty server creates a communication connection channel with the terminal device and generates corresponding current terminal connection information.

[0032] In a preferred embodiment, when the load balancing component 20 assigns the terminal device 40 to the target Netty server, the target Netty server will establish a communication connection channel for communicating with the terminal device 40. After the communication connection channel is established, the corresponding current terminal connection information will be generated. The current terminal connection information includes but is not limited to the terminal device identifier, the communication connection channel identifier, the terminal device IP address and the terminal device port number, and the Netty server IP address and the Netty server port number to which the terminal device 40 is connected.

[0033] S120. In response to the communication connection triggering event, the terminal device sends a login authentication request to the load balancing component, and the load balancing component forwards the login authentication request to the target Netty server through the communication connection channel.

[0034] In a specific embodiment, when the communication connection channel between the target Netty server and the terminal device 40 is created, a communication connection trigger event is generated on the terminal device 40. In response to the communication connection trigger event, the terminal device 40 directly sends a login authentication request to the load balancing component 20 to authenticate the communication connection channel between the target Netty server and the terminal device 40, wherein the login authentication request carries the identity information of the terminal device 40.

[0035] S130. The target Netty server transmits the login authentication request to the business service for verification through an RPC call, and receives a first verification result of the login authentication request fed back by the business service.

[0036] Specifically, Figure 2 The business service 50 shown may be a terminal device management platform for performing data transmission with each terminal device 40 .

[0037] In a preferred embodiment, the first verification result further includes verification failure, wherein the business service 50 can determine the first verification result in the following manner:

[0038] Based on the identity information of the terminal device 40, it is determined whether there is registration information of the terminal device 40. If there is registration information of the terminal device 40, the first verification result is successful verification; if there is no registration information of the terminal device 40, the first verification result is failed verification.

[0039] Specifically, after the communication connection channel between the terminal device 40 and the target Netty server is created, the communication connection channel needs to be authenticated, that is, it is determined whether the business service 50 has the registration information of the terminal device 40. After each terminal device 40 completes the registration on the business service 50, the corresponding registration information will be generated and the corresponding identity information of the terminal device 40 will be added, such as the terminal device identification. At this time, the user can lock the corresponding registration information through the terminal device identification.

[0040] In a specific embodiment, the terminal device 40 needs to complete the registration of the terminal device information in the business service 50 first. Only when the terminal device 40 completes the registration in the business service 50, its corresponding communication connection channel can perform subsequent data transmission.

[0041] S140. The target Netty server determines the first verification result. If the first verification result is successful, the current terminal connection information is sent to the cache middleware to complete the update of the terminal connection information corresponding to the terminal device.

[0042] In a preferred embodiment, the cache middleware 30 is used to record the terminal connection information of the communication connection channel established by each Netty server. The cache middleware 30 provides an external interface. Multiple Netty servers 10 can be connected to the external interface provided by the cache middleware 30 via a TCP connection to cache and interact with the cache middleware 30. Each Netty server has the same function and shares the cache middleware 30.

[0043] In a specific embodiment, in the cache middleware 30, the terminal connection information can be recorded in the form of a key-value pair with a fixed prefix plus a terminal device identifier or a terminal device number as the key and the JSON form of the terminal connection information as the value, and the terminal connection information corresponding to the same Netty server is stored in the same data group, and the corresponding Netty server identifier is added.

[0044] The current terminal connection information also includes the current connection object of the terminal device, and the current connection object is the Netty server to which the terminal device is connected.

[0045] In a specific embodiment, the terminal device 40 can always establish a communication connection channel with only one Netty server 10. Therefore, it is necessary to complete the update of the terminal connection information corresponding to the communication connection channel in the cache middleware 30. Only the communication connection channel corresponding to the terminal connection information saved by the cache middleware 30 can perform subsequent data transmission. Specifically, the cache middleware 30 completes the update of the terminal connection information corresponding to the terminal device 40 in the following manner:

[0046] Determine whether there is historical terminal connection information corresponding to the terminal device based on the terminal device identification; if there is no historical terminal connection information corresponding to the terminal device, save the current terminal connection information to complete the update of the terminal connection information corresponding to the terminal device; if there is historical terminal connection information corresponding to the terminal device, determine whether the current connection object corresponding to the terminal device is the same as the historical connection object of the terminal device indicated by the historical terminal connection information; if the current connection object corresponding to the terminal device is different from the historical connection object, use the current connection terminal connection information to replace the historical terminal connection information to complete the update of the terminal connection information corresponding to the terminal device.

[0047] If the current connection object corresponding to the terminal device is the same as the historical connection object, determine whether the current terminal connection information is consistent with the historical terminal connection information except the connection object. If any information except the connection object is inconsistent, use the current terminal connection information to replace the historical terminal connection information to complete the update of the terminal connection information corresponding to the terminal device. If all other information except the connection object is consistent, no further processing is performed on the current terminal connection information.

[0048] like Figure 2 As shown, the Netty server cluster also includes a message middleware 60 , and each Netty server 10 is connected to the same message middleware 60 through an external interface provided by the message middleware 60 .

[0049] After the communication connection channel between each terminal device and the Netty server cluster is created, the method further includes:

[0050] The business service 50 generates a message instruction for the target terminal device, and publishes the message instruction to the message middleware 60 for broadcasting. Each Netty server 10 subscribes to the message instruction from the message middleware 60; for each Netty server 10, it is determined whether the Netty server 10 has a communication connection channel corresponding to the terminal device identifier. If the Netty server 10 has a communication connection channel corresponding to the terminal device identifier, the control instruction is sent to the target terminal device through the corresponding communication connection channel.

[0051] In a preferred embodiment, the message instruction carries the terminal device identifier and the control instruction. When the business service 50 needs to send the control instruction to a specific terminal device, it only needs to publish the message instruction to the message middleware 60 for broadcasting.

[0052] The business service 50 publishes a message instruction to the message middleware 60. For each netty server 10, after subscribing to and receiving the message instruction, it determines whether the target terminal device 40 indicated by the message instruction has established a connection with itself, that is, whether there is a communication connection channel connecting the target terminal device 40 and itself. If the target terminal device 40 has established a connection with itself, the control instruction is sent to the target terminal device through the corresponding communication connection channel. If the target terminal device 40 has not established a connection with itself, the broadcast message is ignored.

[0053] In a preferred embodiment, each Netty server determines whether there is a communication connection channel corresponding to the terminal device identifier in the following manner:

[0054] The terminal connection information corresponding to the terminal device identifier is extracted from the cache middleware according to the terminal device identifier. If the terminal connection information corresponding to the terminal device identifier can be extracted from the cache middleware, it is determined that the Netty server has a communication connection channel corresponding to the terminal device identifier. If the terminal connection information corresponding to the terminal device identifier cannot be extracted from the cache middleware, it is determined that the Netty server does not have a communication connection channel corresponding to the terminal device identifier.

[0055] In a specific embodiment, since the terminal connection information corresponding to the communication connection channel created by each Netty server is cached in the cache middleware, each Netty server needs to extract the corresponding data from the cache middleware according to its own corresponding Netty server, and determine whether there is a communication connection channel corresponding to the terminal device identifier in the data.

[0056] In another preferred embodiment, the business service can also communicate with the terminal device in the following manner:

[0057] The business service 50 generates a message instruction for the target terminal device and sends the message instruction to the cache middleware. The cache middleware determines whether there is a communication connection channel corresponding to the terminal device identifier. If there is a communication connection channel corresponding to the terminal device identifier, the control instruction is sent to the target Netty server indicated by the communication connection channel. The target Netty server sends the control instruction to the target terminal device through the communication connection channel.

[0058] Specifically, after generating the corresponding message instruction, the business service can publish the message instruction to the message middleware for broadcasting, or directly send it to the cache middleware, which will forward it to the specific target Netty server. You can choose one of the two methods.

[0059] In another preferred embodiment, the method further comprises:

[0060] The terminal device generates a business request and sends the business request to the target Netty server connected to the terminal device through the corresponding communication connection channel. The target Netty server sends the business request to the business service through the RPC call method. The target business service verifies the business verification information and generates a second verification result, which is fed back to the target Netty server through the RPC call method. The business service judges the second verification result. If the second verification result is a successful verification, a business response corresponding to the business request is generated and sent to the message middleware for broadcast. The business response carries the terminal device identifier corresponding to the terminal device.

[0061] Specifically, the business request carries business verification information. When the terminal device initiates a business request for the target business to the business service, the business request needs to be verified first, that is, whether the business request meets the preset conditions for opening the target business. For example, if the target business is to use a membership card for payment, the business request will carry the membership card number, and the business service will verify whether the membership card number has been pre-registered. If it has been pre-registered, the verification is successful. If it has not been registered, the verification fails.

[0062] Only if the second verification result is successful verification, the business service will be based on the business response corresponding to the terminal device, that is, the business response will be sent to the terminal device through any of the above embodiments to facilitate subsequent operations of the terminal device.

[0063] If the second verification result is verification failure, the service request is ignored.

[0064] Based on the same application idea, please refer to Figure 3 , Figure 3 A structural schematic diagram of an electronic device provided in an embodiment of the present application is shown, wherein the electronic device 200 includes: a processor 210, a memory 220 and a bus 230, wherein the memory 220 stores machine-readable instructions executable by the processor 210, and when the electronic device 200 is running, the processor 210 communicates with the memory 220 via the bus 230, and the machine-readable instructions are executed by the processor 210 when running to perform the steps of the communication method described in any of the above embodiments.

[0065] Based on the same application concept, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the communication method provided in the above embodiment are executed.

[0066] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0067] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0068] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0069] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-ONly Memory, ROM), random access memory (RaNdom Access Memory, RAM), disk or optical disk and other media that can store program codes.

[0070] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A communication method based on a Netty server cluster, characterized in that: The Netty server cluster includes multiple Netty servers, load balancing components, cache middleware and message middleware. The method comprises: The load balancing component forwards the communication request received from the terminal device to the target Netty server according to the preset load balancing strategy; The target Netty server creates a communication connection channel with the terminal device and generates corresponding current terminal connection information; The terminal device sends a login authentication request to the load balancing component in response to the communication connection triggering event, and the load balancing component forwards the login authentication request to the target Netty server through the communication connection channel; The target Netty server transmits the login authentication request to the business service for verification through an RPC call, and receives a first verification result of the login authentication request fed back by the business service; The target Netty server judges the first verification result, and if the first verification result is successful, sends the current terminal connection information to the cache middleware to complete the update of the terminal connection information corresponding to the terminal device, wherein the current terminal connection information includes the current connection object and the terminal device identifier of the terminal device; Among them, it also includes: The business service generates a message instruction for the target terminal device, and publishes the message instruction to the message middleware for broadcasting, wherein the message instruction carries the terminal device identifier and the control instruction; Each Netty server subscribes to the message instruction from the message middleware; For each Netty server, determine whether the Netty server has a communication connection channel corresponding to the terminal device identifier; For each Netty server, if the Netty server has a communication connection channel corresponding to the terminal device identifier, the control instruction is sent to the target terminal device through the corresponding communication connection channel.

2. The method according to claim 1, characterized in that: The login authentication request carries the identity information of the terminal device, and the first verification result also includes verification failure. The business service determines the first verification result in the following manner: According to the identity information of the terminal device, determining whether there is registration information of the terminal device; If the registration information of the terminal device exists, the first verification result is verification success; If the registration information of the terminal device does not exist, the first verification result is verification failure.

3. The method according to claim 1, characterized in that: The cache middleware completes the update of the terminal connection information corresponding to the terminal device in the following manner: Determine whether there is historical terminal connection information corresponding to the terminal device according to the terminal device identifier; If there is no historical terminal connection information corresponding to the terminal device, the current terminal connection information is saved to complete the update of the terminal connection information corresponding to the terminal device; If there is historical terminal connection information corresponding to the terminal device, determining whether the current connection object corresponding to the terminal device is the same as the historical connection object of the terminal device indicated by the historical terminal connection information; If the current connection object corresponding to the terminal device is different from the historical connection object, the historical terminal connection information is replaced with the current connection terminal connection information to complete the update of the terminal connection information corresponding to the terminal device.

4. The method according to claim 1, characterized in that Each Netty server determines whether there is a communication connection channel corresponding to the terminal device identifier in the following way: Extracting terminal connection information corresponding to the terminal device identifier from the cache middleware according to the terminal device identifier; If the terminal connection information corresponding to the terminal device identifier can be extracted from the cache middleware, it is determined that the Netty server has a communication connection channel corresponding to the terminal device identifier; If the terminal connection information corresponding to the terminal device identifier cannot be extracted from the cache middleware, it is determined that the Netty server does not have a communication connection channel corresponding to the terminal device identifier.

5. The method according to claim 1, characterized in that The method further comprises: The business service generates a message instruction for the terminal device and sends the message instruction to the cache middleware, wherein the message instruction carries the terminal device identifier and the control instruction; The cache middleware determines whether there is a communication connection channel corresponding to the terminal device identifier, and if there is a communication connection channel corresponding to the terminal device identifier, sends the control instruction to the target Netty server indicated by the communication connection channel; The target Netty server sends the control instruction to the corresponding terminal device through the communication connection channel.

6. The method according to claim 1, characterized in that The method further comprises: The terminal device generates a service request, and sends the service request to a target Netty server connected to the terminal device through a corresponding communication connection channel, wherein the service request carries service verification information; The target Netty server sends the business request to the business service through an RPC call; The business service verifies the business verification information, generates a second verification result, and feeds back to the target Netty server through an RPC call; The business service determines the second verification result. If the second verification result is successful verification, a business response corresponding to the business request is generated and sent to the message middleware for broadcasting. The business response carries a terminal device identifier corresponding to the terminal device.

7. A Netty-based server cluster, characterized in that: The Netty server cluster includes multiple Netty servers, load balancing components, cache middleware, multiple business services and message middleware. The load balancing component forwards the communication request received from the terminal device to the target Netty server according to the preset load balancing strategy; The target Netty server creates a communication connection channel with the terminal device and generates corresponding current terminal connection information; The terminal device sends a login authentication request to the load balancing component in response to the communication connection triggering event, and the load balancing component forwards the login authentication request to the target Netty server through the communication connection channel; The target Netty server transmits the login authentication request to the business service for verification through an RPC call, and receives a first verification result of the login authentication request fed back by the business service; The target Netty server judges the first verification result, and if the first verification result is successful, sends the current terminal connection information to the cache middleware to complete the update of the terminal connection information corresponding to the terminal device, wherein the current terminal connection information includes the current connection object and the terminal device identifier of the terminal device; The business service generates a message instruction for a target terminal device, and publishes the message instruction to the message middleware for broadcasting, wherein the message instruction carries a terminal device identifier and a control instruction; Each Netty server subscribes to the message instruction from the message middleware, determines whether the Netty server has a communication connection channel corresponding to the terminal device identifier, and if it is detected that the Netty server has a communication connection channel corresponding to the terminal device identifier, sends the control instruction to the target terminal device through the corresponding communication connection channel.

8. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and the machine-readable instructions are executed by the processor to execute the steps of the communication method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the communication method according to any one of claims 1 to 6 are executed.

Citation Information

Patent Citations

  • Internet of vehicles terminal access method and device, storage medium and electronic equipment

    CN114915656A