Communication method of communication system, communication system, server and storage medium
By generating subscription identifiers for the protocol server and client of the WebSocket protocol in a distributed environment, the management and routing of long links of WebSocket is realized, which solves the problems of accurate and inefficient data transmission and reduces system complexity and maintenance costs.
Patent Information
- Application Number
- CN202411268425.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2024-12-10
AI Technical Summary
In distributed environments, the WebSocket protocol's data transmission accuracy is insufficient, resulting in low efficiency, and prior art often employs additional components or services to solve this problem, but increases system complexity and maintenance costs.
By establishing a WebSocket connection between the protocol server and the protocol client, generating a subscription identity associated with the target protocol client, and subscribing and obtaining the target data based on the identity, thereby realizing the management and routing of WebSocket long links in a distributed environment. Improve the accuracy and efficiency of data transmission.
It realizes the management and routing of long links of WebSocket in a distributed environment, improves the accuracy and efficiency of target data transmission, reduces network latency and bandwidth consumption, and reduces system complexity and maintenance costs.
Smart Images

Figure CN119109915A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network communication technology, and more specifically, to a communication method of a communication system, a communication system, a server, and a computer-readable storage medium. Background Art
[0002] The WebSocket protocol used to establish a persistent connection is a full-duplex communication protocol that allows data to be transmitted simultaneously on the client and server without the need to frequently establish and close connections, which can enhance communication efficiency. However, when the WebSocket protocol is used in a distributed environment, the accuracy of data transmission is insufficient. Summary of the invention
[0003] The present application provides a communication method of a communication system, a communication system, a server and a computer-readable storage medium.
[0004] The present application embodiment provides a communication method of a communication system, wherein the communication system includes a protocol server, an application server, and a plurality of protocol clients, and the method is used for the protocol server, and the method includes:
[0005] Generate a subscription identifier associated with a target protocol client, where the target protocol client is one of a plurality of the protocol clients, and each of the protocol clients establishes a communication connection with the protocol server based on the WebSocket protocol;
[0006] subscribing to a cache database of the communication system according to the subscription identifier;
[0007] The target data is obtained from the cache database according to the subscription identifier to send the target data to the target protocol client, wherein the target data is published to the cache database by the application server according to the subscription identifier.
[0008] In this way, in a distributed environment where multiple protocol clients respectively establish communication connections with protocol servers based on the WebSocket protocol, the protocol server generates a subscription identifier associated with a target protocol client and subscribes to a cache database of the communication system according to the subscription identifier. The target protocol client is one of the multiple protocol clients. Then, the protocol server obtains the target data from the cache database according to the subscription identifier to accurately send the target data to the target protocol client, wherein the target data is published to the cache database by the application server according to the subscription identifier. In this way, the management and routing of WebSocket long links in a distributed environment are realized, and the accuracy and efficiency of target data transmission are improved. In addition, a communication connection is established between the protocol server and the protocol client based on the WebSocket protocol, and data can be continuously transmitted without interrupting the connection until one of the parties closes the connection, thereby reducing network delays and bandwidth consumption and improving the efficiency of target data transmission.
[0009] In some implementations, generating a subscription identifier associated with a target protocol client includes:
[0010] A subscription identifier associated with the target protocol client is generated based on preset information, wherein the preset information includes client information of the target protocol client, geographic location information of the target protocol client, device information of the target protocol client and / or network information of the target protocol client.
[0011] In this way, the protocol server generates a subscription identifier associated with the target protocol client based on preset information, and the preset information includes client information of the target protocol client, geographic location information of the target protocol client, device information of the target protocol client, and / or network information of the target protocol client. In this way, suitable preset information can be selected for different application scenarios and associated with the generated subscription identifier, thereby identifying and classifying the protocol client and achieving more accurate data distribution.
[0012] In some implementations, generating a subscription identifier associated with a target protocol client includes:
[0013] A plurality of subscription identifiers associated with the target protocol client are generated, each of the subscription identifiers being used to identify a target data category.
[0014] In this way, the protocol server generates multiple subscription identifiers associated with the target protocol client, and each subscription identifier is used to identify a target data category. In this way, the protocol server can receive target data categories corresponding to different subscription identifiers, and achieve efficient and targeted target data delivery. In addition, the protocol server can generate or delete subscription identifiers of different target data categories according to the needs of the protocol client, and achieve flexible delivery of target data.
[0015] In some implementations, subscribing to a cache database of the communication system according to the subscription identifier includes:
[0016] Obtaining an association relationship between the target protocol client and the subscription identifier according to the subscription identifier;
[0017] Subscribe to the associated channel corresponding to the associated relationship in the cache database.
[0018] In this way, the protocol server obtains the association relationship between the target protocol client and the subscription identifier according to the subscription identifier, and subscribes to the association channel corresponding to the association relationship in the cache database. In this way, by subscribing to the association channel, the protocol server can be used to obtain the target data published to the association channel in the subsequent process. In addition, the target data published to the association channel will only be passed to the protocol server that has subscribed to the association channel, reducing unnecessary network communications and improving the performance of the communication system.
[0019] In some implementations, obtaining target data from the cache database according to the subscription identifier includes:
[0020] The target data is obtained from the cache database according to the associated channel.
[0021] In this way, the protocol server obtains the target data from the cache database according to the associated channel. In this way, the protocol server can obtain the target data published to the associated channel from the cache database through the associated channel, thereby achieving accurate transmission of the target data.
[0022] In certain embodiments, the method further comprises:
[0023] Establishing a communication connection with the target protocol client based on the WebSocket protocol, and generating a session identifier associated with the target protocol client;
[0024] The target data is sent to the target protocol client according to the session identifier.
[0025] In this way, the protocol server establishes a communication connection with the target protocol client based on the WebSocket protocol, and generates a session identifier associated with the target protocol client. Then, the protocol server sends the target data to the target protocol client according to the session identifier. In this way, through the generated session identifier, the protocol server can identify the target protocol client and pass the target data to the target protocol client, thereby achieving accurate delivery of the target data.
[0026] The present application embodiment provides a communication method of a communication system, wherein the communication system includes a protocol server, an application server, and a plurality of protocol clients, and the method is used for the application server, and the method includes:
[0027] The target data is published to the cache database of the communication system according to the subscription identifier, so that the protocol server obtains the target data from the cache database according to the subscription identifier and sends the target data to the target protocol client, wherein the subscription identifier is generated by the protocol server and is associated with the target protocol client, the target protocol client is one of multiple protocol clients, and each of the protocol clients establishes a communication connection with the protocol server based on the WebSocket protocol.
[0028] In this way, the application server publishes the target data to the cache database of the communication system according to the subscription identifier, so that the protocol server obtains the target data from the cache database according to the subscription identifier, and sends the target data to the target protocol client, wherein the subscription identifier is generated by the protocol server and is associated with the target protocol client, the target protocol client is one of multiple protocol clients, and each protocol client establishes a communication connection with the protocol server based on the WebSocket protocol. In this way, the management and routing of WebSocket long links in a distributed environment are realized, and the accuracy and efficiency of target data transmission are improved. In addition, a communication connection is established between the protocol server and the protocol client based on the WebSocket protocol, and data can be continuously transmitted without interrupting the connection until one of the parties closes the connection, reducing network delays and bandwidth consumption, and improving the efficiency of target data transmission.
[0029] In some implementations, publishing the target data to the cache database according to the subscription identifier includes:
[0030] Acquire the association relationship between the target protocol client and the subscription identifier from the cache database;
[0031] The target data is published to the cache database according to the association relationship.
[0032] In this way, the application server obtains the association relationship between the target protocol client and the subscription identifier from the cache database, and publishes the target data to the cache database according to the association relationship. In this way, obtaining the association relationship from the cache database and publishing the target data to the cache database according to the association relationship achieves efficient and accurate target data transmission, which helps to improve the efficiency of the communication system.
[0033] In some implementations, publishing the target data to the cache database according to the association relationship includes:
[0034] The target data is published to an associated channel, where the associated channel is used to indicate a channel in the cache database corresponding to the association relationship between the target protocol client and the subscription identifier.
[0035] In this way, the application server publishes the target data to the associated channel, which is used to indicate the channel in the cache database corresponding to the association relationship between the target protocol client and the subscription identifier. In this way, by publishing the target data to the associated channel, the cache database will publish the target data to the protocol server that has subscribed to the associated channel, thereby achieving accurate delivery of the target data and helping to improve the performance of the communication system.
[0036] The present application embodiment provides a communication system, the communication system comprising a protocol server, an application server and a plurality of protocol clients;
[0037] The protocol server is configured to: generate a subscription identifier associated with a target protocol client, the target protocol client is one of a plurality of the protocol clients, and each of the protocol clients establishes a communication connection with the protocol server based on the WebSocket protocol;
[0038] subscribing to a cache database of the communication system according to the subscription identifier;
[0039] Acquire target data from the cache database according to the subscription identifier, so as to send the target data to the target protocol client;
[0040] The application server is configured to publish the target data to the cache database according to the subscription identifier.
[0041] In this way, the communication system can realize the management and routing of WebSocket long links in a distributed environment, improving the accuracy and efficiency of target data transmission. In addition, the protocol server in the communication system and the protocol client in the communication system establish a communication connection based on the WebSocket protocol, which can continuously transmit data without interrupting the connection until one of the parties closes the connection, reducing network delays and bandwidth consumption, and improving the efficiency of target data transmission.
[0042] An embodiment of the present application provides a server, wherein the memory stores a computer program, and when the computer program is executed by the processor, the above method is implemented.
[0043] An embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium memory stores a computer program, and when the computer program is executed by one or more processors, the above method is implemented.
[0044] Additional aspects and advantages of the embodiments of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0046] Figure 1 is a flow chart of a communication method according to some embodiments of the present application;
[0047] Figure 2 is a schematic diagram of a communication system of certain embodiments of the present application;
[0048] Figure 3 is a flow chart of a communication method according to some embodiments of the present application;
[0049] Figure 4 is a flow chart of a communication method according to some embodiments of the present application;
[0050] Figure 5 is a flow chart of a communication method according to some embodiments of the present application;
[0051] Figure 6 is a flow chart of a communication method according to some embodiments of the present application;
[0052] Figure 7 is a flow chart of a communication method according to some embodiments of the present application;
[0053] Figure 8 It is a schematic diagram of the corresponding relationship between the protocol client and the identifier in some implementation modes of the present application;
[0054] Fig. 9 is a flow chart of a communication method according to some embodiments of the present application;
[0055] Fig.10 is a flow chart of a communication method according to some embodiments of the present application;
[0056] Fig.11 It is a flowchart of a communication method of certain embodiments of the present application. DETAILED DESCRIPTION
[0057] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals represent the same or similar elements or elements having the same or similar functions from beginning to end. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the embodiments of the present application, and cannot be understood as limiting the embodiments of the present application.
[0058] The WebSocket protocol provides a full-duplex communication method that allows data to be transmitted in two directions simultaneously. Compared with HTTP requests, there is no need to re-establish a connection for each communication, thereby reducing a large amount of protocol overhead while maintaining a connection and improving the efficiency of target data transmission. It is suitable for applications that require real-time updates and fast responses.
[0059] Therefore, the WebSocket protocol is suitable for the field of vehicle communication network technology where real-time data exchange is often carried out, such as vehicle monitoring, navigation systems, and autonomous driving. In addition, since the WebSocket protocol reduces a large amount of protocol overhead when maintaining a connection, for resource-constrained environments such as vehicles, more resources can be used in other directions to improve vehicle performance. In addition, since the vehicle's in-vehicle network environment usually faces various complex situations, such as network fluctuations and data compression, the flexibility and efficiency of the WebSocket protocol enable the protocol to adapt to these complex environments.
[0060] However, since the WebSocket connection of each vehicle is independent, in a distributed environment, when a message needs to be sent to a specific user or a specific vehicle, the corresponding user or vehicle needs to be found in all WebSocket connections, which results in insufficient accuracy and low efficiency in data transmission. In related technologies, additional components or services are usually used to support distributed environments to solve the above problems, but this increases the complexity and maintenance costs of the system.
[0061] Based on the above questions, please refer to Figure 1 The embodiment of the present application provides a communication method of a communication system, the communication system includes a protocol server, an application server and a plurality of protocol clients, the method is used for the protocol server, and the method includes:
[0062] 011: Generate a subscription identifier associated with the target protocol client;
[0063] 012: Subscribe to the cache database of the communication system according to the subscription identifier;
[0064] 013: Obtain target data from the cache database according to the subscription identifier to send the target data to the target protocol client.
[0065] The embodiment of the present application also provides a server, including a memory and a processor. The resource access method of the embodiment of the present application can be implemented by the server of the embodiment of the present application. Specifically, a computer program is stored in the memory, and the processor is used to generate a subscription identifier associated with a target protocol client. And subscribe to a cache database of a communication system according to the subscription identifier. And obtain target data from the cache database according to the subscription identifier to send the target data to the target protocol client.
[0066] The embodiment of the present application also provides a protocol server communication device. The resource access method of the embodiment of the present application can be implemented by the protocol server communication device of the embodiment of the present application. Specifically, the protocol server communication device includes a generation module, a subscription module and an acquisition module. The generation module is used to generate a subscription identifier associated with a target protocol client. The subscription module is used to subscribe to a cache database of a communication system according to the subscription identifier. The acquisition module is used to obtain target data from the cache database according to the subscription identifier to send the target data to the target protocol client.
[0067] The embodiment of the present application also provides a communication system 1000 , which includes a protocol server 100 , an application server 200 and a plurality of protocol clients 300 .
[0068] Among them, the protocol server 100 is configured to generate a subscription identifier associated with a target protocol client, the target protocol client is one of a plurality of protocol clients 300, each protocol client 300 respectively establishes a communication connection with the protocol server 100 based on the WebSocket protocol, and subscribes to a cache database of the communication system 1000 according to the subscription identifier, and obtains target data from the cache database according to the subscription identifier to send the target data to the target protocol client.
[0069] The application server 200 is configured to publish the target data to the cache database according to the subscription identifier.
[0070] Specifically, the WebSocket protocol is a full-duplex communication protocol that allows data to be transmitted simultaneously on the client and server without the need to frequently establish and close connections, thereby enhancing communication efficiency.
[0071] A protocol server is a server that establishes a communication connection with a protocol client based on the WebSocket protocol. A protocol client is a client that establishes a communication connection with a protocol server based on the WebSocket protocol.
[0072] Application servers refer to external servers that communicate with protocol servers.
[0073] Subscription IDs are used to identify different types of messages or data.
[0074] The protocol server 100, application server 200 and multiple protocol clients 300 in the implementation mode of the present application constitute a distributed system. The protocol server 100, application server 200 and multiple protocol clients 300 are respectively distributed in different locations of the network, and each device can run alone and work in collaboration with other devices. Among them, data transmission is carried out between the protocol server 100 and the application server 200 through a network connection, and the protocol server 100 and multiple protocol clients 300 establish a communication connection based on the WebSocket protocol. In some embodiments, the protocol server 100 can be a server of an urban traffic management system, a cloud game server and a server of an online education platform. The application server 200 can be an external processing system for collecting road condition information, an external processing system for transmitting game data to a cloud game server, and an external processing system for transmitting education data to an online education server. The protocol client 300 can be a vehicle, a mobile phone and a tablet.
[0075] The cache database refers to a message middleware with publish-subscribe functions, which can realize the decoupling and asynchronous transmission of data between different components. The cache database includes RabbitMQ, Kafka and Redis cache databases. The communication method of the implementation method of the present application is described below using the Redis cache database as the cache database. It should be noted that the cache database in the implementation method of the present application can run as an independent service with its own server instance and port. It can also be integrated into the server through embedding and run as part of the server.
[0076] See also Figure 2 , Figure 2 A schematic diagram of a communication system provided in an embodiment of the present application, Figure 2 In the example, the Redis cache database is run as an independently deployed server. The communication process is as follows: the application server 200 publishes the target data to the Redis cache database according to the subscription identifier. Then, the Redis cache database publishes the target data to the protocol server 100. Finally, the protocol server 100 sends the target data to the protocol client 300 according to the communication connection established by the WebSocket protocol.
[0077] It should be noted that the communication method of the communication system provided in the embodiment of the present application is applicable to a situation in which multiple protocol clients 300 respectively establish communication connections with a protocol server 100 based on the WebSocket protocol, and the communication system includes a distributed environment of multiple protocol servers 100, and the target data needs to be accurately published to the corresponding target protocol client 300.
[0078] Specifically, in a distributed environment where multiple protocol clients 300 respectively establish communication connections with the protocol server 100 based on the WebSocket protocol, the protocol server 100 generates a subscription identifier associated with a target protocol client 300 and subscribes to a cache database of the communication system according to the subscription identifier, and the target protocol client 300 is one of the multiple protocol clients 300. Then, the protocol server 100 obtains the target data from the cache database according to the subscription identifier to accurately send the target data to the target protocol client 300, wherein the target data is published to the cache database by the application server 200 according to the subscription identifier.
[0079] The following is an example to illustrate the method of the implementation mode of the present application. In the embodiment of the present application, the vehicle serves as the protocol client 300, and vehicle A serves as the target protocol client 300. The server of the urban traffic management system serves as the protocol server 100, hereinafter referred to as the management server, and the urban traffic management system is used to provide real-time information and navigation guidance. The external processing system serves as the application server 200, and the external processing system is used to collect road condition information. Topic serves as a subscription identifier. Road condition information is the target data. It should be noted that in a city, there are multiple management servers distributed in different locations to achieve redundancy and failover, ensuring that the urban traffic management system can still operate normally when a single server has problems.
[0080] When the management server and vehicle A establish a communication connection based on the WebSocket protocol, the management server generates Topic-A associated with vehicle A. This Topic-A identifies the road condition information. The management server then subscribes to the Redis cache database based on Topic-A. Then, when the external processing system publishes the road condition information to the Redis cache database based on Topic-A, since the management server subscribes to the Redis cache database based on Topic-A, the Redis cache database will publish the road condition information to the management server. After the management server obtains the road condition information, it accurately sends the road condition information to vehicle A. Vehicle A can choose the appropriate driving method based on the road condition information.
[0081] In summary, in the communication method, communication system and server of the communication system of the embodiment of the present application, for a distributed environment in which multiple protocol clients 300 respectively establish communication connections with the protocol server 100 based on the WebSocket protocol, the protocol server 100 generates a subscription identifier associated with the target protocol client 300, and subscribes to the cache database of the communication system according to the subscription identifier, and the target protocol client 300 is one of the multiple protocol clients 300. Then, the protocol server 100 obtains the target data from the cache database according to the subscription identifier to accurately send the target data to the target protocol client 300, wherein the target data is published to the cache database by the application server 200 according to the subscription identifier. In this way, the management and routing of WebSocket long links in a distributed environment are realized, and the accuracy and efficiency of target data transmission are improved. In addition, a communication connection is established between the protocol server 100 and the protocol client 300 based on the WebSocket protocol, and data can be continuously transmitted without interrupting the connection until one of the parties closes the connection, reducing network delay and bandwidth consumption, and improving the efficiency of target data transmission.
[0082] See also Figure 3 In some embodiments, step 011 (generating a subscription identifier associated with a target protocol client) includes:
[0083] 0111: Generate a subscription identifier associated with the target protocol client based on preset information.
[0084] In some implementations, the generation module is further configured to generate a subscription identifier associated with the target protocol client based on preset information.
[0085] In some implementations, the processor is further configured to generate a subscription identifier associated with the target protocol client based on preset information.
[0086] Specifically, the preset information includes client information of the target protocol client 300, geographic location information of the target protocol client 300, device information of the target protocol client 300 and / or network information of the target protocol client 300. Client information refers to account information of the target protocol client 300 such as account number, name, etc., such as the account of the vehicle owner. Geographic location information refers to the geographic location of the current target protocol client 300, such as the current location of the vehicle. Device information refers to information such as the device type of the target protocol client 300, such as the vehicle model, etc. Network information refers to information such as the current network connection status of the target protocol client 300, such as whether the vehicle's network connection is in good condition, etc.
[0087] When generating a subscription identifier associated with the target protocol client 300, it can be based on different preset information. Generating a subscription identifier based on different preset information means binding the subscription identifier with different preset information.
[0088] When the subscription identifier is bound to the account information, the cache database is subscribed according to the subscription identifier, published to the cache database, and the target message corresponding to the subscription identifier will be delivered to the target protocol client 300 .
[0089] When the subscription identifier is bound to the geographic location information, it can help the communication system provide location-based services, such as nearby restaurant recommendations, traffic information, weather services, etc., thereby improving the user experience.
[0090] When the subscription identifier is bound to the device information, the communication system can provide customized services according to the device type of the target protocol client 300. For example, suitable interfaces and functions can be provided for vehicles of different models.
[0091] When the subscription identifier is bound to the network information, the communication system sends the target data to the target protocol client 300 when the network connection status of the target protocol client 300 is good.
[0092] Continuing with the above example, the management server generates Topic-A associated with vehicle A based on the geographic location information of vehicle A. As the geographic location information of vehicle A changes, the management server receives road condition information near the geographic location of the geographic location information in real time.
[0093] In this way, suitable preset information can be selected for different application scenarios and associated with the generated subscription identifier, so as to identify and classify protocol clients and achieve more accurate data distribution.
[0094] See also Figure 4 In some embodiments, step 011 (generating a subscription identifier associated with a target protocol client) includes:
[0095] 0112: Generate multiple subscription identifiers associated with the target protocol client.
[0096] In some implementations, the generation module is used to generate a plurality of subscription identifiers associated with the target protocol client.
[0097] In some embodiments, the processor is further configured to generate a plurality of subscription identifiers associated with the target protocol client.
[0098] Specifically, the protocol server 100 generates a plurality of subscription identifiers associated with the target protocol client 300, each subscription identifier being used to identify a target data category.
[0099] Continuing with the above example, when establishing a WebSocket connection with vehicle A, the management server generates multiple Topics associated with vehicle A, such as Topic-A for identifying road condition information, Topic-B for identifying traffic flow information, and Topic-C for signal light status information. Based on different Topics, vehicle A can obtain corresponding data according to actual needs.
[0100] In this way, the protocol server 100 can receive target data categories corresponding to different subscription identifiers, and achieve efficient and targeted target data delivery. In addition, the protocol server 100 can generate or delete subscription identifiers of different target data categories according to the needs of the protocol client 300, and achieve flexible delivery of target data.
[0101] See also Figure 5 In some implementations, step 012 (subscribing to a cache database of a communication system according to a subscription identifier) includes:
[0102] 0121: Get the association relationship between the target protocol client and the subscription identifier according to the subscription identifier;
[0103] 0122: Subscribe to the associated channel corresponding to the associated relationship in the cache database.
[0104] In some implementations, the processing module is further used to obtain the association relationship between the target protocol client and the subscription identifier according to the subscription identifier. The subscription module is used to subscribe to the associated channel corresponding to the association relationship in the cache database.
[0105] In some implementations, the processor is further configured to obtain, according to the subscription identifier, an association relationship between the target protocol client and the subscription identifier, and an associated channel corresponding to the association relationship in the subscription cache database.
[0106] Specifically, an associated channel refers to a logical concept in the cache database used to identify different message flows or topics, and has no physical meaning, that is, it does not occupy any physical resources, such as memory or storage space.
[0107] The protocol server 100 obtains the association relationship between the target protocol client 300 and the subscription identifier according to the subscription identifier, and subscribes to the associated channel corresponding to the association relationship in the cache database. After the protocol server 100 subscribes to the associated channel, if data is sent to the associated channel, the cache database will automatically send the data to all subscribers who have subscribed to the associated channel. The associated channel is dynamically created and destroyed.
[0108] Continuing with the above example, the management server obtains the association relationship between vehicle A and Topic-A based on Topic-A. The Redis cache database creates a corresponding associated channel A-Topic in itself based on the association relationship, and the management server subscribes to the associated channel A-Topic. After the external processing system sends the road condition information to the associated channel A-Topic, the Redis cache database will send the road condition information directly to all vehicles that have subscribed to the associated channel A-Topic. That is to say, if Topic-A is generated based on geographic location information, then vehicles that can receive the road condition information that the Redis cache database will send need to meet the following conditions: they are in the geographic location corresponding to the geographic location information and have subscribed to the associated channel A-Topic.
[0109] In this way, the protocol server 100 can obtain the target data published to the associated channel in the subsequent process by subscribing to the associated channel. In addition, the target data published to the associated channel will only be transmitted to the protocol server 100 that has subscribed to the associated channel, thereby reducing unnecessary network communications and improving the performance of the communication system.
[0110] See also Figure 6 In some implementations, step 013 (obtaining target data from the cache database according to the subscription identifier) includes:
[0111] 0131: Get target data from cache database according to associated channel.
[0112] In some implementations, the acquisition module is further configured to acquire target data from a cache database according to the associated channel.
[0113] In some implementations, the processor is further configured to obtain target data from a cache database according to the associated channel.
[0114] Specifically, the protocol server 100 obtains the target data from the cache database according to the associated channel. After the protocol server 100 subscribes to the associated channel in the cache database, if there is target data sent to the associated channel, the cache database will immediately send the target data to the protocol server 100.
[0115] Continuing with the above example, after the management server subscribes to the associated channel A-Topic, once data is sent to the associated channel A-Topic, the Redis cache database will send the data to the management server. In some embodiments, the associated channel A-Topic can be subscribed by multiple management servers, and the road condition information published to the associated channel A-Topic is sent to all management servers that have subscribed to the associated channel A-Topic.
[0116] In this way, the protocol server 100 can obtain the target data published to the associated channel from the cache database through the associated channel, thereby achieving accurate delivery of the target data.
[0117] See also Figure 7 In some embodiments, the method further comprises:
[0118] 014: Establish a communication connection with the target protocol client based on the WebSocket protocol, and generate a session identifier associated with the target protocol client;
[0119] 015: Send target data to the target protocol client according to the session identifier.
[0120] In some embodiments, the generating module is used to establish a communication connection with the target protocol client based on the WebSocket protocol and generate a session identifier associated with the target protocol client. The sending module is used to send target data to the target protocol client according to the session identifier.
[0121] In some embodiments, the processor is further configured to establish a communication connection with a target protocol client based on the WebSocket protocol, generate a session identifier associated with the target protocol client, and send target data to the target protocol client according to the session identifier.
[0122] Specifically, the session identifier is used to identify the protocol client 300. The protocol server 100 establishes a communication connection with the target protocol client 300 based on the WebSocket protocol, and generates a session identifier associated with the target protocol client 300. Then, the protocol server 100 sends the target data to the target protocol client 300 according to the session identifier. Figure 8 , Figure 8 It is a schematic diagram of the correspondence between protocol clients and identifiers, wherein one subscription identifier can correspond to multiple session identifiers and multiple protocol clients respectively, and one protocol client corresponds to one session identifier.
[0123] Continuing with the above example, when the management server establishes a WebSocket connection with vehicle A, it generates a session identifier session-A, which is used to identify the communication connection between the management server and vehicle A. When the management server obtains the road condition information that needs to be delivered to vehicle A from the Redis cache database, the management server can accurately send the road condition information to vehicle A among multiple vehicles that have established WebSocket connections with the management server through the session identifier session-A.
[0124] In this way, through the generated session identifier, the protocol server 100 can identify the target protocol client 300 and transfer the target data to the target protocol client 300, thereby achieving accurate transfer of the target data.
[0125] See also Fig. 9 The embodiment of the present application provides a communication method of a communication system, the communication system includes a protocol server, an application server and a plurality of protocol clients, the method is used for the application server, and the method includes:
[0126] 021: Publish the target data to the cache database of the communication system according to the subscription identifier, so that the protocol server obtains the target data from the cache database according to the subscription identifier and sends the target data to the target protocol client.
[0127] The embodiment of the present application also provides a server, including a memory and a processor. The resource access method of the embodiment of the present application can be implemented by the server of the embodiment of the present application. Specifically, a computer program is stored in the memory, and the processor is used to publish the target data to the cache database of the communication system according to the subscription identifier, so that the protocol server obtains the target data from the cache database according to the subscription identifier, and sends the target data to the target protocol client.
[0128] The embodiment of the present application also provides an application server communication device. The resource access method of the embodiment of the present application can be implemented by the application server communication device of the embodiment of the present application. Specifically, the application server communication device includes a publishing module. The publishing module is used to publish the target data to the cache database of the communication system according to the subscription identifier, so that the protocol server obtains the target data from the cache database according to the subscription identifier, and sends the target data to the target protocol client.
[0129] The embodiment of the present application also provides a communication system 1000 , which includes a protocol server 100 , an application server 200 and a plurality of protocol clients 300 .
[0130] Among them, the protocol server 100 is configured to generate a subscription identifier associated with a target protocol client, the target protocol client is one of a plurality of protocol clients 300, each protocol client 300 respectively establishes a communication connection with the protocol server 100 based on the WebSocket protocol, and subscribes to a cache database of the communication system 1000 according to the subscription identifier, and obtains target data from the cache database according to the subscription identifier to send the target data to the target protocol client.
[0131] The application server 200 is configured to publish the target data to the cache database according to the subscription identifier.
[0132] Specifically, the communication method of the communication system of this embodiment is basically the same as the communication method of the communication system in the aforementioned embodiment with the protocol server as the execution object. For details, please refer to the explanation of the corresponding part. The difference is that this embodiment takes the application server as the execution object, which will not be repeated here.
[0133] In summary, in the communication method, communication system and server of the communication system of the embodiment of the present application, for a distributed environment in which multiple protocol clients 300 respectively establish communication connections with the protocol server 100 based on the WebSocket protocol, the protocol server 100 generates a subscription identifier associated with the target protocol client 300, and subscribes to the cache database of the communication system according to the subscription identifier, and the target protocol client 300 is one of the multiple protocol clients 300. Then, the protocol server 100 obtains the target data from the cache database according to the subscription identifier to accurately send the target data to the target protocol client 300, wherein the target data is published to the cache database by the application server 200 according to the subscription identifier. In this way, the management and routing of WebSocket long links in a distributed environment are realized, and the accuracy and efficiency of target data transmission are improved. In addition, a communication connection is established between the protocol server 100 and the protocol client 300 based on the WebSocket protocol, and data can be continuously transmitted without interrupting the connection until one of the parties closes the connection, reducing network delay and bandwidth consumption, and improving the efficiency of target data transmission.
[0134] See also Fig.10 In some implementations, step 021 (publishing the target data to the cache database according to the subscription identifier) includes:
[0135] 0211: Obtain the association between the target protocol client and the subscription identifier from the cache database;
[0136] 0212: Publish target data to the cache database based on the subscription identifier.
[0137] In some implementations, the acquisition module is used to acquire the association relationship between the target protocol client and the subscription identifier from the cache database. The publishing module is used to publish the target data to the cache database according to the subscription identifier.
[0138] In some implementations, the processor is further configured to obtain an association between the target protocol client and the subscription identifier from the cache database, and publish the target data to the cache database according to the subscription identifier.
[0139] Specifically, the application server 200 obtains the association relationship between the target protocol client 300 and the subscription identifier from the cache database, and publishes the target data to the cache database according to the association relationship.
[0140] Continuing with the above example, when the external processing system needs to send road condition information to vehicle A, the external processing system first obtains the association relationship corresponding to vehicle A from the Redis cache database, which refers to the association relationship between vehicle A and subscription identifier Topic-A. Then, the external processing system publishes the road condition information to the Redis cache database based on the association relationship.
[0141] In this way, the external processing system obtains the association relationship from the cache database and publishes the target data to the cache database according to the association relationship, thereby achieving efficient and accurate target data delivery and helping to improve the efficiency of the communication system.
[0142] See also Fig.11 In some implementations, step 0212 (publishing target data to the cache database according to the subscription identifier) includes:
[0143] 02121: Publish target data to associated channels.
[0144] In some implementations, the publishing module is used to publish the target data to an associated channel.
[0145] In some embodiments, the processor is further configured to publish the target data to an associated channel.
[0146] Specifically, the application server 200 publishes the target data to an associated channel, where the associated channel is used to indicate a channel in the cache database that corresponds to the association relationship between the target protocol client 300 and the subscription identifier.
[0147] Continuing with the above example, the external processing system sends road condition information to vehicle A, which means the external processing system routes the road condition information to the corresponding associated channel A-Topic in the Redis cache database. The associated channel A-Topic is used to indicate the channel in the Redis cache database that corresponds to the association relationship between vehicle A and the subscription identifier Topic.
[0148] In this way, by publishing the target data to the associated channel, the cache database will publish the target data to the protocol server 100 that has subscribed to the associated channel, thereby achieving accurate delivery of the target data, which helps to improve the performance of the communication system.
[0149] The following is a complete description of the above example:
[0150] Please refer to Figure 2, the management server and vehicle A establish a communication connection based on the WebSocket protocol, and the management server generates a subscription identifier Topic-A and a session identifier session-A. Among them, the subscription identifier Topic-A is generated based on the geographic location information of vehicle A. For example, if vehicle A establishes a WebSocket connection with the management server of city B in city B, then vehicle A can receive the data information identified by the subscription identifier Topic-A sent by the management server only within the scope of city B. The session identifier session-A is an identifier generated when the management server establishes a connection with vehicle A. It is used to identify the communication between the management server and vehicle A, and can accurately send road condition information to vehicle A among multiple vehicles that communicate with the management server through WebSocket.
[0151] After generating the subscription identifier Topic-A, the management server binds the subscription identifier to the data information category required by vehicle A. For the convenience of explanation, the subscription identifier Topic-A is bound to the road condition information.
[0152] Next, the management server will also obtain the association relationship between vehicle A and subscription identifier Topic-A based on the subscription identifier Topic-A. In the Redis cache database, there will also be an association channel A-Topic corresponding to the association relationship, and this association channel A-Topic receives road condition information. Then, the management server will subscribe to the association channel A-Topic, so that the road condition information received by the association channel A-Topic will be sent to the management server. In some embodiments, if other management servers have also subscribed to the association channel A-Topic, then the road condition information received by the association channel A-Topic will be published to all management servers that have subscribed to the association channel A-Topic.
[0153] When the external processing system needs to send the collected road condition information to vehicle A, it obtains the association relationship between vehicle A and subscription identifier Topic-A from the Redis cache database, thereby obtaining the associated channel A-Topic subscribed by the management server. Then, the road condition message is published to the associated channel A-Topic. After the associated channel A-Topic receives the road condition information, it publishes the road condition information to the management server subscribed to the associated channel A-Topic.
[0154] After receiving the road condition information, the management server understands that the road condition information is to be sent to vehicle A because it is sent by the associated channel A-Topic. The management server finds the corresponding session identifier session-A based on the local cache information and sends the road condition information to vehicle A.
[0155] The present application also provides a computer-readable storage medium containing a computer program. When the computer program is executed by one or more processors, the one or more processors execute the method of the present application.
[0156] It is understood that a computer program includes computer program code. The computer program code may be in source code form, object code form, executable file or some intermediate form. Computer readable storage media may include: any entity or device capable of carrying computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), and software distribution medium.
[0157] In the description of this specification, the descriptions with reference to the terms "specifically", "further", "particularly", "understandably", etc. are intended to mean that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms are not intended to refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.
[0158] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0159] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A communication method of a communication system, characterized in that: The communication system includes a protocol server, an application server and a plurality of protocol clients, and the method is used for the protocol server, and the method includes: Generate a subscription identifier associated with a target protocol client, where the target protocol client is one of a plurality of the protocol clients, and each of the protocol clients establishes a communication connection with the protocol server based on the WebSocket protocol; subscribing to a cache database of the communication system according to the subscription identifier; The target data is obtained from the cache database according to the subscription identifier to send the target data to the target protocol client, wherein the target data is published to the cache database by the application server according to the subscription identifier.
2. The method according to claim 1, characterized in that: The generating of a subscription identifier associated with a target protocol client includes: A subscription identifier associated with the target protocol client is generated based on preset information, wherein the preset information includes client information of the target protocol client, geographic location information of the target protocol client, device information of the target protocol client and / or network information of the target protocol client.
3. The method according to claim 1, characterized in that The generating of a subscription identifier associated with a target protocol client includes: A plurality of subscription identifiers associated with the target protocol client are generated, each of the subscription identifiers being used to identify a target data category.
4. The method according to claim 1, characterized in that: The step of subscribing to a cache database of the communication system according to the subscription identifier comprises: Obtaining an association relationship between the target protocol client and the subscription identifier according to the subscription identifier; Subscribe to the associated channel corresponding to the associated relationship in the cache database.
5. The method according to claim 4, characterized in that The acquiring target data from the cache database according to the subscription identifier includes: The target data is obtained from the cache database according to the associated channel.
6. The method according to claim 1, characterized in that The method further comprises: Establishing a communication connection with the target protocol client based on the WebSocket protocol, and generating a session identifier associated with the target protocol client; The target data is sent to the target protocol client according to the session identifier.
7. A communication method of a communication system, characterized in that: The communication system includes a protocol server, an application server and a plurality of protocol clients, and the method is used for the application server, and the method includes: The target data is published to the cache database of the communication system according to the subscription identifier, so that the protocol server obtains the target data from the cache database according to the subscription identifier and sends the target data to the target protocol client, wherein the subscription identifier is generated by the protocol server and is associated with the target protocol client, the target protocol client is one of multiple protocol clients, and each of the protocol clients establishes a communication connection with the protocol server based on the WebSocket protocol.
8. The method according to claim 7, characterized in that The step of publishing the target data to the cache database according to the subscription identifier includes: Acquire the association relationship between the target protocol client and the subscription identifier from the cache database; The target data is published to the cache database according to the association relationship.
9. The method according to claim 8, characterized in that The publishing the target data to the cache database according to the association relationship includes: The target data is published to an associated channel, where the associated channel is used to indicate a channel in the cache database corresponding to the association relationship between the target protocol client and the subscription identifier.
10. A communication system, characterized in that: The communication system includes a protocol server, an application server and a plurality of protocol clients; The protocol server is configured to: generate a subscription identifier associated with a target protocol client, the target protocol client is one of a plurality of the protocol clients, and each of the protocol clients establishes a communication connection with the protocol server based on the WebSocket protocol; subscribing to a cache database of the communication system according to the subscription identifier; Acquire target data from the cache database according to the subscription identifier, so as to send the target data to the target protocol client; The application server is configured to publish the target data to the cache database according to the subscription identifier.
11. A server, characterized in that: The server includes a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the method according to any one of claims 1 to 6 or the method according to any one of claims 7 to 9 is implemented.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium memory stores a computer program, and when the computer program is executed by one or more processors, the method according to any one of claims 1 to 9 is implemented.
