CN116095140A - Unified access gateway method and system based on WebSocket - Google Patents

Unified access gateway method and system based on WebSocket Download PDF

Info

Publication number
CN116095140A
CN116095140A CN202211717337.5A CN202211717337A CN116095140A CN 116095140 A CN116095140 A CN 116095140A CN 202211717337 A CN202211717337 A CN 202211717337A CN 116095140 A CN116095140 A CN 116095140A
Authority
CN
China
Prior art keywords
message
gateway
client
transit gateway
transit
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211717337.5A
Other languages
Chinese (zh)
Inventor
陈荣观
陈锦辉
戴立陈
黄嘉晟
林清伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujian Xingwang Intelligent Technology Co ltd
Original Assignee
Fujian Xingwang Intelligent 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 Fujian Xingwang Intelligent Technology Co ltd filed Critical Fujian Xingwang Intelligent Technology Co ltd
Priority to CN202211717337.5A priority Critical patent/CN116095140A/en
Publication of CN116095140A publication Critical patent/CN116095140A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/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]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention provides a unified access gateway method and a unified access gateway system based on WebSocket, wherein the method comprises the following steps: the client side is provided with unified connection and is connected with the transit gateway; after establishing connection with the transit gateway through the client, packaging the message according to the format requirement of the transit gateway and then sending the message to the transit gateway; analyzing the receiver by the transfer gateway, packaging the message into a sender and a sent message body, and sending the sender and the message body to the corresponding receiver; the server end network element analyzes the message of the transit gateway, and after the service is processed, the received sender is taken as a receiver, and the service result is taken as a sent message body and returned to the transit gateway; and the transit gateway analyzes the message returned by the network element of the server, analyzes the receiver, encapsulates the message into a sender and a message body sent to the corresponding client. The invention can reduce the connection number of the client and the network element of the server, simplify the configuration and save the performance.

Description

Unified access gateway method and system based on WebSocket
Technical Field
The invention relates to the technical field of electronic information, in particular to a unified access gateway method and system based on WebSocket.
Background
At present, the existing gateway unified entry is mainly implemented by proxy for Http, for example, the nginix adopts Url to proxy, and of course, the nginix can proxy WebSocket, but the most important problem is that the nginix cannot reduce the number of connections. The connection occupation performance of WebSocket is greatly affected, so when using nginnx for proxy, N clients will cause n×m connections when connecting M network elements, and the clients need to connect multiple network elements WebSocket, which is troublesome in configuration and occupies performance. And the coupling degree of the existing client list and the network element WebSocket is higher, various authentications are required to be carried out aiming at different network elements, and the network elements are reconnected, so that the stability degree is difficult to maintain.
Disclosure of Invention
The invention aims to solve the technical problem of providing a unified access gateway method and a unified access gateway system based on WebSocket, which reduce the number of connections between a client and a server network element, simplify configuration, reduce performance occupation and are convenient to maintain.
In a first aspect, the present invention provides a method for unifying access gateways based on WebSocket, which needs to provide a client, a transit gateway and a server network element, where the client and the transit gateway are connected through WebSocket, and the method includes the following steps:
s1, setting uniform connection on a client side, realizing connection with a transit gateway, and developing service-oriented according to the requirement of the transit gateway;
s2, after connection is established with the transit gateway through the client, the message is packaged according to the format requirement of the transit gateway and then sent to the transit gateway, and the content of the message comprises a receiver and a sent message body;
s3, analyzing the receiver by the transit gateway, packaging the message into a sender and a sent message body, and sending the sender and the message body to the corresponding receiver;
s4, the server-side network element serving as a receiver analyzes the message of the transit gateway and carries out corresponding service processing, after the service is processed, the received sender serves as the receiver, and the service result serves as a sent message body and is returned to the transit gateway;
s5, the transit gateway analyzes the message returned by the server-side network element, analyzes the receiver, and encapsulates the message into a sender and a sent message body to the corresponding client.
Further, the client stores each server network element ID and the transit gateway ID.
Further, each client ID and each server ID are stored in the transit gateway.
In a second aspect, the present invention provides a system for unifying access gateways based on WebSocket, which needs to provide a client, a transit gateway and a server network element, where the client and the transit gateway are connected through WebSocket, and the system includes:
the client connection module is used for setting uniform connection on the client side, realizing connection with the transit gateway and developing service-oriented according to the requirement of the transit gateway;
the service request module is used for packaging the message according to the format requirement of the transit gateway and then sending the message to the transit gateway after establishing connection with the transit gateway through the client, wherein the content of the message comprises a receiver and a sent message body;
the forwarding protocol module is used for analyzing the receiver by the forwarding gateway, encapsulating the message into a sender and a sent message body and sending the sender and the message body to the corresponding receiver;
the service processing module is used for analyzing the message of the transit gateway by the service end network element serving as a receiver, carrying out corresponding service processing, taking the received sender as the receiver after the service is processed, and returning the service result as a sent message body to the transit gateway;
and the result return module is used for analyzing the message returned by the server-side network element by the transit gateway, analyzing the receiver, and packaging the message into a sender and a message body sent to the corresponding client.
Further, the client stores each server network element ID and the transit gateway ID.
Further, each client ID and each server ID are stored in the transit gateway.
The invention has the following advantages: by the WebSocket unified entry mode, the occupied connections are changed from original N multiplied by M to N+M, so that the performance of a system with a plurality of clients and a plurality of server network elements can be greatly saved, and the configuration is simplified. The transit gateway and other service end network elements adopt a connection mode, the client is not connected with each network element any more, so that the client is not concerned with the states and connection modes of other network elements any more, decoupling of the client and other network elements is realized, and the connection stability is high and the maintenance is easy.
Drawings
The invention will be further described with reference to examples of embodiments with reference to the accompanying drawings.
Fig. 1 is a flowchart of a method execution of a unified access gateway based on WebSocket according to the present invention.
Fig. 2 is a system block diagram of a unified access gateway based on WebSocket according to the present invention.
Fig. 3 is a schematic diagram of a unified access gateway connection structure based on WebSocket in the present invention.
Detailed Description
The embodiment of the application is used for solving the problems of troublesome configuration and occupied performance of the prior art that a client is connected with a plurality of network elements WebSocket by providing a method and a system for unifying access gateways based on WebSocket.
According to the technical scheme in the embodiment of the application, the overall thought is as follows: the unified access gateway based on the WebSocket mainly comprises three parts of unified access points, webSocket connection optimization and protocol design optimization. The unified access point mainly aims at the client, when various gateways acquire various different service data, the connection protocol and the authentication problem during connection are not needed to be considered, the unified access point is only required to be developed according to the requirements of the transit gateway, and meanwhile, the connection of the transit gateway is only required, so that the capability of service development is realized. WebSocket connection optimization is two-way, namely, a server side is aimed at, and a client side is aimed at: aiming at the service end, N clients are originally arranged, the pressure to be born by the service end is N connections, and after the transit gateway is arranged, only 1 connection of the transit gateway is born, and the connection optimization is changed from N connections to 1 connection; for the aspect of the client, if there are M WebSocket servers, the client needs to create M WebSocket clients, and if there are transit gateways, only 1 connection is needed to be performed for the transit gateway, and the connection optimization is optimized to be 1 by M. Protocol design optimization means that the message from the client side to the message from the server side is converted; when the client transmits the message, the client transmits the message in a format required by a transfer gateway, wherein the format mainly comprises a receiver and a transmitted message body, the transfer gateway analyzes the receiver, encapsulates the message into the sender and the transmitted message body, a server network element analyzes the message, and returns the message as the receiver and the service result as the message body according to the received sender ID after the service is processed. In the process, the decoupling of the client and the server is also realized, the client does not need to care about the state of the current service network element any more, and only the network element name needing to be docked is indicated in the protocol, and the gateway is transferred to be responsible for docking and returning the response message.
In order to better understand the above technical solutions, the following detailed description will refer to the accompanying drawings and specific embodiments.
Example 1
The embodiment provides a method for unifying access gateways based on WebSocket, which needs to provide a client, a transit gateway and a server network element, wherein the transit gateway and the server network element belong to a server side, the client and the transit gateway are connected through WebSocket, as shown in fig. 1 and fig. 3, and the connections in fig. 3 are WebSocket connections, and the method comprises the following steps:
s1, setting uniform connection on a client side, realizing connection with a transit gateway, and developing service-oriented according to the requirement of the transit gateway;
s2, after connection is established with the transit gateway through the client, the message is packaged according to the format requirement of the transit gateway and then sent to the transit gateway, and the content of the message comprises a receiver and a sent message body;
s3, analyzing the receiver by the transit gateway, packaging the message into a sender and a sent message body, and sending the sender and the message body to the corresponding receiver;
s4, the server network element (such as network element A, network element B, network element C in figure 3, etc.) serving as the receiver analyzes the message of the transit gateway, and carries out corresponding service processing, after the service is processed, the received sender ID is taken as the receiver, and the service result is taken as a sent message body to be returned to the transit gateway;
s5, the transit gateway analyzes the message returned by the server-side network element, analyzes the receiver, and encapsulates the message into a sender and a sent message body to the corresponding client.
Preferably, the client stores each server network element ID and the transit gateway ID.
Preferably, each client ID and each server ID are stored in the transit gateway.
Example two
The invention provides a unified access gateway system based on WebSocket, which needs to provide a client, a transit gateway and a server network element, wherein the transit gateway and the server network element belong to a server side, the client and the transit gateway are connected through WebSocket, as shown in FIG. 2 and FIG. 3, the connections in FIG. 3 are all WebSocket connections, and the system comprises:
the client connection module is used for setting uniform connection on the client side, realizing connection with the transit gateway and developing service-oriented according to the requirement of the transit gateway;
the service request module is used for packaging the message according to the format requirement of the transit gateway and then sending the message to the transit gateway after establishing connection with the transit gateway through the client, wherein the content of the message comprises a receiver and a sent message body;
the forwarding protocol module is used for analyzing the receiver by the forwarding gateway, encapsulating the message into a sender and a sent message body and sending the sender and the message body to the corresponding receiver;
the service processing module is used for analyzing the message of the transit gateway by a service end network element (such as network element A, network element B, network element C and the like in fig. 3) serving as a receiver, carrying out corresponding service processing, taking the received sender ID as the receiver after the service is processed, and returning the service result as a sent message body to the transit gateway;
and the result return module is used for analyzing the message returned by the server-side network element by the transit gateway, analyzing the receiver, and packaging the message into a sender and a message body sent to the corresponding client.
Preferably, the client stores each server network element ID and the transit gateway ID.
Preferably, each client ID and each server ID are stored in the transit gateway.
The technology is designed and realized on the basis of WebSocket and the proxy thought of Nginx. WebSocket is a protocol that performs full duplex communication over a single TCP connection, which makes the exchange of data between a client and a server simpler, allowing the server to push data to the client on its own initiative. In the WebSocket API, the client and the server only need to complete one handshake, and can directly create persistent connection between the two and perform bidirectional data transmission. Nginx is an HTTP server, and has a great effect of matching according to Url, and proxy real server, so as to realize hiding and unifying interfaces outside a server heap.
The invention realizes that the access points of the client WebSocket are unified as the transit gateway by the unified entry method, and solves the problems of troublesome configuration and occupation performance of the client connected with a plurality of network elements WebSocket. According to the invention, the transit gateway and other service end network elements adopt a connection mode, and the client is not connected with each network element any more, so that the problem of occupying excessive connection and affecting the performance is solved; the access of the transit gateway also ensures that the client does not need to care about the states and the connection modes of other network elements, thereby realizing the decoupling of the client and other network elements.
While specific embodiments of the invention have been described above, it will be appreciated by those skilled in the art that the specific embodiments described are illustrative only and not intended to limit the scope of the invention, and that equivalent modifications and variations of the invention in light of the spirit of the invention will be covered by the claims of the present invention.

Claims (6)

1. A unified access gateway method based on WebSocket is characterized in that: the method comprises the following steps that a client, a transit gateway and a server network element are required to be provided, wherein the client is connected with the transit gateway through a WebSocket, and the method comprises the following steps:
s1, setting uniform connection on a client side, realizing connection with a transit gateway, and developing service-oriented according to the requirement of the transit gateway;
s2, after connection is established with the transit gateway through the client, the message is packaged according to the format requirement of the transit gateway and then sent to the transit gateway, and the content of the message comprises a receiver and a sent message body;
s3, analyzing the receiver by the transit gateway, packaging the message into a sender and a sent message body, and sending the sender and the message body to the corresponding receiver;
s4, the server-side network element serving as a receiver analyzes the message of the transit gateway and carries out corresponding service processing, after the service is processed, the received sender serves as the receiver, and the service result serves as a sent message body and is returned to the transit gateway;
s5, the transit gateway analyzes the message returned by the server-side network element, analyzes the receiver, and encapsulates the message into a sender and a sent message body to the corresponding client.
2. The method according to claim 1, characterized in that: and each server network element ID and the transit gateway ID are stored on the client.
3. The method according to claim 1, characterized in that: and each client ID and each server network element ID are stored in the transit gateway.
4. A WebSocket-based unified access gateway system, characterized in that: the system comprises a client, a transit gateway and a server network element, wherein the client is connected with the transit gateway through a WebSocket, and the system comprises:
the client connection module is used for setting uniform connection on the client side, realizing connection with the transit gateway and developing service-oriented according to the requirement of the transit gateway;
the service request module is used for packaging the message according to the format requirement of the transit gateway and then sending the message to the transit gateway after establishing connection with the transit gateway through the client, wherein the content of the message comprises a receiver and a sent message body;
the forwarding protocol module is used for analyzing the receiver by the forwarding gateway, encapsulating the message into a sender and a sent message body and sending the sender and the message body to the corresponding receiver;
the service processing module is used for analyzing the message of the transit gateway by the service end network element serving as a receiver, carrying out corresponding service processing, taking the received sender as the receiver after the service is processed, and returning the service result as a sent message body to the transit gateway;
and the result return module is used for analyzing the message returned by the server-side network element by the transit gateway, analyzing the receiver, and packaging the message into a sender and a message body sent to the corresponding client.
5. The system according to claim 4, wherein: and each server network element ID and the transit gateway ID are stored on the client.
6. The system according to claim 4, wherein: and each client ID and each server network element ID are stored in the transit gateway.
CN202211717337.5A 2022-12-29 2022-12-29 Unified access gateway method and system based on WebSocket Pending CN116095140A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211717337.5A CN116095140A (en) 2022-12-29 2022-12-29 Unified access gateway method and system based on WebSocket

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211717337.5A CN116095140A (en) 2022-12-29 2022-12-29 Unified access gateway method and system based on WebSocket

Publications (1)

Publication Number Publication Date
CN116095140A true CN116095140A (en) 2023-05-09

Family

ID=86198568

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211717337.5A Pending CN116095140A (en) 2022-12-29 2022-12-29 Unified access gateway method and system based on WebSocket

Country Status (1)

Country Link
CN (1) CN116095140A (en)

Similar Documents

Publication Publication Date Title
CN102546800B (en) Handshake and communication methods for gateway, gateway and Web communication system
CN107018147B (en) Internet of things communication method and system and gateway module
CN102546794B (en) Method for directly communicating browser client with back-end server as well as gateway and communication system
CN109525661B (en) Data transmission method and device
US8032609B2 (en) Dynamic endpoint aggregator for web services
US8726149B2 (en) Method and system for providing reduced-size hypertext content to a limited-display client device
JP3478200B2 (en) Two-way communication system between server and client
CN1812405B (en) Reliable one-way messaging over request-response transport protocols
CN110677432A (en) Network protocol internal proxy forwarding method, device, medium and terminal equipment
CN114827202A (en) Entity transmission method, system and storage medium based on Internet of things interaction
CN107342934A (en) A kind of mixed mode Mobile solution real-time messages method for pushing and system based on WebSocket
CN102594886B (en) Method and device for direct communication between browsers, and communication system
CN114157537A (en) System and method for realizing multi-source heterogeneous data access by general equipment gateway
CN101631127A (en) File transfer method and clients
CN117615043B (en) Inter-service communication method and system on edge gateway
US8918516B2 (en) Symbiotic client and server for embedded network system
CN116095140A (en) Unified access gateway method and system based on WebSocket
CN102761780A (en) Method for obtaining media metadata by intelligent remote controller to
CN102857504B (en) Network optimized approach and device
CN114257576A (en) RPC server implementation method based on support of multiple communication protocols
CN102325187A (en) System and method for integrating multiple function services
CA2592881C (en) Dynamic endpoint aggregator for web services
CN118018538B (en) Method for communication of Internet of things through external program module
CN110851116A (en) Embedded system message interaction middleware
US20030018831A1 (en) Application programming interface for providing direct access to a WSP layer of a WAP stack

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