CN115529314A - Communication method based on Netty server cluster - Google Patents

Communication method based on Netty server cluster Download PDF

Info

Publication number
CN115529314A
CN115529314A CN202211141341.1A CN202211141341A CN115529314A CN 115529314 A CN115529314 A CN 115529314A CN 202211141341 A CN202211141341 A CN 202211141341A CN 115529314 A CN115529314 A CN 115529314A
Authority
CN
China
Prior art keywords
terminal equipment
terminal
netty server
target
netty
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211141341.1A
Other languages
Chinese (zh)
Inventor
林烈鑫
曹雅武
莫尧钧
卓木维
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Enji Hongye Energy Technology Co ltd
Original Assignee
Beijing Enji Hongye Energy Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Enji Hongye Energy Technology Co ltd filed Critical Beijing Enji Hongye Energy Technology Co ltd
Priority to CN202211141341.1A priority Critical patent/CN115529314A/en
Publication of CN115529314A publication Critical patent/CN115529314A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Telephonic Communication Services (AREA)

Abstract

The application provides a communication method based on a Netty server cluster, which comprises the following steps: the load balancing component forwards the received communication request sent by the terminal equipment to the target Netty server; the target Netty server establishes a communication connection channel with the terminal equipment and generates current terminal connection information; the terminal equipment 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 the service for verification in an RPC calling mode and receives a first verification result; and the target Netty server judges the first verification result so as to finish updating the terminal connection information. According to the method and the system, the single-machine Netty server is deployed in a clustering mode, and the limitation of the number of the single-machine Netty server connection terminals is solved.

Description

Communication method based on Netty server cluster
Technical Field
The application relates to the technical field of data communication, in particular to a communication method based on a Netty server cluster.
Background
Netty is a java open source framework provided by JBOSS, which provides an asynchronous, event-driven web application framework and tools for rapid development of high-performance, high-reliability web servers and client programs.
With the continuous development of services, the number of terminals is continuously increased, and the terminals which can be borne by the single-machine Netty server are limited in connection, so that the connection requirements of a large number of terminals cannot be met.
Disclosure of Invention
In view of the above, an object of the present invention is to provide at least a communication method based on a Netty server cluster, which solves the limitation of the number of terminals connected to a single-machine Netty server by deploying the single-machine Netty server in a clustered manner.
The application mainly comprises the following aspects:
in a first aspect, an embodiment of the present application provides a communication method based on a Netty server cluster, where the Netty server cluster includes multiple Netty servers, a load balancing component, and a cache middleware, and the method includes:
the load balancing component forwards the received communication request sent by the terminal equipment to the target Netty server according to a preset load balancing strategy; the target Netty server is used for establishing a communication connection channel with the terminal equipment and generating corresponding current terminal connection information; the terminal equipment responds to the communication connection triggering event, 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 in an RPC calling mode, and receives a first verification result of the login authentication request fed back by the business service; and the target Netty server judges the first verification result, and if the first verification result is verification success, the current terminal connection information is sent to the cache middleware so as to finish updating of the terminal connection information corresponding to the terminal equipment.
In a possible implementation manner, the login authentication request carries identity information of the terminal device, and the first verification result further includes a verification failure, where the business service determines the first verification result by: judging whether registration information of the terminal equipment exists or not according to the identity information of the terminal equipment; if the registration information of the terminal equipment exists, the first verification result is successful verification; and if the registration information of the terminal equipment does not exist, the first verification result is verification failure.
In a possible implementation manner, the current terminal connection information includes a current connection object of the terminal device and a terminal device identifier, where the cache middleware completes updating of the terminal connection information corresponding to the terminal device by: judging whether historical terminal connection information corresponding to the terminal equipment exists or not according to the terminal equipment identification; if the historical terminal connection information corresponding to the terminal equipment does not exist, storing the current terminal connection information so as to finish updating the terminal connection information corresponding to the terminal equipment; if the historical terminal connection information corresponding to the terminal equipment exists, judging whether a current connection object corresponding to the terminal equipment is the same as a historical connection object of the terminal equipment indicated by the historical terminal connection information; and if the current connection object corresponding to the terminal equipment is different from the historical connection object, replacing the historical terminal connection information with the current connection terminal connection information so as to finish updating the terminal connection information corresponding to the terminal equipment.
In one possible implementation, the Netty server cluster further comprises message middleware, wherein the method further comprises: the business service generates a message instruction aiming at the target terminal equipment, and issues the message instruction to a message middleware for broadcasting, wherein the message instruction carries a terminal equipment identifier and a control instruction; each Netty server subscribes a message instruction from the message middleware; judging whether a communication connection channel corresponding to the terminal equipment identifier exists in each Netty server; and for each Netty server, if the Netty server has a communication connection channel corresponding to the terminal equipment identifier, the control instruction is issued to the target terminal equipment through the corresponding communication connection channel.
In a possible implementation manner, each Netty server determines whether a communication connection channel corresponding to the terminal device identifier exists or not by the following method: extracting terminal connection information corresponding to the terminal equipment identification from the cache middleware according to the terminal equipment identification; if the terminal connection information corresponding to the terminal equipment identifier can be extracted from the cache middleware, determining that a communication connection channel corresponding to the terminal equipment identifier exists in the Netty server; and if the terminal connection information corresponding to the terminal equipment identifier cannot be extracted from the cache middleware, determining that the Netty server does not have a communication connection channel corresponding to the terminal equipment identifier.
In one possible embodiment, the method further comprises: the business service generates a message instruction aiming at the terminal equipment and sends the message instruction to the cache middleware, wherein the message instruction carries the terminal equipment identification and the control instruction; the cache middleware judges whether a communication connection channel corresponding to the terminal equipment identifier exists or not, and sends a control instruction to a target Netty server indicated by the communication connection channel if the communication connection channel corresponding to the terminal equipment identifier exists; and the target Netty server sends the control command to the corresponding terminal equipment through the communication connection channel.
In one possible embodiment, the method further comprises: the terminal equipment generates a service request, and sends the service request to a target Netty server connected with the terminal equipment through a corresponding communication connection channel, wherein the service request carries service verification information; the target Netty server sends the service request to the service in an RPC calling mode; the service verifies the service verification information, generates a second verification result and feeds the second verification result back to the target Netty server in an RPC calling mode; the service judges the second verification result, if the second verification result is successful, a service response corresponding to the service request is generated and sent to the message middleware for broadcasting, and the service response carries the terminal equipment identifier corresponding to the terminal equipment.
In a second aspect, an embodiment of the present application further provides a Netty-based server cluster, where the Netty server cluster includes multiple Netty servers, a load balancing component, a cache middleware, and multiple service services, and the load balancing component forwards a received communication request sent by a terminal device to a target Netty server according to a preset load balancing policy; the target Netty server establishes a communication connection channel with the terminal equipment and generates corresponding current terminal connection information; the terminal equipment responds to a communication connection triggering event, sends a login authentication request to a load balancing component, and the load balancing component forwards the login authentication request to a target Netty server through the communication connection channel; the target Netty server transmits the login authentication request to a service for verification in an RPC calling mode, and receives a first verification result of the login authentication request fed back by the service; and 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 a cache middleware to complete the updating of the terminal connection information corresponding to the terminal equipment.
In a third aspect, an embodiment of the present application further provides an electronic device, including: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, the processor and the memory communicate with each other through the bus when the electronic device is operated, and the machine-readable instructions are executed by the processor to perform the steps of the communication method according to the first aspect or any one of the possible implementation manners of the first aspect.
In a fourth aspect, this embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and the computer program is executed by a processor to perform the steps of communicating as described in the first aspect or any one of the possible implementation manners of the first aspect.
The application provides a communication method based on a Netty server cluster, which comprises the following steps: the load balancing component forwards the received communication request sent by the terminal equipment to the target Netty server according to a preset load balancing strategy; the target Netty server establishes a communication connection channel with the terminal equipment and generates corresponding current terminal connection information; the terminal equipment responds to the communication connection triggering 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 the service for verification in an RPC calling mode and receives a first verification result; and the target Netty server judges the first verification result so as to update the terminal connection information corresponding to the terminal equipment. According to the method and the system, the single-machine Netty server is deployed in a clustering mode, and the limitation of the number of the single-machine Netty server connection terminals is solved.
In order to make the aforementioned objects, features and advantages of the present application comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.
Fig. 1 shows a flowchart of a communication method based on a Netty server cluster according to an embodiment of the present application;
fig. 2 is a schematic structural diagram illustrating a Netty server cluster provided in an embodiment of the present application;
fig. 3 shows a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
To make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it should be understood that the drawings in the present application are for illustrative and descriptive purposes only and are not used to limit the scope of protection of the present application. Further, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of the present application. It should be understood that the operations of the flow diagrams may be performed out of order, and that steps without logical context may be performed in reverse order or concurrently. In addition, one skilled in the art, under the guidance of the present disclosure, may add one or more other operations to the flowchart, or may remove one or more operations from the flowchart.
In addition, the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present application without making any creative effort, shall fall within the protection scope of the present application.
With the continuous development of communication services, the number of terminals is continuously increased, and the terminals which can be borne by a single Netty server are limited in connection, so that the connection requirements of a large number of terminals cannot be met.
Based on this, the embodiment of the present application provides a communication method based on a Netty server cluster, which solves the limitation of the number of the connection terminals of the single-machine Netty server by deploying the single-machine Netty server in a clustering manner, and specifically includes the following steps:
referring to fig. 1, fig. 1 is a flowchart illustrating a communication method based on a Netty server cluster according to an embodiment of the present disclosure. Referring to fig. 2, fig. 2 shows a schematic structural diagram of a Netty server cluster provided in the embodiment of the present application, and as shown in fig. 1 and fig. 2, the Netty server cluster includes a plurality of Netty servers 10, a load balancing component 20, and a caching middleware 30, and the method provided in the embodiment of the present application includes the following steps:
s100, the load balancing component forwards the received communication request sent by the terminal device to the target Netty server according to a preset load balancing strategy.
In a preferred embodiment, as shown in fig. 2, a plurality of terminal devices 40 may all send communication requests to the load balancing component, each terminal device 40 may be a charging pile, and each load balancing component 20 may serve as a unified external interface provided by the Netty server cluster, and for each terminal device 40, before it does not establish a connection with the Netty server cluster, a connection may be established with the load balancing component 20 through a preset address of the load balancing component 20, so as to send a communication request for establishing a communication connection to the load balancing component 20.
After receiving the communication request sent by the terminal device 40, the load balancing component 20 may select one target Netty server from the plurality of Netty servers 10 according to a preset load balancing policy to establish a communication connection with the terminal device 40, and forward the communication request to the target Netty server, where the communication request carries the identity information of the terminal device, including but not limited to the terminal 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.
S110, the target Netty server creates a communication connection channel between the target Netty server and the terminal equipment and generates corresponding current terminal connection information.
In a preferred embodiment, after the load balancing component 20 allocates 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, and after the communication connection channel is established, corresponding current terminal connection information will be generated, where the current terminal connection information includes, but is not limited to, a terminal device identifier, a communication connection channel identifier, a terminal device IP address and a terminal device port number, and a Netty server IP address and a Netty server port number connected to the terminal device 40.
S120, the terminal equipment responds to the communication connection triggering event, 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.
In a specific embodiment, after the communication connection channel between the target Netty server and the terminal device 40 is created, a communication connection trigger event is generated in the terminal device 40, and the terminal device 40 directly sends a login authentication request to the load balancing component 20 in response to the communication connection trigger event, so as to authenticate the communication connection channel between the target Netty server and the terminal device 40, where the login authentication request carries the identity information of the terminal device 40.
S130, the target Netty server transmits the login authentication request to the service for verification in an RPC calling mode, and receives a first verification result of the login authentication request fed back by the service.
Specifically, the service 50 shown in fig. 2 may be a terminal device management platform that performs data transmission with each terminal device 40.
In a preferred embodiment, the first verification result further comprises a verification failure, wherein the business service 50 may determine the first verification result by:
according to the identity information of the terminal device 40, whether the registration information of the terminal device 40 exists is judged, if the registration information of the terminal device 40 exists, the first verification result is verification success, and if the registration information of the terminal device 40 does not exist, the first verification result is verification failure.
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 service 50 has registration information of the terminal device 40, after each terminal device 40 completes registration on the service 50, corresponding registration information is generated and identity information corresponding to the terminal device 40, such as a terminal device identifier, is added, and at this time, a user may lock the corresponding registration information through the terminal device identifier.
In a specific embodiment, the terminal device 40 needs to complete the registration of the terminal device information in the service 50, and only the terminal device 40 that completes the registration in the service 50 can perform the subsequent data transmission through the corresponding communication connection channel.
And S140, the target Netty server judges the first verification result, and if the first verification result is verification success, the current terminal connection information is sent to the cache middleware to complete updating of the terminal connection information corresponding to the terminal equipment.
In a preferred embodiment, the cache middleware 30 is configured to record terminal connection information of a communication connection channel established by each Netty server, the cache middleware 30 is provided with a pair of external interfaces, each Netty server 10 may be connected to the external interface provided by the cache middleware 30 in a tcp connection manner to perform data caching and interaction with the cache middleware 30, and each Netty server has the same function and shares the cache middleware 30.
In a specific embodiment, in the cache middleware 30, the terminal connection information may be recorded in a key-value pair form by using a fixed prefix plus a terminal device identifier or a terminal device number as a key and using a JSON form of the terminal connection information as a value, and the terminal connection information corresponding to the same Netty server is stored in the same data group, and a corresponding Netty server identifier is added.
The current terminal connection information also includes a current connection object of the terminal device, and the current connection object is the Netty server connected to the terminal device.
In a specific embodiment, the terminal device 40 can only establish a communication connection channel with one Netty server 10 all the time, and therefore, the cache middleware 30 needs to update the terminal connection information corresponding to the communication connection channel, and only the communication connection channel corresponding to the terminal connection information stored in 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 by:
judging whether historical terminal connection information corresponding to the terminal equipment exists or not according to the terminal equipment identification, if the historical terminal connection information corresponding to the terminal equipment does not exist, storing the current terminal connection information to finish updating the terminal connection information corresponding to the terminal equipment, if the historical terminal connection information corresponding to the terminal equipment exists, judging whether a current connection object corresponding to the terminal equipment is the same as a historical connection object of the terminal equipment indicated by the historical terminal connection information, and if the current connection object corresponding to the terminal equipment is not the same as the historical connection object, replacing the historical terminal connection information with the current connection terminal connection information to finish updating the terminal connection information corresponding to the terminal equipment.
If the current connection object corresponding to the terminal equipment is the same as the historical connection object, judging whether other information except the connection object in the current terminal connection information is consistent with the historical terminal connection information, if any one of the other information except the connection object is inconsistent, replacing the historical terminal connection information with the current terminal connection information to finish updating the terminal connection information corresponding to the terminal equipment, and if all the other information except the connection object is consistent, not further processing the current terminal connection information.
As shown in fig. 2, the Netty server cluster further comprises message middleware 60, and the Netty servers 10 are all commonly connected to the same message middleware 60 through external interfaces provided by the message middleware 60.
After the communication connection channel between each terminal device and the Netty server cluster is established, the method further comprises the following steps:
the business service 50 generates a message instruction for the target terminal device, issues the message instruction to the message middleware 60 for broadcasting, and each Netty server 10 subscribes the message instruction from the message middleware 60; and for each Netty server 10, judging whether the Netty server 10 has a communication connection channel corresponding to the terminal equipment identifier, and if the Netty server 10 has the communication connection channel corresponding to the terminal equipment identifier, issuing a control instruction to the target terminal equipment through the corresponding communication connection channel.
In a preferred embodiment, the message instruction carries the terminal device identifier and the control instruction, and when the service 50 needs to issue the control instruction to a specific terminal device, it only needs to issue the message instruction to the message middleware 60 for broadcasting.
The service 50 issues a message instruction to the message middleware 60, and for each netty server 10, after subscribing to receive the message instruction, determines whether the target terminal device 40 indicated by the message instruction establishes a connection with itself, that is, whether a communication connection channel for connecting the target terminal device with itself exists, if the target terminal device 40 establishes a connection with itself, the control instruction is issued to the target terminal device through the corresponding communication connection channel, and if the target terminal device 40 does not establish a connection with itself, the broadcast message is ignored.
In a preferred embodiment, each Netty server determines whether a communication connection channel corresponding to the terminal device identifier exists or not by the following method:
and extracting terminal connection information corresponding to the terminal equipment identifier from the cache middleware according to the terminal equipment identifier, if the terminal connection information corresponding to the terminal equipment identifier can be extracted from the cache middleware, determining that the Netty server has a communication connection channel corresponding to the terminal equipment identifier, and if the terminal connection information corresponding to the terminal equipment identifier cannot be extracted from the cache middleware, determining that the Netty server does not have a communication connection channel corresponding to the terminal equipment identifier.
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 corresponding data from the cache middleware according to the Netty server corresponding to the Netty server, and determine whether the communication connection channel corresponding to the terminal device identifier exists in the data.
In another preferred embodiment, the service may also communicate with the terminal device by:
the service 50 generates a message instruction for the target terminal device, and sends the message instruction to the cache middleware, the cache middleware judges whether a communication connection channel corresponding to the terminal device identifier exists, if the communication connection channel corresponding to the terminal device identifier exists, the cache middleware sends the control instruction to a target Netty server indicated by the communication connection channel, and the target Netty server sends the control instruction to the target terminal device through the communication connection channel.
Specifically, after the service generates the corresponding message instruction, the service may issue the message instruction to the message middleware for broadcasting, or may directly send the message instruction to the cache middleware, and the cache middleware forwards the message instruction to the specific target Netty server, where one of the two ways is selected.
In another preferred embodiment, the method further comprises:
the method comprises the steps that a terminal device generates a service request, the service request is sent to a target Netty server connected with the terminal device through a corresponding communication connection channel, the target Netty server sends the service request to a service in an RPC calling mode, the target service verifies service verification information and generates a second verification result, the second verification result is fed back to the target Netty server in the RPC calling mode, the service judges the second verification result, if the second verification result is successful, a service response corresponding to the service request is generated and sent to a message middleware for broadcasting, and a terminal device identification corresponding to the terminal device is carried in the service response.
Specifically, the service request carries service verification information, and when the terminal device issues a service request for a target service to the service, the service request needs to be verified first, that is, whether the service request meets a preset condition for starting the target service is verified, for example, if the target service is a service for paying by using a member card, the service request carries a member card number, and the service verifies whether the member card number is registered in advance, if the member card number is registered in advance, the verification is successful, and if the member card number is not registered, the verification fails.
Only if the second verification result is that the verification is successful, the service will be based on the service response corresponding to the terminal device, that is, the service response is sent to the terminal device by any of the above embodiments, so that the terminal device performs subsequent operations.
And if the second verification result is verification failure, ignoring the service request.
Based on the same application concept, please refer to fig. 3, fig. 3 shows a schematic structural diagram of an electronic device according to an embodiment of the present application, where 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, when the electronic device 200 is operated, the processor 210 communicates with the memory 220 via the bus 230, and the machine-readable instructions are executed by the processor 210 to perform the steps of the communication method according to any of the above embodiments.
Based on the same application concept, embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and the computer program is executed by a processor to perform the steps of the communication method provided in the foregoing embodiments.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solutions of the present application, which are essential or part of the technical solutions contributing to the prior art, may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-ONly Memory (ROM), a RaNdom Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A communication method based on a Netty server cluster is characterized in that the Netty server cluster comprises a plurality of Netty servers, a load balancing component and a cache middleware,
the method comprises the following steps:
the load balancing component forwards the received communication request sent by the terminal equipment to the target Netty server according to a preset load balancing strategy;
the target Netty server establishes a communication connection channel with the terminal equipment and generates corresponding current terminal connection information;
the terminal equipment responds to a communication connection triggering event, sends a login authentication request to a load balancing component, and the load balancing component forwards the login authentication request to a target Netty server through the communication connection channel;
the target Netty server transmits the login authentication request to a service for verification in an RPC calling mode, and receives a first verification result of the login authentication request fed back by the service;
and the target Netty server judges the first verification result, and if the first verification result is verification success, the current terminal connection information is sent to a cache middleware to finish updating of the terminal connection information corresponding to the terminal equipment.
2. The method of claim 1, wherein the login authentication request carries identity information of a terminal device, wherein the first verification result further comprises a verification failure,
wherein the business service determines the first verification result by:
judging whether registration information of the terminal equipment exists or not according to the identity information of the terminal equipment;
if the registration information of the terminal equipment exists, the first verification result is verification success;
and if the registration information of the terminal equipment does not exist, the first verification result is verification failure.
3. The method according to claim 1, wherein the current terminal connection information comprises a current connection object of a terminal device and a terminal device identification,
the cache middleware completes the update of the terminal connection information corresponding to the terminal equipment in the following way:
judging whether historical terminal connection information corresponding to the terminal equipment exists or not according to the terminal equipment identification;
if the historical terminal connection information corresponding to the terminal equipment does not exist, the current terminal connection information is stored so as to finish updating the terminal connection information corresponding to the terminal equipment;
if the historical terminal connection information corresponding to the terminal equipment exists, judging whether a current connection object corresponding to the terminal equipment is the same as a historical connection object of the terminal equipment indicated by the historical terminal connection information;
and if the current connection object corresponding to the terminal equipment is different from the historical connection object, replacing the historical terminal connection information with the current connection terminal connection information so as to finish updating the terminal connection information corresponding to the terminal equipment.
4. The method of claim 1, wherein the Netty server cluster further comprises message middleware,
wherein the method further comprises:
the business service generates a message instruction aiming at the target terminal equipment, and issues the message instruction to the message middleware for broadcasting, wherein the message instruction carries a terminal equipment identifier and a control instruction;
each Netty server subscribes the message instruction from the message middleware;
judging whether a communication connection channel corresponding to the terminal equipment identifier exists in each Netty server;
and for each Netty server, if the Netty server has a communication connection channel corresponding to the terminal equipment identifier, the control instruction is issued to the target terminal equipment through the corresponding communication connection channel.
5. The method of claim 4, wherein each Netty server determines whether a communication connection channel corresponding to the terminal device identifier exists by:
extracting terminal connection information corresponding to the terminal equipment identification from the cache middleware according to the terminal equipment identification;
if the terminal connection information corresponding to the terminal equipment identifier can be extracted from the cache middleware, determining that a communication connection channel corresponding to the terminal equipment identifier exists in the Netty server;
and if the terminal connection information corresponding to the terminal equipment identifier cannot be extracted from the cache middleware, determining that the Netty server does not have a communication connection channel corresponding to the terminal equipment identifier.
6. The method of claim 1, further comprising:
the business service generates a message instruction aiming at the terminal equipment and sends the message instruction to the cache middleware, wherein the message instruction carries a terminal equipment identifier and a control instruction;
the cache middleware judges whether a communication connection channel corresponding to the terminal equipment identifier exists or not, and sends the control instruction to a target Netty server indicated by the communication connection channel if the communication connection channel corresponding to the terminal equipment identifier exists;
and the target Netty server transmits the control command to corresponding terminal equipment through the communication connecting channel.
7. The method of claim 1, further comprising:
the terminal equipment generates a service request, and sends the service request to a target Netty server connected with the terminal equipment through a corresponding communication connection channel, wherein the service request carries service verification information;
the target Netty server sends the service request to a service in an RPC calling mode;
the service verifies the service verification information, generates a second verification result, and feeds the second verification result back to the target Netty server in an RPC calling mode;
and the business service judges a second verification result, if the second verification result is successful, a business response corresponding to the business request is generated and sent to the message middleware for broadcasting, and the business response carries the terminal equipment identifier corresponding to the terminal equipment.
8. A Netty server-based cluster, the Netty server cluster comprising a plurality of Netty servers, a load balancing component, caching middleware and a plurality of business services,
the load balancing component forwards the received communication request sent by the terminal equipment to the target Netty server according to a preset load balancing strategy;
the target Netty server establishes a communication connection channel with the terminal equipment and generates corresponding current terminal connection information;
the terminal equipment responds to a communication connection triggering event, sends a login authentication request to a load balancing component, and the load balancing component forwards the login authentication request to a target Netty server through the communication connection channel;
the target Netty server transmits the login authentication request to a service for verification in an RPC calling mode, and receives a first verification result of the login authentication request fed back by the service;
and 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 a cache middleware to complete the updating of the terminal connection information corresponding to the terminal equipment.
9. An electronic device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating over the bus when the electronic device is operating, the machine-readable instructions being executable by the processor to perform the steps of the communication method according to any one of claims 1 to 7.
10. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the communication method according to one of claims 1 to 7.
CN202211141341.1A 2022-09-20 2022-09-20 Communication method based on Netty server cluster Pending CN115529314A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211141341.1A CN115529314A (en) 2022-09-20 2022-09-20 Communication method based on Netty server cluster

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211141341.1A CN115529314A (en) 2022-09-20 2022-09-20 Communication method based on Netty server cluster

Publications (1)

Publication Number Publication Date
CN115529314A true CN115529314A (en) 2022-12-27

Family

ID=84698541

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211141341.1A Pending CN115529314A (en) 2022-09-20 2022-09-20 Communication method based on Netty server cluster

Country Status (1)

Country Link
CN (1) CN115529314A (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107222460A (en) * 2017-05-03 2017-09-29 飞天诚信科技股份有限公司 A kind of shared method and device of server data memory space
US20170295175A1 (en) * 2015-04-17 2017-10-12 Tencent Technology (Shenzhen) Company Limited Authentication method and device
CN108650262A (en) * 2018-05-09 2018-10-12 聚龙股份有限公司 A kind of cloud platform extended method and system based on micro services framework
CN109547458A (en) * 2018-12-10 2019-03-29 平安科技(深圳)有限公司 Login validation method, device, computer equipment and storage medium
CN110247917A (en) * 2019-06-20 2019-09-17 北京百度网讯科技有限公司 Method and apparatus for authenticating identity
CN112738021A (en) * 2020-12-02 2021-04-30 海能达通信股份有限公司 Single sign-on method, terminal, application server, authentication server and medium
CN113055367A (en) * 2021-03-08 2021-06-29 浪潮云信息技术股份公司 Method and system for realizing micro-service gateway authentication
CN113783695A (en) * 2021-08-03 2021-12-10 西北大学 Client information authentication method and system of micro-service architecture
CN114024972A (en) * 2021-10-28 2022-02-08 平安科技(深圳)有限公司 Long connection communication method, system, device, equipment and storage medium
CN114915656A (en) * 2021-12-29 2022-08-16 南京四维智联科技有限公司 Internet of vehicles terminal access method, device, storage medium and electronic equipment

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170295175A1 (en) * 2015-04-17 2017-10-12 Tencent Technology (Shenzhen) Company Limited Authentication method and device
CN107222460A (en) * 2017-05-03 2017-09-29 飞天诚信科技股份有限公司 A kind of shared method and device of server data memory space
CN108650262A (en) * 2018-05-09 2018-10-12 聚龙股份有限公司 A kind of cloud platform extended method and system based on micro services framework
CN109547458A (en) * 2018-12-10 2019-03-29 平安科技(深圳)有限公司 Login validation method, device, computer equipment and storage medium
CN110247917A (en) * 2019-06-20 2019-09-17 北京百度网讯科技有限公司 Method and apparatus for authenticating identity
CN112738021A (en) * 2020-12-02 2021-04-30 海能达通信股份有限公司 Single sign-on method, terminal, application server, authentication server and medium
CN113055367A (en) * 2021-03-08 2021-06-29 浪潮云信息技术股份公司 Method and system for realizing micro-service gateway authentication
CN113783695A (en) * 2021-08-03 2021-12-10 西北大学 Client information authentication method and system of micro-service architecture
CN114024972A (en) * 2021-10-28 2022-02-08 平安科技(深圳)有限公司 Long connection communication method, system, device, equipment and storage medium
CN114915656A (en) * 2021-12-29 2022-08-16 南京四维智联科技有限公司 Internet of vehicles terminal access method, device, storage medium and electronic equipment

Similar Documents

Publication Publication Date Title
CN107018119B (en) Identity verification system, method and platform
CN108293181B (en) Processing method for binding communication identifier and terminal
CN105337997B (en) Login method of application client and related equipment
CN108337210B (en) Equipment configuration method, device and system
CN113132402B (en) Single sign-on method and system
CN110365483B (en) Cloud platform authentication method, client, middleware and system
CN102291452A (en) Virtual machine management method, cloud management server and cloud system based on cloud strategy
CN106254319B (en) Light application login control method and device
CN109597643A (en) Using gray scale dissemination method, device, electronic equipment and storage medium
CN110324184B (en) Service capacity expansion and migration method, device, system, equipment and readable storage medium
CN108650098B (en) Method and device for user-defined verification mode
CN113505354B (en) Data processing method, device and storage medium
CN112968963B (en) WebSocket-based method for forced real-time offline of user
CN113190778A (en) Business data pushing method, system, computer equipment and computer storage medium
CN114268462B (en) Asset information changing method, server, client, and storage medium
CN106487557A (en) A kind of service updating method of application, device, server and terminal unit
CN113868602A (en) Application authorization method, distributed cluster system, electronic device and storage medium
US8490155B2 (en) Method and apparatus for detecting downloadable conditional access system host with duplicated secure micro
CN115529314A (en) Communication method based on Netty server cluster
CN113765963A (en) Data processing method, device, equipment and computer readable storage medium
CN116546062A (en) Cloud mobile phone control method and device, cloud server and storage medium
CN106487637B (en) Application message processing system and method and application device
CN113329045A (en) File downloading method and device, computer readable storage medium and computer equipment
CN111541649A (en) Password resetting method, device, server and storage medium
US10819695B2 (en) Electronic device including local identity provider server for single sign on and related methods

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination