CN114979240A - Distributed WebSocket access system and method - Google Patents

Distributed WebSocket access system and method Download PDF

Info

Publication number
CN114979240A
CN114979240A CN202210884320.2A CN202210884320A CN114979240A CN 114979240 A CN114979240 A CN 114979240A CN 202210884320 A CN202210884320 A CN 202210884320A CN 114979240 A CN114979240 A CN 114979240A
Authority
CN
China
Prior art keywords
message
client
websocket
server
access device
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.)
Granted
Application number
CN202210884320.2A
Other languages
Chinese (zh)
Other versions
CN114979240B (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.)
Hangzhou Wonderful Miaoxing Network Technology Co ltd
Original Assignee
Hangzhou Wonderful Miaoxing Network 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 Hangzhou Wonderful Miaoxing Network Technology Co ltd filed Critical Hangzhou Wonderful Miaoxing Network Technology Co ltd
Priority to CN202210884320.2A priority Critical patent/CN114979240B/en
Publication of CN114979240A publication Critical patent/CN114979240A/en
Application granted granted Critical
Publication of CN114979240B publication Critical patent/CN114979240B/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
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • 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
    • 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer And Data Communications (AREA)

Abstract

The application relates to a distributed WebSocket access system, which comprises: the system comprises an agent access device and a message server, wherein the agent access device is used for carrying out two-way communication with the message server and a client respectively, a plurality of agent access devices are distributed in the system, and each agent access device is connected with a plurality of clients; the message server is used for performing two-way communication with the agent access devices and the service server respectively, wherein each agent access device is connected with the message server through a WebSocket connection channel, the WebSocket connection channels are established based on a webSocket Tunnel protocol, and in the webSocket Tunnel protocol, a plurality of client data forwarded by the agent access devices are gathered on one WebSocket connection channel for transmission through a specific packaging structure. By the method and the device, the upper limit of the number of the clients which can be connected by the server is improved under the condition that the hardware configuration of the server is not changed.

Description

Distributed WebSocket access system and method
Technical Field
The present application relates to the field of network communications, and in particular, to a distributed WebSocket access system and method.
Background
WebSocket is a communication protocol that makes data exchange between a client and a server simpler and more efficient, and allows a server to actively push data to the client. Based on the advantages, WebSocket is increasingly applied to real-time communication occasions, for example: message pushing of an APP or a browser, real-time interaction of a WeChat mini game and the like.
In a business scenario, a large number (e.g., 100 ten thousand) of clients are connected to a server; in the related art, for large-scale client connection, the conventional distributed WebSocket access method has the following defects:
1: the server program needs to be as efficient as possible (i.e., the computational power consumption of a single process should be as small as possible), and meanwhile, the network layer of the server operating system needs to be optimized, and after the optimization, a large number of connected servers need to have a large memory (for example, 100 ten thousand of connections and at least 20G of memory space are needed as a support);
2: because the request of the client needs to be processed and forwarded through the load balancing equipment, when the number of the connected clients is large, great operation pressure is caused on the load balancing equipment, and the service life of the load balancing equipment and the overall stability of the system are adversely affected;
3: compared with the traditional HTTP protocol, the development process of the server for the WebSocket protocol is complex, the development difficulty is higher, and more time and labor cost are consumed.
At present, no effective solution is provided for the above problems in the existing WebSocket access system.
Disclosure of Invention
The embodiment of the application provides a distributed WebSocket access method system, a distributed WebSocket access method, computer equipment and a storage medium, and aims to at least solve the problem that the number of connectable clients of a server is limited in a WebSocket communication mode.
In a first aspect, an embodiment of the present application provides a distributed WebSocket access system, where the system includes: the proxy access device and the message server, wherein;
the agent access devices are used for performing two-way communication with the message server and the client respectively, wherein a plurality of agent access devices are distributed in the system and each agent access device is connected with a plurality of clients;
the message server is used for performing two-way communication with the agent access devices and the service server respectively, wherein each agent access device is connected with the message server through a WebSocket connection channel respectively,
the WebSocket connection channel is established based on a WebSocket Tunnel protocol, and in the WebSocket Tunnel protocol, a plurality of client data forwarded by the proxy access device are gathered on one WebSocket connection channel for transmission through a specific packaging structure.
In some embodiments, in the specific encapsulation structure, message data sent by a plurality of clients are aggregated, and a message body structure of the message data is redefined, wherein a message type and a client ID are added to a file header of the message body structure.
In some embodiments, a client list is maintained in the message server, where the client list includes a plurality of sets of client information records, and the client information records include: a client ID, a client address, and a proxy accessor ID that match each other.
In some of these embodiments, where message data is pushed to the client:
the service server is used for sending message data to the message server, wherein the message data comprises a client ID and message content;
the message server is used for searching in the client list according to the client ID, determining the proxy access device ID corresponding to the message data, and,
after the message data is processed by a specific packaging structure of the WebSocket Tunnel protocol, forwarding the message data to a corresponding proxy access device through the WebSocket connection channel according to the proxy access device ID;
and the agent access device is used for judging the processing mode of the message data according to the message type in the message data, determining a corresponding client address according to the client ID, and forwarding the message data to a corresponding client according to the client address.
In some embodiments, the message data transmitted in the WebSocket Tunnel protocol is a WebSocket message, and the message data in the WebSocket Tunnel protocol is in a JSON format.
In some of these embodiments, the message server is further configured to:
converting the message data from WebSocket protocol format to HTTP protocol format after receiving the message data forwarded by the proxy access device,
and forwarding the message data in the HTTP protocol format to the service server.
In some embodiments, the system further includes a custom deployment module, where the custom deployment module is configured to deploy the message server and the proxy access device in a custom manner according to service requirements, and includes:
according to different business items of the business servers, a special message server of each business server is deployed in a targeted manner;
according to resource configuration requirements, the message server is deployed in different machine rooms or cloud platforms;
deploying the agent accessor and configuring the number of the agent accessors according to an operator line, and sharing the agent accessor among a plurality of the message servers.
In a second aspect, an embodiment of the present application provides a distributed WebSocket access method, where the method includes:
the agent access device is respectively in two-way communication with the message server and the client, wherein a plurality of agent access devices are distributed in the system and each agent access device is connected with a plurality of clients;
a message server, which is respectively in two-way communication with the agent access device and the service server, wherein each agent access device is respectively connected with the message server through a WebSocket connection channel, wherein,
the WebSocket connection channel is established based on a WebSocket Tunnel protocol, and in the WebSocket Tunnel protocol, a plurality of client data forwarded by the proxy access device are collected on one WebSocket connection channel for transmission through a specific packaging structure.
In a third aspect, an embodiment of the present application provides a computer device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor, when executing the computer program, implements the method according to the first aspect.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the method according to the first aspect.
Compared with the prior art, the distributed WebSocket access system provided by the embodiment of the application has the following beneficial effects:
1. a plurality of agent access devices are distributed, the characteristic of horizontal extension can be supported, and firstly, more clients can be allowed to be accessed; furthermore, based on a specific websocket Tunnel protocol, data of a plurality of clients can be sent to the message server and then to the service server through a line,
for a service server, communication with a large number of clients can be realized only by processing a small number of connection lines, so that the upper limit of client connection is improved under the condition that the hardware resources of a server are unchanged;
2. because the number of the connecting lines of the server is reduced, the processing capacity of the load balancing equipment is reduced, so that the operation pressure of the load balancing equipment can be reduced, and the service life of the load balancing equipment is prolonged;
3. the message server converts the message data sent by the client into the HTTP protocol from the WebSocket protocol, so that independent development and configuration on the server aiming at the WebSocket protocol are not needed, and the development difficulty, time and labor cost of the server are reduced;
4. the user can flexibly deploy the message server according to the self requirement and by combining the actual service situation, for example: the message server with higher configuration is specially used for the main business, the message server with relatively poorer configuration is specially used for the auxiliary business, or different message servers are deployed in different machine rooms or cloud platforms and the like, so that the load is reasonably distributed, the resource is maximally utilized, and the service stability is improved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
fig. 1 is a schematic diagram of a distributed WebSocket communication manner in the prior art;
fig. 2 is an architecture diagram of a distributed WebSocket access system according to an embodiment of the present application;
fig. 3 is a schematic diagram of an encapsulation structure of a WebSocket Tunnel protocol according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a partial message structure according to an embodiment of the present application;
fig. 5 is a schematic diagram of the operation of a proxy accessor according to an embodiment of the application;
FIG. 6 is a schematic diagram of the operation of a message server according to an embodiment of the present application;
FIG. 7 is a schematic diagram of a client list according to an embodiment of the present application;
fig. 8 is a schematic flowchart of a service end pushing data to a target client according to an embodiment of the present application;
FIG. 9 is a schematic diagram of a custom deployment message server according to an embodiment of the present application;
fig. 10 is an internal structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of and not restrictive on the broad application. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments provided in the present application without any inventive step are within the scope of protection of the present application.
It is obvious that the drawings in the following description are only examples or embodiments of the present application, and that it is also possible for a person skilled in the art to apply the present application to other similar contexts on the basis of these drawings without inventive effort. Moreover, it should be appreciated that in the development of any such actual implementation, as in any engineering or design project, numerous implementation-specific decisions must be made to achieve the developers' specific goals, such as compliance with system-related and business-related constraints, which may vary from one implementation to another.
Reference in the specification to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the specification. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of ordinary skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments without conflict.
Unless defined otherwise, technical or scientific terms referred to herein shall have the ordinary meaning as understood by those of ordinary skill in the art to which this application belongs. Reference to "a," "an," "the," and similar words throughout this application are not to be construed as limiting in number, and may refer to the singular or the plural. The present application is directed to the use of the terms "including," "comprising," "having," and any variations thereof, which are intended to cover non-exclusive inclusions; for example, a process, method, system, article, or apparatus that comprises a list of steps or modules (elements) is not limited to the listed steps or elements, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. Reference to "connected," "coupled," and the like in this application is not intended to be limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The term "plurality" as referred to herein means two or more. "and/or" describes an association relationship of associated objects, meaning that three relationships may exist, for example, "A and/or B" may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. Reference herein to the terms "first," "second," "third," and the like, are merely to distinguish similar objects and do not denote a particular ordering for the objects.
Fig. 1 is a schematic diagram of a distributed WebSocket communication mode in the prior art, and as shown in fig. 1, no matter service deployment is cloud service or IDC (computer room), a 7-layer gateway/load balancing device (which can be implemented by using dedicated hardware devices or software such as nginx, haproxy, etc.) generally exists for uniformly receiving a user request and then sending the request to a corresponding service node.
Under the condition that configurations such as a server memory and the like are fixed, the number of connectable clients is limited due to limited computing power, and meanwhile, a large number of clients can cause great operating pressure on the load balancing device, for example, the load balancing device needs to maintain 200 million WebSocket connections to support 100 million clients.
In view of the above problems, the present inventors propose an improved scheme, and fig. 2 is an architecture diagram of a distributed WebSocket access system according to an embodiment of the present application, and as shown in fig. 2, the system mainly includes: the proxy access device and the message server, wherein;
the system comprises a plurality of Agent access devices (WebSocket Agents), a Message Server (WebSocket Message Server) and a client, wherein the Agent access devices (WebSocket Agents) are respectively in two-way communication with the Message Server (WebSocket Message Server) and the client, a plurality of Agent access devices are distributed in the system, and each Agent access device is connected with a plurality of clients;
the agent access device is responsible for forwarding the message sent by the client to the message server and forwarding the message sent by the message server to the client. Of course, the proxy accessor is also responsible for sending some events of the client (such as status information of client connection, client disconnection, etc.) to the message server, and for connection authentication and heartbeat detection with the client. In the application, the agent access device is only used for maintaining and forwarding data of the client and does not participate in specific business processing, so that the agent access device is low in calculation consumption and can be deployed in an environment with relatively low requirements on selectivity and performance.
In addition, data are transmitted between the proxy access device and the client through a traditional WebSocket protocol, and one proxy access device can be connected with a plurality of clients simultaneously. The proxy accessors are typically deployed on the edge side of the network, and the proxy accessors to which each client is connected should be allocated in close proximity.
Further, in an initial situation, a certain number of proxy access devices may be deployed in the system, and as the service develops, if the number of client access devices needs to be further increased, new proxy access devices may be additionally deployed in the system at any time based on the feature of supporting horizontal extension.
It should be further noted that, in this embodiment, the distributed deployment of the proxy access device may further bring the following beneficial effects:
1. the system can be deployed in a targeted manner for a network where a client is located, for example: the proxy accessor is deployed to the telecommunication network for the telecommunication user and to the connected network for the connected user. Thereby improving the message transmission speed of each client.
2. The deployment may be adjusted for the distribution of the number of customers. For example, more telecommunication subscribers can deploy a plurality of (e.g., 8) agent access devices in the telecommunication network, and less connected subscribers can deploy a fewer (e.g., 1) agent access devices in the connected network.
3. Because each agent access device is only responsible for the connection of a part of clients, when a certain agent access device fails, only a small part of clients can be affected, and all the clients cannot be affected, so that the influence surface of the failure is limited, and the overall stability of the system is improved.
The Message Server (WebSocket Message Server) is used for performing two-way communication with the agent access devices and the service Server respectively, wherein each agent access device is connected with the Message Server through a respective WebSocket connection channel,
the WebSocket connection channel is established based on a WebSocket Tunnel protocol, and in the WebSocket Tunnel protocol, a plurality of client data forwarded by the proxy access device are gathered on one WebSocket connection channel for transmission through a specific packaging structure.
It should be emphasized that, in this embodiment, there is only one connection channel (line) between one proxy access device and one message server, and the connection channel is established based on the websocket Tunnel protocol designed by the inventor of the present invention.
Through the websocket Tunnel protocol, the proxy access device can aggregate message data of a plurality of clients connected with the proxy access device in one line and send the aggregated message data to the message server. Specifically, the method comprises the following steps: a specific encapsulation structure is adopted in the WebSocket Tunnel protocol, and fig. 3 is a schematic diagram of an encapsulation structure of a WebSocket Tunnel protocol according to an embodiment of the present application, as shown in fig. 3:
the message data of each client is combined into a message file, the message structure of each message data is redefined, specifically, a message type and a client ID are added before the data content of each message data, wherein the message type is used for indicating what kind of processing is to be performed on the message data, and the client ID is the identification ID of the user. In addition, the message is transmitted by adopting a JSON format which is widely used, and the message coding and decoding do not need to be specially designed.
As shown in fig. 4, fig. 4 is a schematic diagram of a partial message structure according to an embodiment of the present application.
Furthermore, because the bottom layer of the WebSocket Tunnel protocol is still based on WebSocket, the data transmitted in the WebSocket Tunnel protocol is still a WebSocket message;
therefore, communication can be realized by using the existing network infrastructure without any special equipment, and the WebSocket connection channel can be established between the proxy access device and the message server through the existing gateway equipment.
Compared with the traditional communication mode based on the WebSocket protocol, the system accesses a plurality of clients through the agent access devices which are distributed, collects the message data of the clients to a connecting line through the WebSocket Tunnel protocol and forwards the message data to the message server, and then forwards the message data to the service server. Because the service server connecting line is only the connecting line with the agent access device, the connecting line required to be processed by the server is greatly reduced, so that the access amount of the client is increased, and meanwhile, the normal communication with the client is not interfered.
Further, the message server is also used for protocol conversion, that is, after converting WebSocket Tunnel protocol data sent by the proxy access device into HTTP protocol data, the HTTP protocol data is forwarded to the server.
Or after the HTTP protocol data sent by the server side is converted into WebSocket Tunnel protocol data, the WebSocket Tunnel protocol data is sent to the proxy access device.
It should be noted that, compared with the conventional HTTP protocol, the process of developing the WebSocket protocol by the server is complex, the development difficulty is higher, and more time and labor costs are consumed. In the embodiment, the message server converts the message data into the traditional HTTP, so that additional development is not needed at the server, the time and labor cost is reduced, and the existing server based on the HTTP can be seamlessly docked.
In some embodiments, fig. 5 is a schematic diagram of an operation of the proxy accessor according to the embodiment of the application, as shown in fig. 5:
the agent access device is used for accessing the client and performing two-way communication with the message server and the client respectively, namely forwarding data sent by the client to the message server and forwarding data sent by the message server to the client.
Further, the proxy access device is also responsible for identity authentication and heartbeat detection with the client and the message server. Since how to establish the connection, how to perform the identity authentication, and how to perform the heartbeat detection do not relate to the core invention points of the present application, and are conventional technical means of those skilled in the art, the description of the present embodiment is not repeated.
In some embodiments, fig. 6 is a schematic diagram of an operation of a message server according to an embodiment of the present application, as shown in fig. 6:
and the message server is in bidirectional communication with the agent access device and the service server respectively. That is, the data sent by the proxy access device is forwarded to the service server, or the data sent by the proxy access device is forwarded to the proxy access device. Besides, the websocket protocol and the HTTP protocol are also responsible for mutual conversion. Further, the specific technical details for performing identity authentication and heartbeat detection are not described herein again.
In some embodiments, fig. 7 is a schematic diagram of a client list according to an embodiment of the present application, where the client list is maintained in a message server, and the client list includes a plurality of sets of client information records, where the client information records include: the client ID, the client address, and the ID of the proxy accessor to which the client is connected.
In the above list, the client ID (client _ ID) needs 8 bytes, the agent access device number (agent _ ID) needs 2 bytes, the client address (remote _ addr) needs 6 bytes, and the time (time) needs 8 bytes. Therefore, one client records only 24 bytes of memory, and when 100 ten thousand clients are connected, only 24M memory is needed.
In addition, as can be seen from fig. 7, there are two recorded client IDs of "34567" because the system supports simultaneous connection of the same client on multiple devices.
In some embodiments, fig. 8 is a schematic flowchart illustrating a process of pushing data to a target client by a service according to an embodiment of the present application, as shown in fig. 8,
first, the service server sends HTTP message data to the message server, for example: "POST/23456 { ' message ' > you have 2 unread messages ' }", wherein the message data includes a client ID and message content;
secondly, the message server searches client information in a locally stored client list according to the client ID, and further determines an agent access device ID and a client address matched with the message data;
further, after processing the message data by a WebSocket Tunnel protocol specific encapsulation structure, the message server forwards the message data to the corresponding proxy access device through the WebSocket connection channel according to the proxy access device ID, where the encapsulated message data includes: message type, client ID and message content;
finally, the agent accessor judges the processing mode of the message data according to the message type encapsulated in the message data (for example, if the character of the message type is '0 x 05', the message data needs to be sent to the client). And determines the corresponding client address according to the client ID "23456" and forwards the message data "you have 2 unread messages" to the corresponding client.
In some embodiments, when a client sends data to a service server, the data is firstly acquired by an agent access device, and then a proxy controller encapsulates message data of a plurality of clients in a fixed format and sends the encapsulated message data to the message server through a WebSocket connection channel established based on a WebSocket Tunnel protocol. And finally, after the message data of each client is converted into HTTP protocol data by the message server, the HTTP protocol data is sent to the service server.
In some embodiments, the scheme of the application also has the characteristic of flexibility in actual deployment, that is, various deployment schemes can be flexibly formulated according to business conditions and self requirements. The system deploys the message server and the agent access device in a user-defined way according to the manual instruction by the user-defined deployment module;
for example: in a company with multiple service lines, multiple dedicated message servers can be deployed for different services, and the proxy accessor is shared by multiple message servers, specifically,
the user can combine the self demand, according to the actual situation of the business, dispose the message server flexibly, for example: the message server with higher hardware configuration is dedicated to the main business, and the message server with relatively poorer hardware configuration is dedicated to the auxiliary business.
Fig. 9 is a schematic diagram of a custom deployment message server according to an embodiment of the present application, where, as shown in fig. 9, a game service server is responsible for communication by a dedicated game message server, and a social service server is responsible for communication by a dedicated social message server.
Because the message server is a transfer and protocol conversion component of all client information, by utilizing the self-defined deployment mode, the node with higher configuration is used for services with higher computational power requirements and more complex scenes, and the message server node with relatively poorer configuration is applied to simpler services. Therefore, a special message server is deployed in a targeted manner according to specific service requirements, so that the system load is reasonably and evenly distributed, and the overall stability is improved.
Furthermore, for some service scenarios with complex scenarios and particularly high message processing pressure, a plurality of dedicated message servers can be set for the service to share the operating pressure, thereby further improving the overall stability.
It should also be noted that the proxy accessor is typically deployed at the edge of the network, as close as possible to the client. For example, lines for respective operators are separately deployed, thereby increasing customer connection speed. Meanwhile, since the agent access device supports a large number of clients and is large in number, in view of cost, the agent access device may be designed to support sharing of each service line (i.e., each service server) without being deployed for each service line.
In some embodiments, an embodiment of the present application further provides a distributed WebSocket access method, where the method includes:
the agent access device is respectively in two-way communication with the message server and the client, wherein a plurality of agent access devices are distributed in the system and each agent access device is connected with a plurality of clients;
a message server, which is respectively communicated with the agent access device and the service server in a bidirectional way, and each agent access device is respectively connected with the message server through a WebSocket connecting channel, wherein,
the WebSocket connection channel is established based on a WebSocket Tunnel protocol, and in the WebSocket Tunnel protocol, a plurality of client data forwarded by the proxy access device are gathered on one WebSocket connection channel for transmission through a specific packaging structure.
In one embodiment, a computer device is provided, which may be a terminal. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a distributed WebSocket access method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
In one embodiment, fig. 10 is a schematic diagram of an internal structure of an electronic device according to an embodiment of the present application, and as shown in fig. 10, there is provided an electronic device, which may be a server, and its internal structure diagram may be as shown in fig. 10. The electronic device comprises a processor, a network interface, an internal memory and a non-volatile memory connected by an internal bus, wherein the non-volatile memory stores an operating system, a computer program and a database. The processor is used for providing calculation and control capabilities, the network interface is used for communicating with an external terminal through network connection, the internal memory is used for providing an environment for an operating system and the running of a computer program, the computer program is executed by the processor to realize a distributed WebSocket access method, and the database is used for storing data.
Those skilled in the art will appreciate that the architecture shown in fig. 10 is merely a block diagram of some of the structures associated with the present solution and does not constitute a limitation on the electronic devices to which the present solution applies, and that a particular electronic device may include more or less components than those shown, or combine certain components, or have a different arrangement of components.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The above examples only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A distributed WebSocket access system, the system comprising: the proxy access device and the message server, wherein;
the agent access devices are used for performing two-way communication with the message server and the client respectively, wherein a plurality of agent access devices are distributed in the system and each agent access device is connected with a plurality of clients;
the message server is used for performing two-way communication with the agent access device and the service server respectively, wherein each agent access device is connected with the message server through a WebSocket connection channel respectively,
the WebSocket connection channel is established based on a WebSocket Tunnel protocol, and in the WebSocket Tunnel protocol, a plurality of client data forwarded by the proxy access device are gathered on one WebSocket connection channel for transmission through a specific packaging structure.
2. The system according to claim 1, wherein in the specific encapsulation structure, message data sent by a plurality of clients are aggregated, and a message body structure of the message data is redefined, wherein a header of each message body structure is added with a message type and a client ID.
3. The system according to claim 2, wherein a client list is maintained in the message server, the client list includes a plurality of sets of client information records, and the client information records include: a client ID, a client address, and a proxy accessor ID that match each other.
4. The system according to claim 3, wherein in case of pushing message data to the client:
the service server is used for sending message data to the message server, wherein the message data comprises a client ID and message content;
the message server is used for searching in the client list according to the client ID, determining the agent accessor ID corresponding to the message data, and,
after the message data is processed by a specific packaging structure of the WebSocket Tunnel protocol, forwarding the message data to a corresponding proxy access device through the WebSocket connection channel according to the proxy access device ID;
and the agent access device is used for judging the processing mode of the message data according to the message type in the message data, determining a corresponding client address according to the client ID, and forwarding the message data to a corresponding client according to the client address.
5. The system according to claim 1, wherein the message data transmitted in the WebSocket Tunnel protocol is a WebSocket message, and the message data in the WebSocket Tunnel protocol is in JSON format.
6. The system of claim 5, wherein the message server is further configured to:
converting the message data from WebSocket protocol format to HTTP protocol format after receiving the message data forwarded by the proxy access device,
and forwarding the message data in the HTTP protocol format to the service server.
7. The system of claim 1, further comprising a custom deployment module, wherein the custom deployment module is configured to custom deploy the message server and the proxy access device according to business requirements, and the custom deployment module comprises:
according to different business items of the business servers, a special message server of each business server is deployed in a targeted manner;
deploying the message server in different machine rooms or cloud platforms according to resource configuration requirements;
deploying the agent accessor and configuring the number of the agent accessors according to an operator line, and sharing the agent accessor among a plurality of the message servers.
8. A distributed WebSocket access method is characterized by comprising the following steps:
the agent access device is respectively in two-way communication with the message server and the client, wherein a plurality of agent access devices are distributed in the system and each agent access device is connected with a plurality of clients;
a message server, which is respectively in two-way communication with the agent access device and the service server, wherein each agent access device is respectively connected with the message server through a WebSocket connection channel, wherein,
the WebSocket connection channel is established based on a WebSocket Tunnel protocol, and in the WebSocket Tunnel protocol, a plurality of client data forwarded by the proxy access device are collected on one WebSocket connection channel for transmission through a specific packaging structure.
9. A computer arrangement comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method as claimed in claim 8 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method of claim 8.
CN202210884320.2A 2022-07-26 2022-07-26 Distributed WebSocket access system and method Active CN114979240B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210884320.2A CN114979240B (en) 2022-07-26 2022-07-26 Distributed WebSocket access system and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210884320.2A CN114979240B (en) 2022-07-26 2022-07-26 Distributed WebSocket access system and method

Publications (2)

Publication Number Publication Date
CN114979240A true CN114979240A (en) 2022-08-30
CN114979240B CN114979240B (en) 2022-10-25

Family

ID=82970207

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210884320.2A Active CN114979240B (en) 2022-07-26 2022-07-26 Distributed WebSocket access system and method

Country Status (1)

Country Link
CN (1) CN114979240B (en)

Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012063282A1 (en) * 2010-11-10 2012-05-18 株式会社日立製作所 Operating method and system for mashup application
CN103458034A (en) * 2013-09-04 2013-12-18 国云科技股份有限公司 Method for having access to SPICE protocol remote desktop through WEB page
CN103685363A (en) * 2012-09-07 2014-03-26 中国科学院计算机网络信息中心 Efficient and reliable method and system for multitask processing
WO2014207305A1 (en) * 2013-06-24 2014-12-31 Cassidian Finland Oy Mobile device management using websocket
US9350763B1 (en) * 2012-04-17 2016-05-24 Amazon Technologies, Inc. HTTP tunnelling over websockets
US20170149915A1 (en) * 2015-11-25 2017-05-25 Sap Se System and method of feed data transmission
CN107342934A (en) * 2017-06-19 2017-11-10 浪潮金融信息技术有限公司 A kind of mixed mode Mobile solution real-time messages method for pushing and system based on WebSocket
US20170329864A1 (en) * 2012-08-31 2017-11-16 Salesforce.Com, Inc. Systems and methods for providing access to external content objects
US10003674B1 (en) * 2017-07-07 2018-06-19 Tmaxsoft.Co., Ltd. Method for supporting websocket and web server and web application server using the same
CN108600204A (en) * 2018-04-11 2018-09-28 浙江大学 A kind of corporate intranet access method based on Opposite direction connection and application layer tunnel
CN109660617A (en) * 2018-12-18 2019-04-19 中电科华云信息技术有限公司 A kind of information push method based on server cluster
CN109922053A (en) * 2019-02-22 2019-06-21 北京三快在线科技有限公司 Data transmission method, device, electronic equipment and readable storage medium storing program for executing
CN112202872A (en) * 2020-09-28 2021-01-08 华云数据控股集团有限公司 Data forwarding method, API gateway and message service system
CN113204730A (en) * 2021-05-19 2021-08-03 网宿科技股份有限公司 Resource acquisition method, webvpn proxy server, system and server
CN114363204A (en) * 2021-12-09 2022-04-15 网宿科技股份有限公司 Request monitoring method, network device and storage medium

Patent Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012063282A1 (en) * 2010-11-10 2012-05-18 株式会社日立製作所 Operating method and system for mashup application
US9350763B1 (en) * 2012-04-17 2016-05-24 Amazon Technologies, Inc. HTTP tunnelling over websockets
US20170329864A1 (en) * 2012-08-31 2017-11-16 Salesforce.Com, Inc. Systems and methods for providing access to external content objects
CN103685363A (en) * 2012-09-07 2014-03-26 中国科学院计算机网络信息中心 Efficient and reliable method and system for multitask processing
WO2014207305A1 (en) * 2013-06-24 2014-12-31 Cassidian Finland Oy Mobile device management using websocket
CN103458034A (en) * 2013-09-04 2013-12-18 国云科技股份有限公司 Method for having access to SPICE protocol remote desktop through WEB page
US20170149915A1 (en) * 2015-11-25 2017-05-25 Sap Se System and method of feed data transmission
CN107342934A (en) * 2017-06-19 2017-11-10 浪潮金融信息技术有限公司 A kind of mixed mode Mobile solution real-time messages method for pushing and system based on WebSocket
US10003674B1 (en) * 2017-07-07 2018-06-19 Tmaxsoft.Co., Ltd. Method for supporting websocket and web server and web application server using the same
CN108600204A (en) * 2018-04-11 2018-09-28 浙江大学 A kind of corporate intranet access method based on Opposite direction connection and application layer tunnel
CN109660617A (en) * 2018-12-18 2019-04-19 中电科华云信息技术有限公司 A kind of information push method based on server cluster
CN109922053A (en) * 2019-02-22 2019-06-21 北京三快在线科技有限公司 Data transmission method, device, electronic equipment and readable storage medium storing program for executing
CN112202872A (en) * 2020-09-28 2021-01-08 华云数据控股集团有限公司 Data forwarding method, API gateway and message service system
CN113204730A (en) * 2021-05-19 2021-08-03 网宿科技股份有限公司 Resource acquisition method, webvpn proxy server, system and server
CN114363204A (en) * 2021-12-09 2022-04-15 网宿科技股份有限公司 Request monitoring method, network device and storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
LI BAI-CHAO: "Keyword Mining for Private Protocols Tunneled Over WebSocket", 《IEEE COMMUNICATIONS LETTERS》 *
曾玮等: "基于Spring Session及Redis的高校Web服务器会话保持技术研究", 《实验室科学》 *
童珉: "WebSocket通信技术在无线电频谱管理系统中的应用", 《广播与电视技术》 *

Also Published As

Publication number Publication date
CN114979240B (en) 2022-10-25

Similar Documents

Publication Publication Date Title
US11522734B2 (en) Method for controlling a remote service access path and relevant device
CN108200165B (en) Request Transmission system, method, apparatus and storage medium
CN113596191B (en) Data processing method, network element equipment and readable storage medium
WO2020057469A1 (en) Data processing method, related device, and computer storage medium
CN108200158B (en) Request Transmission system, method, apparatus and storage medium
CN111327668B (en) Network management method, device, equipment and storage medium
CN113242293A (en) UPF equipment, data processing and capacity expansion method and device
CN110012118B (en) Method and controller for providing Network Address Translation (NAT) service
CN105119787A (en) Public Internet access system and public Internet access method based on software definition
KR20210023194A (en) Mec(mobile edge computing) system and control method thereof
CN113037737A (en) External network card technology for various user terminal devices
CN111182022A (en) Data transmission method and device, storage medium and electronic device
CN112968965B (en) Metadata service method, server and storage medium for NFV network node
CN112398845B (en) Data transmission method, data transmission device, data transmission system and electronic equipment
CN114979240B (en) Distributed WebSocket access system and method
CN107094175A (en) A kind of server disposition structure and interoperability methods for realizing interworking between network
CN111193778A (en) Method, device, equipment and medium for WEB service load balancing
CN114025010B (en) Method for establishing connection and network equipment
CN115834684A (en) Data processing method, cloud desktop system, equipment and storage medium
KR101251630B1 (en) System and method for providing push service
CN114866854A (en) Video access mode dynamic allocation method, system, electronic equipment and storage medium
CN111315037B (en) Communication link establishing method and device, computer equipment and storage medium
CN110311936B (en) Communication method and device between clients, electronic equipment and storage medium
CN112333690A (en) Data transmission method, device, storage medium, terminal and network access point equipment
CN111818147A (en) System and method for realizing automatic load balancing of openstack swift service

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