CN112769671B - Message processing method, device and system - Google Patents

Message processing method, device and system Download PDF

Info

Publication number
CN112769671B
CN112769671B CN201910998278.5A CN201910998278A CN112769671B CN 112769671 B CN112769671 B CN 112769671B CN 201910998278 A CN201910998278 A CN 201910998278A CN 112769671 B CN112769671 B CN 112769671B
Authority
CN
China
Prior art keywords
message
server
client
request
broadcast
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.)
Active
Application number
CN201910998278.5A
Other languages
Chinese (zh)
Other versions
CN112769671A (en
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 CHJ Automotive Information Technology Co Ltd
Original Assignee
Beijing CHJ Automotive Information 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 CHJ Automotive Information Technology Co Ltd filed Critical Beijing CHJ Automotive Information Technology Co Ltd
Priority to CN201910998278.5A priority Critical patent/CN112769671B/en
Publication of CN112769671A publication Critical patent/CN112769671A/en
Application granted granted Critical
Publication of CN112769671B publication Critical patent/CN112769671B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/21Monitoring or handling of messages
    • H04L51/214Monitoring or handling of messages using selective forwarding
    • 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/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • 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
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1044Group management mechanisms 
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/55Push-based network services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Abstract

The invention provides a message processing method, a device and a system, relates to the technical field of communication, and aims to improve the speed of searching a WebSocket server executing a message pushing task, wherein the method comprises the following steps: the method comprises the steps that a proxy server receives a message pushing request for requesting to push a message to a first client side, and then broadcasts a broadcast message carrying the message pushing request to a server cluster; and when the WebSocket server in the server cluster determines that the connection information of the first client is stored according to the message pushing request carried in the broadcast message, the WebSocket server pushes the WebSocket message corresponding to the message pushing request to the first client. The technical scheme provided by the invention is used for processing the WebSocket message.

Description

Message processing method, device and system
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method, an apparatus, and a system for processing a message.
Background
With the development of the internet, it is difficult for a conventional HyperText Transfer Protocol (HTTP) to meet the increasingly complex requirements of Web page (Web) applications. In recent years, with the advent of hypertext Markup Language (HTML) 5.0, a web port (WebSocket) protocol has been proposed, which can implement full duplex communication between a browser and a server, extend the communication function between the browser and a server, and enable the server to actively push data to a client, and thus has been widely applied to various fields.
Due to the fact that the bearing capacity of a single WebSocket server is limited, when the number of clients is large, the single WebSocket server can hardly support pushing tasks. Therefore, in order to serve more clients, more and more message push systems expand the push capability of the system by deploying a server cluster, wherein the server cluster is composed of a plurality of WebSocket servers, and message transmission can be performed between a client and the server cluster through a proxy server. When the existing message pushing system realizes message pushing, the connection relationship between the client and the server is generally stored through the shared storage system, and when a message pushing task exists, the WebSocket server executing the message pushing task is found by inquiring the connection relationship stored in the shared storage system, and then the server is informed to push the message.
However, in the above manner of searching for the WebSocket server executing the message pushing task through the shared storage system, the searching speed is slow.
Disclosure of Invention
In view of this, the present invention provides a message processing method, device and system, which are used to improve the speed of searching for a WebSocket server executing a message push task.
In order to achieve the above object, in a first aspect, an embodiment of the present invention provides a message processing method applied to a proxy server, including:
receiving a message pushing request for requesting to push a message to a first client;
and broadcasting a broadcast message carrying the message pushing request to a server cluster, wherein the broadcast message is used for indicating a web port WebSocket server in the server cluster to push a WebSocket message corresponding to the message pushing request to the first client when determining that the connection information of the first client is stored according to the message pushing request carried in the broadcast message.
As an optional implementation manner in the embodiment of the present invention, the broadcasting a broadcast message carrying the message push request to a server cluster includes:
and instructing the execution server to notify the message middleware to broadcast the broadcast message carrying the message pushing request to the server cluster.
As an optional implementation manner of the embodiment of the present invention, the message middleware is a Redis information distribution end.
As an optional implementation manner of the embodiment of the present invention, the method further includes:
when a connection request initiated by a second client is received, acquiring a server list from a registration center, wherein the registration center comprises registration information of a WebSocket server in an online state in a server cluster, and the server list is formed according to the registration information;
determining a target server according to the server list;
and forwarding the connection request to a target server to indicate the target server to establish connection with the second client according to the connection request.
As an optional implementation manner of the embodiment of the present invention, the registry is an Eureka registry.
As an optional implementation manner of the embodiment of the present invention, the WebSocket server is a node.
In a second aspect, an embodiment of the present invention provides a message processing method, which is applied to a WebSocket server in a server cluster, and includes:
receiving a broadcast message, wherein the broadcast message carries a message pushing request for requesting to push a message to a first client;
and when the connection information of the first client is determined to be stored according to the message pushing request, pushing the WebSocket message corresponding to the message pushing request to the first client.
As an optional implementation manner of the embodiment of the present invention, the message push request carries identity information of the first client, and when it is determined that connection information of the first client is stored according to the message push request, pushing a WebSocket message corresponding to the message push request to the first client includes:
and when the connection information of the first client is determined to be stored according to the identity information of the first client, pushing the WebSocket information corresponding to the message pushing request to the first client.
As an optional implementation manner of the embodiment of the present invention, the receiving a broadcast message includes:
receiving a broadcast message broadcast by message middleware.
As an optional implementation manner of the embodiment of the present invention, the method further includes:
registering with a registry at startup.
As an optional implementation manner of the embodiment of the present invention, the method further includes:
receiving a connection request forwarded by a proxy server, wherein the connection request is initiated by a second client;
and establishing connection with the second client according to the connection request, and storing the connection information of the second client.
As an optional implementation manner of the embodiment of the present invention, the method further includes:
and when the connection with the second client is disconnected, deleting the connection information of the second client.
As an optional implementation manner of the embodiment of the present invention, the WebSocket server is a node.
In a third aspect, an embodiment of the present invention provides a message processing apparatus, which is applied to a proxy server, and includes:
the receiving module is used for receiving a message pushing request for requesting to push a message to a first client;
and the processing module is used for broadcasting a broadcast message carrying the message pushing request to a server cluster, and the broadcast message is used for indicating a web port WebSocket server in the server cluster to push a WebSocket message corresponding to the message pushing request to the first client when determining that the connection information of the first client is stored according to the message pushing request carried in the broadcast message.
As an optional implementation manner of the embodiment of the present invention, the processing module is specifically configured to:
and instructing the execution server to notify the message middleware to broadcast the broadcast message carrying the message pushing request to the server cluster.
As an optional implementation manner of the embodiment of the present invention, the message middleware is a Redis information distribution end.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes:
the acquisition module is used for acquiring a server list from a registration center when the receiving module receives a connection request initiated by a second client, wherein the registration center comprises registration information of a WebSocket server in an online state in the server cluster, and the server list is formed according to the registration information;
the determining module is used for determining a target server according to the server list;
and the sending module is used for forwarding the connection request to the target server so as to indicate the target server to establish connection with the second client according to the connection request.
As an optional implementation manner of the embodiment of the present invention, the registry is an Eureka registry.
As an optional implementation manner of the embodiment of the present invention, the WebSocket server is a node.
In a fourth aspect, an embodiment of the present invention provides a message processing apparatus, which is applied to a WebSocket server in a server cluster, and includes:
the system comprises a receiving module, a sending module and a receiving module, wherein the receiving module is used for receiving a broadcast message, and the broadcast message carries a message pushing request for requesting to push a message to a first client;
and the pushing module is used for pushing the WebSocket message corresponding to the message pushing request to the first client when the connection information of the first client is determined to be stored according to the message pushing request.
As an optional implementation manner in this embodiment of the present invention, the message push request carries identity information of the first client, and the push module is specifically configured to:
and when the connection information of the first client is determined to be stored according to the identity information of the first client, pushing the WebSocket information corresponding to the message pushing request to the first client.
As an optional implementation manner of the embodiment of the present invention, the receiving module is specifically configured to:
receiving a broadcast message broadcast by message middleware.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes:
and the registration module is used for registering with the registration center when starting.
As an optional implementation manner of the embodiment of the present invention, the receiving module is further configured to: receiving a connection request forwarded by a proxy server, wherein the connection request is initiated by a second client;
the device further comprises: and the connection module is used for establishing connection with the second client according to the connection request and storing the connection information of the second client.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes:
and the deleting module is used for deleting the connection information of the second client when the connection between the second client and the second client is disconnected.
As an optional implementation manner of the embodiment of the present invention, the WebSocket server is a node.
In a fifth aspect, an embodiment of the present invention provides a proxy server, including: a memory for storing a computer program and a processor; the processor is configured to perform the method of the first aspect or any of the embodiments of the first aspect when the computer program is invoked.
In a sixth aspect, an embodiment of the present invention provides a WebSocket server, including: a memory for storing a computer program and a processor; the processor is configured to perform the method of the second aspect or any of the embodiments of the second aspect when the computer program is invoked.
In a seventh aspect, an embodiment of the present invention provides a message processing system, including: the client, the server cluster and the proxy server in the fifth aspect, wherein the server cluster includes a plurality of WebSocket servers in the sixth aspect.
As an optional implementation manner of the embodiment of the present invention, the system further includes: the execution server is used for notifying the message middleware to broadcast the broadcast message carrying the message pushing request to the server cluster according to the indication of the proxy server.
As an optional implementation manner of the embodiment of the present invention, the system further includes: the registry is used for providing a server list for the proxy server, wherein the registry comprises registration information of the WebSocket server in an online state in the server cluster, and the server list is formed according to the registration information.
In an eighth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method described in the first aspect, the second aspect, any implementation manner of the first aspect, or any implementation manner of the second aspect.
According to the message processing method, device and system provided by the embodiment of the invention, when the proxy server receives the message push request for requesting to push the message to the first client, the broadcast message carrying the message push request is broadcasted to the server cluster, so that the WebSocket server in the server cluster pushes the WebSocket message corresponding to the message push request to the first client when determining that the connection information of the first client is stored according to the message push request carried in the broadcast message.
Drawings
Fig. 1 is a schematic structural diagram of a message pushing system according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of a message processing method according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of another message processing method according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a message processing apparatus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of another message processing apparatus according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a proxy server according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a WebSocket server according to an embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a message processing method, a device and a system, which mainly broadcast a broadcast message carrying a message push request to a server cluster when receiving the message push request for requesting to push a message to a first client, so that a WebSocket server in the server cluster pushes a WebSocket message corresponding to the message push request to the first client when determining that connection information of the first client is stored according to the message push request carried in the broadcast message, thereby improving the speed of searching for the WebSocket server executing the message push task.
The technical solution of the present invention will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
Fig. 1 is a schematic structural diagram of a message pushing system according to an embodiment of the present invention, and as shown in fig. 1, the message pushing system according to the embodiment may include: a client 100, a proxy server 200 and a server cluster 300, wherein the server cluster 300 may include a plurality of WebSocket servers 301.
In this embodiment, the client 100 may be an electronic device with display, operation and network access functions, for example, a mobile device such as a mobile phone, a tablet computer, a notebook computer or an intelligent wearable device, or a fixed device such as a desktop computer or a television with a network access function. The number of the clients 100 may be multiple, and a user may establish a connection with the WebSocket server 301 in the server cluster 300 through a browser on the client 100. It should be noted that, the connections between the client 100 and the WebSocket server 301 in the embodiment of the present invention are all connections based on the WebSocket protocol.
The WebSocket server 301 in the server cluster 300 may specifically be a server developed based on blocking input/output, such as a Tomcat server; to improve the system load-bearing capacity, the WebSocket server 301 may also be a server developed based on non-blocking input/output, such as: a Netty server and a node.js server, wherein the node.js server is lightweight and efficient, and the server construction method is simple, and therefore, the node.js server is preferably used in this embodiment.
The proxy server 200 is configured to perform message transfer between the client 100 and the server cluster 300, and may receive a message sent by the client 100 to the server cluster 300, and forward the message to the corresponding WebSocket server 301; or may receive a message sent by the WebSocket server 301 to the client 100, and forward the message to the corresponding client 100. The proxy server 200 may be specifically Nginx, or a server such as Apache or F5 that is responsible for balancing may be used, where the configuration of the Nginx is simple, the performance is high, and the cost is low, so that the proxy server 200 in this embodiment preferably uses the Nginx.
In this embodiment, when receiving a message push request for requesting to push a message to a certain client 100 (referred to as a first client 100 herein), the proxy server 200 may broadcast the message push request to the server cluster 300 in a broadcast manner, and after receiving the broadcast message push request, the WebSocket server 301 in the server cluster 300 may query whether the WebSocket server itself stores the connection information of the first client 100, and if so, push the WebSocket message corresponding to the message push request to the first client 100 (for a specific description, refer to a subsequent method embodiment). Compared with the mode of inquiring the WebSocket server 301 executing the message pushing request (namely the message pushing task) in the record containing all the client-side 100 connections, the searching speed can be effectively increased, and the record containing all the client-side 100 connections does not need to be established.
In broadcasting the message push request, in this embodiment, the proxy server 200 may specifically send the message push request to the execution server 400, and instruct the execution server 400 to notify the message middleware 500 to broadcast the message push request to the server cluster 300. That is, in this embodiment, the message pushing system may further include: the execution server 400 and the message middleware 500.
The execution server 400 is used to execute the operation of the access message middleware 500 allocated by the proxy server 200, and may be a server developed based on blocking input/output, such as a Tomcat server, which has a low development cost and may reduce the system cost as the execution server 400; the execution server 400 may be another server having a function of accessing the message middleware 500, and this embodiment is not particularly limited thereto.
The message middleware 500 may implement broadcasting of a message, which may specifically be a Redis information publishing end, and may also be an information publishing end such as Kafka or rabitmq, where the processing speed of the Redis information publishing end is fast, and the speed of searching for the WebSocket server 301 executing the message push task may be increased by using the Redis information publishing end as the message middleware 500. WebSocket server 301 in server cluster 300 may subscribe to message middleware 500 and receive messages broadcast by message middleware 500.
In order to facilitate the proxy server 200 to distribute the connection request, in this embodiment, the message pushing system may further include: a registry 600. When the WebSocket server 301 in the server cluster 300 starts, it may register with the registry 600; the registry 600 may determine the online WebSocket server 301 list according to the registration information of the WebSocket server 301 started (i.e., in an online state) in the server cluster 300. When a new client 100 (referred to as a second client 100) initiates a connection request, the proxy server 200 may obtain a list of servers available for invocation from the registry 600, determine a server (referred to as a target server herein) from the list of servers, assign the connection request to the target server, and enable the target server to establish a connection with the second client 100.
The registry 600 may be a registry 600 implemented based on the Eureka framework, that is, the registry 600 may be the Eureka registry 600, or a service registry 600 such as ZooKeeper. Among them, the Eureka preferentially guarantees availability at the time of design, and the availability of the registration service can be guaranteed using the Eureka registry 600.
In the message pushing system provided in this embodiment, when receiving a message pushing request for requesting to push a message to a first client, a proxy server broadcasts a broadcast message carrying the message pushing request to a server cluster, so that a WebSocket server in the server cluster pushes the WebSocket message corresponding to the message pushing request to the first client when determining that connection information of the first client is stored according to the message pushing request carried in the broadcast message, which can effectively improve a search speed compared with a manner of querying a WebSocket server executing a message pushing task in a record including connections of all clients.
Fig. 2 is a schematic flowchart of a message processing method according to an embodiment of the present invention, and as shown in fig. 2, the method according to the embodiment may include the following steps:
s110, the proxy server receives a message pushing request for requesting to push a message to the first client.
Specifically, the client may send a message push request to the server cluster to request the server cluster to push the WebSocket message to other clients (referred to herein as the first client). The proxy server is used as a bridge for connecting the client and the server cluster, receives the message pushing request at the moment, and finds out the corresponding WebSocket server to execute the message pushing request.
The message push request may include identity information of the first client, where the identity information may be stored in a Cookie (data stored on a local terminal of the user), and a user of the client may manually edit an input number or an account as the identity information of the client.
In addition, the message pushing request can also include a message type of the WebSocket message requested to be pushed or a specific WebSocket message, so as to meet the diversified requirements of the WebSocket message requested to be pushed.
S120, the proxy server broadcasts the broadcast message carrying the message pushing request to the server cluster.
Specifically, after receiving the message pushing request, the proxy server may carry the message pushing request in a broadcast message and broadcast the message pushing request to the server cluster, so that the WebSocket server in the server cluster determines whether the WebSocket server stores the connection information of the first client according to the message pushing request carried in the broadcast message, if so, pushes the WebSocket message corresponding to the message pushing request to the first client, and otherwise, ignores the message pushing request.
In a specific implementation, in order to reduce the development cost, in this embodiment, the broadcast message may be broadcast through a message middleware, for example, redis, that is, the proxy server may instruct the message middleware to broadcast the broadcast message. In view of that it is difficult for most of the existing proxy servers to directly access the message middleware, in order to further reduce development cost and improve convenience of accessing the message middleware, in this embodiment, the proxy server may access the message middleware through the execution server, that is, the proxy server may instruct the execution server to notify the message middleware to broadcast the broadcast message carrying the message push request to the server cluster.
In specific implementation, the proxy server may send an indication message to the execution server, where the indication message may carry the message push request; after receiving the indication message, the execution server can carry the message pushing request in the broadcast request message and send the message pushing request to the message middleware; after receiving the broadcast request message, the message middleware can carry the message push request in the broadcast message and broadcast the broadcast message to the server cluster.
S130, the WebSocket server receives the broadcast message.
Specifically, the WebSocket server in the server cluster subscribes to the message middleware, and after the message middleware issues the broadcast message, the WebSocket server in the server cluster can receive the broadcast message.
S140, when determining that the connection information of the first client is stored according to the message pushing request carried in the broadcast message, the WebSocket server pushes the WebSocket message corresponding to the message pushing request to the first client.
Specifically, the WebSocket server in the server cluster stores connection information of the client connected with the WebSocket server; after receiving the broadcast message, the WebSocket server can check whether the WebSocket server stores the connection information of the first client according to the identity information of the first client in the message push request; if so, indicating that the first client is the WebSocket server which needs to execute the message pushing task, pushing a WebSocket message corresponding to the message pushing request to the first client; if not, the message pushing request can be ignored if the message pushing request is not the WebSocket server which needs to execute the message pushing task.
When the connection information is specifically stored, the identity information of the client may be used as a key (key), and a channel connected to the client may be stored as a value (value). When checking whether the connection information of the first client is stored in the server, inquiring whether a key in a key-value key value pair is the identity information of the first client, if so, indicating that the server is a server for establishing connection with the first client, and pushing a WebSocket message to the first client through a channel stored in the corresponding value; if not, the connection between the first client and the second client is not established, and the message pushing request is ignored at the moment.
In addition, when the WebSocket message is specifically pushed, if the message pushing request includes a message type of the WebSocket message requested to be pushed, the WebSocket server can push the WebSocket message corresponding to the message type to the first client; if the message pushing request comprises a specific WebSocket message, the WebSocket server can directly push the WebSocket message to the first client; if the message pushing request does not include information related to the WebSocket message, the WebSocket server can push an agreed WebSocket message to the first client.
In the message processing method provided by this embodiment, when receiving a message push request for requesting to push a message to a first client, a proxy server broadcasts a broadcast message carrying the message push request to a server cluster; after receiving the broadcast message, the WebSocket server in the server cluster pushes the WebSocket message corresponding to the message pushing request to the first client when determining that the connection information of the first client is stored according to the message pushing request carried in the broadcast message, so that the searching speed can be effectively increased compared with the mode that the WebSocket server executing the message pushing task is inquired in a record containing all client connections.
Fig. 3 is a flowchart illustrating another message processing method according to an embodiment of the present invention, where the embodiment mainly describes a connection establishment process. On the basis of the foregoing embodiment, as shown in fig. 3, the method provided in this embodiment may further include the following steps:
s210, when receiving the connection request initiated by the second client, the proxy server requests a server list from the registration center.
Specifically, when a WebSocket server in the server cluster is started, the WebSocket server can be registered with the registration center; the registration center may determine an online server list according to registration information of a WebSocket server started (i.e., in an online state) in the server cluster.
When receiving a connection request initiated by a new client (referred to as a second client), the proxy server may obtain a list of WebSocket servers available for invocation from the registry, so as to allocate a WebSocket server to the second client.
The connection request may include information such as identity information of the second client, an Internet Protocol (IP) address, and a port number.
S220, the registration center returns a server list to the proxy server.
Specifically, the registration center includes registration information of the WebSocket server in an online state in the server cluster, and the server list can be determined according to the registration information. The registry, upon receiving the request of the proxy server, may return the list of servers to the proxy server.
The registration information may include environment information such as an IP address and a port number of the WebSocket server, and may also include configuration information such as a memory size of the WebSocket server and a core number of a Central Processing Unit (CPU).
In this embodiment, when a WebSocket server in a server cluster is offline, an offline message may be sent to the registration center before offline to notify the registration center, and the registration center may delete the corresponding registration information; or the registration center can also actively detect whether the Websocket server in the server cluster is online at regular time, and delete the corresponding registration information when detecting that the Websocket server is offline.
And S230, after receiving the server list, the proxy server determines a target server according to the server list.
Specifically, after receiving the server list, the proxy server may determine, according to a certain balanced allocation principle, that the target server is allocated to the second client from the server list.
The equalization allocation principle may specifically be a polling principle: and distributing each connection request to different WebSocket servers one by one according to the time sequence, namely distributing the first connection request to the first WebSocket server, distributing the second connection request to the second WebSocket server … …, and distributing the (N + 1) th connection request to the first WebSocket server if N servers exist, and so on.
The balanced distribution principle may specifically be a hash principle: distributing each connection request according to a hash (hash) result of the IP of the client; the balanced allocation principle may specifically be a configuration principle: and distributing some connection requests for the high-configuration WebSocket server. Of course, the principle of the equal distribution may be other principles, and this embodiment is not particularly limited thereto.
S240, the proxy server forwards the connection request to the target server.
Specifically, after the proxy server determines the target server, the proxy server forwards the connection request to the target server.
And S250, the target server establishes connection with the second client according to the connection request and stores the connection information of the second client.
Specifically, after receiving the connection request, the target server may establish a connection with the second client according to information such as an IP address and a port number of the second client in the connection request. After the connection is established, the connection information of the second client may be stored.
And S260, when the connection between the target server and the second client is disconnected, deleting the connection information of the second client.
Specifically, when the WebSocket connection is disconnected due to the browser being closed or the network being in failure in the second client, the target server connected to the second client may receive a disconnection event sent by the second client through the proxy server, and at this time, the target server may delete the connection information of the second client.
In the message processing method provided by this embodiment, when receiving a connection request initiated by a second client, a proxy server obtains a server list available for invocation from a registry; and then, determining a target server according to the server list, and forwarding the connection request to the target server to enable the target server to establish connection with the second client according to the connection request, so that the connection request can be distributed conveniently and uniformly by the proxy server.
Based on the same inventive concept, as an implementation of the foregoing method, an embodiment of the present invention provides a message processing apparatus, where the apparatus embodiment corresponds to the foregoing method embodiment, and for convenience of reading, details in the foregoing method embodiment are not repeated in this apparatus embodiment one by one, but it should be clear that the apparatus in this embodiment can correspondingly implement all the contents in the foregoing method embodiment.
Fig. 4 is a schematic structural diagram of a message processing apparatus according to an embodiment of the present invention, where the apparatus may be integrated in a proxy server, and as shown in fig. 4, the message processing apparatus 110 according to this embodiment may include:
a receiving module 111, configured to receive a message push request for requesting to push a message to a first client;
the processing module 112 is configured to broadcast a broadcast message carrying a message push request to the server cluster, where the broadcast message is used to instruct a WebSocket server at a web port in the server cluster to push a WebSocket message corresponding to the message push request to a first client when determining that connection information of the first client is stored according to the message push request carried in the broadcast message.
As an optional implementation manner of the embodiment of the present invention, the processing module 112 is specifically configured to:
and instructing the execution server to notify the message middleware to broadcast the broadcast message carrying the message push request to the server cluster.
As an optional implementation manner of the embodiment of the present invention, the message middleware is a Redis information publishing end.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes:
an obtaining module 113, configured to obtain a server list from a registration center when the receiving module 111 receives a connection request initiated by a second client, where the registration center includes registration information of a WebSocket server in an online state in a server cluster, and the server list is formed according to the registration information;
a determining module 114, configured to determine a target server according to the server list;
the sending module 115 is configured to forward the connection request to the target server, so as to instruct the target server to establish a connection with the second client according to the connection request.
As an optional implementation of the embodiment of the present invention, the registry is a Eureka registry.
As an optional implementation manner of the embodiment of the present invention, the WebSocket server is a node.
The message processing apparatus provided in this embodiment may execute the above method embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.
Fig. 5 is a schematic structural diagram of another message processing apparatus according to an embodiment of the present invention, where the apparatus may be integrated in a WebSocket server in a server cluster, and as shown in fig. 5, the message processing apparatus 120 according to the embodiment may include:
a receiving module 121, configured to receive a broadcast message, where the broadcast message carries a message push request for requesting to push a message to a first client;
the pushing module 122 is configured to, when it is determined that the connection information of the first client is stored according to the message pushing request, push a WebSocket message corresponding to the message pushing request to the first client.
As an optional implementation manner of the embodiment of the present invention, the message push request carries identity information of the first client, and the push module 122 is specifically configured to:
and when the connection information of the first client is determined to be stored according to the identity information of the first client, pushing the WebSocket information corresponding to the message pushing request to the first client.
As an optional implementation manner of the embodiment of the present invention, the receiving module 121 is specifically configured to:
receiving a broadcast message broadcast by message middleware.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes:
and a registration module 123, configured to register with the registry at startup.
As an optional implementation manner of the embodiment of the present invention, the receiving module 121 is further configured to: receiving a connection request forwarded by the proxy server, wherein the connection request is initiated by a second client;
the device also includes: and the connection module 124 is configured to establish a connection with the second client according to the connection request, and store connection information of the second client.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes:
and a deleting module 125, configured to delete the connection information of the second client when the connection with the second client is disconnected.
As an optional implementation manner of the embodiment of the present invention, the WebSocket server is a node.
The message processing apparatus provided in this embodiment may execute the above method embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.
Based on the same inventive concept, the embodiment of the invention also provides a proxy server. Fig. 6 is a schematic structural diagram of a proxy server according to an embodiment of the present invention, and as shown in fig. 6, the proxy server according to the embodiment includes: a memory 211 and a processor 212, the memory 211 being for storing computer programs; the processor 212 is adapted to perform the method according to the above-described method embodiment when the computer program is invoked.
The proxy server provided in this embodiment may execute the above method embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.
Based on the same inventive concept, the embodiment of the invention also provides a WebSocket server. Fig. 7 is a schematic structural diagram of a WebSocket server provided in the embodiment of the present invention, and as shown in fig. 7, the WebSocket server provided in this embodiment includes: a memory 221 and a processor 222, the memory 221 being for storing computer programs; the processor 222 is adapted to perform the method according to the above-described method embodiment when the computer program is called.
The WebSocket server provided in this embodiment may execute the method embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.
Embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method described in the above method embodiments.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media having computer-usable program code embodied in the medium.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer readable media includes both permanent and non-permanent, removable and non-removable storage media. Storage media may implement information storage by any method or technology, and the information may be computer-readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and these modifications or substitutions do not depart from the spirit of the corresponding technical solutions of the embodiments of the present invention.

Claims (19)

1. A message processing method applied to a proxy server is characterized by comprising the following steps:
receiving a message pushing request for pushing a message to a first client;
broadcasting a broadcast message carrying the message push request to a server cluster, wherein the broadcast message is used for indicating a web port full-duplex communication server in the server cluster to push a full-duplex communication message corresponding to the message push request to a first client when determining that connection information of the first client is stored according to the message push request carried in the broadcast message;
the broadcasting the broadcast message carrying the message pushing request to the server cluster includes:
and instructing the execution server to notify the message middleware to broadcast the broadcast message carrying the message pushing request to the server cluster.
2. The method of claim 1, wherein the message middleware is a remote dictionary service information publisher.
3. The method of claim 1, further comprising:
when a connection request initiated by a second client is received, acquiring a server list from a registration center, wherein the registration center comprises registration information of a full-duplex communication server in an online state in the server cluster, and the server list is formed according to the registration information;
determining a target server according to the server list;
and forwarding the connection request to a target server to indicate the target server to establish connection with the second client according to the connection request.
4. The method of claim 3, wherein the registry is a microservice registry.
5. The method of any of claims 1-4, wherein the full duplex communication server is a non-blocking server.
6. A message processing method is applied to a web port full duplex communication server in a server cluster, and is characterized by comprising the following steps:
receiving a broadcast message, wherein the broadcast message carries a message pushing request for pushing a message to a first client;
when the connection information of the first client is determined to be stored according to the message pushing request, pushing a full-duplex communication message corresponding to the message pushing request to the first client;
the receiving a broadcast message includes:
receiving a broadcast message broadcast by message middleware.
7. The method according to claim 6, wherein the message push request carries identity information of the first client, and when it is determined that connection information of the first client is stored according to the message push request, pushing a full-duplex communication message corresponding to the message push request to the first client comprises:
and when the connection information of the first client is determined to be stored according to the identity information of the first client, pushing the full-duplex communication message corresponding to the message pushing request to the first client.
8. The method of claim 6, further comprising:
registering with a registry at startup.
9. The method of claim 6, further comprising:
receiving a connection request forwarded by a proxy server, wherein the connection request is initiated by a second client;
and establishing connection with the second client according to the connection request, and storing the connection information of the second client.
10. The method of claim 9, further comprising:
and when the connection with the second client is disconnected, deleting the connection information of the second client.
11. The method according to any of claims 6-10, wherein the full duplex communication server is a non-blocking server.
12. A message processing apparatus applied to a proxy server, comprising:
the system comprises a receiving module, a sending module and a sending module, wherein the receiving module is used for receiving a message pushing request for pushing a message to a first client;
a processing module, configured to broadcast a broadcast message carrying the message push request to a server cluster, where the broadcast message is used to instruct a web port full-duplex communication server in the server cluster to push a full-duplex communication message corresponding to the message push request to a first client when determining that connection information of the first client is stored according to the message push request carried in the broadcast message;
the processing module is specifically configured to:
and instructing the execution server to notify the message middleware to broadcast the broadcast message carrying the message push request to the server cluster.
13. A message processing device applied to a web port full duplex communication server in a server cluster is characterized by comprising:
the system comprises a receiving module, a sending module and a receiving module, wherein the receiving module is used for receiving a broadcast message, and the broadcast message carries a message pushing request for pushing a message to a first client;
the pushing module is used for pushing a full-duplex communication message corresponding to the message pushing request to the first client when the connection information of the first client is determined to be stored according to the message pushing request;
the receiving module is specifically configured to:
receiving a broadcast message broadcast by message middleware.
14. A proxy server, comprising: a memory for storing a computer program and a processor; the processor is adapted to perform the method of any of claims 1-5 when the computer program is invoked.
15. A web portal full duplex communication server, comprising: a memory for storing a computer program and a processor; the processor is adapted to perform the method of any of claims 6-11 when invoking the computer program.
16. A message processing system, comprising: client, server cluster and proxy server according to claim 14, wherein a plurality of netpage port full-duplex communication servers according to claim 15 are comprised in the server cluster.
17. The system of claim 16, further comprising: the execution server is used for notifying the message middleware to broadcast the broadcast message carrying the message pushing request to the server cluster according to the indication of the proxy server.
18. The system according to claim 16 or 17, characterized in that it further comprises: the registry is used for providing a server list for the proxy server, wherein the registry comprises the registration information of the full-duplex communication servers in an online state in the server cluster, and the server list is formed according to the registration information.
19. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-11.
CN201910998278.5A 2019-10-21 2019-10-21 Message processing method, device and system Active CN112769671B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910998278.5A CN112769671B (en) 2019-10-21 2019-10-21 Message processing method, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910998278.5A CN112769671B (en) 2019-10-21 2019-10-21 Message processing method, device and system

Publications (2)

Publication Number Publication Date
CN112769671A CN112769671A (en) 2021-05-07
CN112769671B true CN112769671B (en) 2023-04-18

Family

ID=75691648

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910998278.5A Active CN112769671B (en) 2019-10-21 2019-10-21 Message processing method, device and system

Country Status (1)

Country Link
CN (1) CN112769671B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113452774B (en) * 2021-06-25 2022-07-12 睿视(苏州)视频科技有限公司 Message pushing method, device, equipment and storage medium
CN115086292A (en) * 2022-06-15 2022-09-20 浙江省标准化研究院(金砖国家标准化(浙江)研究中心、浙江省物品编码中心) Distributed instant server push scheme architecture design method, device and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6134531A (en) * 1997-09-24 2000-10-17 Digital Equipment Corporation Method and apparatus for correlating real-time audience feedback with segments of broadcast programs
CN101753712A (en) * 2008-11-28 2010-06-23 Lg电子株式会社 Mobile terminal and method of purchasing broadcast product therein
CN106131702A (en) * 2016-07-29 2016-11-16 上海幻电信息科技有限公司 Barrage supplying system and method

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7444137B1 (en) * 2005-11-01 2008-10-28 At&T Mobility Ii Llc Cell broadcast via encoded message to an embedded client
US20120117594A1 (en) * 2010-11-05 2012-05-10 Net & Tv, Inc. Method and apparatus for providing converged social broadcasting service
WO2016163772A2 (en) * 2015-04-07 2016-10-13 엘지전자 주식회사 Broadcast signal transmission apparatus, broadcast signal reception apparatus, broadcast signal transmission method, and broadcast signal reception method
CN108390881B (en) * 2018-02-27 2021-06-15 北京焦点新干线信息技术有限公司 Distributed high-concurrency real-time message pushing method and system
CN108377247B (en) * 2018-03-08 2021-02-26 北京车和家信息技术有限公司 Message pushing method and device
CN108683653B (en) * 2018-05-07 2021-12-10 常熟市第一人民医院 Active message pushing system based on WebSocket
CN109636165B (en) * 2018-12-04 2022-12-13 浙江诺诺网络科技有限公司 Decentralized online customer service queuing scheduling method
CN109600452B (en) * 2018-12-29 2021-10-12 北京车和家信息技术有限公司 Server cluster, message pushing method and related server

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6134531A (en) * 1997-09-24 2000-10-17 Digital Equipment Corporation Method and apparatus for correlating real-time audience feedback with segments of broadcast programs
CN101753712A (en) * 2008-11-28 2010-06-23 Lg电子株式会社 Mobile terminal and method of purchasing broadcast product therein
CN106131702A (en) * 2016-07-29 2016-11-16 上海幻电信息科技有限公司 Barrage supplying system and method

Also Published As

Publication number Publication date
CN112769671A (en) 2021-05-07

Similar Documents

Publication Publication Date Title
US20180309845A1 (en) Method and system of dispatching requests in a content delivery network
US20200099606A1 (en) Distrubuted testing service
EP1021021B1 (en) Method and apparatus for providing awareness-triggered push
US8935377B2 (en) Dynamic registration of listener resources for cloud services
CN112261094B (en) Message processing method and proxy server
CN111786998A (en) Authority management method and device based on micro-service calling and storage medium
CN112769671B (en) Message processing method, device and system
CN113434249A (en) Mirror image synchronization method and device, docker host and storage medium
CN114036031B (en) Scheduling system and method for resource service application in enterprise digital middleboxes
US8725856B2 (en) Discovery of network services
CN110427266B (en) Data redundancy architecture based on MQTT service
US20210250408A1 (en) Server node selection method and terminal device
CN109547508B (en) Method, device and system for realizing resource access
CN111131470B (en) Terminal device, data processing method thereof and data processing system
CN111262779A (en) Method, device, server and system for acquiring data in instant messaging
CN108810070B (en) Resource sharing method and device, intelligent equipment and storage medium
CN106899652B (en) Method and device for pushing service processing result
CN113285920B (en) Service access method, device, equipment and storage medium
CN112131263B (en) Software package acquisition method, system, device, electronic equipment and storage medium
CN112202914B (en) Message pushing method and device
CN109600452B (en) Server cluster, message pushing method and related server
CN110661895A (en) Network address mapping method and network address mapping equipment of server
CN107835225B (en) Method, device and equipment for acquiring data information
CN115221443B (en) Information transmission method, device, system, electronic equipment and storage medium
CN114979284B (en) 5G message scheduling method, device and system

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
GR01 Patent grant
GR01 Patent grant