Communication control method and device, equipment, program product and storage medium
By maintaining a long connection between the client and the server, the problems of frequent disconnection and security risks in the existing communication mode are solved, and efficient and secure real-time communication is achieved.
Patent Information
- Application Number
- CN202510159078.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-13
- Publication Date
- 2025-05-16
AI Technical Summary
In the existing communication mode, the connection between the client and the server is frequently disconnected, which cannot meet the real-time requirements, increases connection and communication overhead, and opens network ports to increase security risks.
Receive the client's connection request through the preset communication protocol, determine the target server based on the server resource information, and realize real-time communication between the client and the server by maintaining a long connection until the connection is disconnected when the connection is disconnected.
It realizes that the port is not opened in the client environment, only establishes connections when needed, and maintains long connections, improving the security and efficiency of communication and reducing communication overhead.
Smart Images

Figure CN120017710A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of communication technology, and in particular, to a communication control method, apparatus, device, program product, and storage medium. Background Art
[0002] In the current field of network communications, real-time, efficient and secure data transmission between clients and servers is crucial.
[0003] Most current communication modes are based on the Hypertext Transfer Protocol (HTTP), which is essentially a request-response mode, meaning that the client must actively initiate a request to obtain data. In this mode, the client and server are frequently disconnected, which makes it unable to meet certain data transmission tasks with high real-time requirements, and increases the connection and communication overhead between the client and the server. In addition, in this current communication mode, in order to achieve communication between the client and the server, certain network ports need to be opened, and opening ports will increase the risk of the server or client being exposed to external attacks to a certain extent. Summary of the invention
[0004] The embodiments of the present invention provide a communication control method, apparatus, device, program product and storage medium, which can meet the requirements of not opening ports in the client environment, establishing connections only when needed and maintaining connections for a certain period of time, while achieving real-time communication between the client and the server, improving the security and efficiency of the communication process between the client and the server, and reducing communication overhead.
[0005] In a first aspect, an embodiment of the present invention provides a communication control method, including:
[0006] Receive a connection request sent by a client through a preset communication protocol;
[0007] In response to the connection request, determining a target server of the connection request based on the connection request and resource information of each server at a current moment;
[0008] Connect to the target server, and control the client and the target server to communicate data through the preset communication protocol until a connection disconnection request sent by the target server or the client is received, and then disconnect the connection between the target server and the client.
[0009] In a second aspect, an embodiment of the present invention provides a communication control device, the device comprising:
[0010] An information receiving module, used to receive a connection request sent by a client through a preset communication protocol;
[0011] An information determination module, configured to respond to the connection request and determine a target server of the connection request based on the connection request and resource information of each server at a current moment;
[0012] The communication control module is used to connect to the target server and control the client and the target server to communicate data through the preset communication protocol until a connection disconnection request sent by the target server or the client is received, and then the connection between the target server and the client is disconnected.
[0013] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a communication control method as described in any one of the embodiments of the present invention is implemented.
[0014] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a communication control method as described in any one of the embodiments of the present invention.
[0015] In a fifth aspect, an embodiment of the present invention provides a computer program product, including a computer program, which, when executed by a processor, implements a communication control method as described in any one of the embodiments of the present invention.
[0016] In an embodiment of the present invention, a connection request sent by a client is received through a preset communication protocol; in response to the connection request, a target server of the connection request is determined based on the connection request and resource information of each server at the current moment; the target server is connected, and the client and the target server are controlled to communicate data through the preset communication protocol until a connection disconnection request sent by the target server or the client is received, and the connection between the target server and the client is disconnected. The method of the embodiment of the present invention connects the client and the server through a proxy server, so that the communication between the client and the server is realized while the port is not opened in the client environment, the connection is established only when needed, and the connection is maintained for a certain period of time. By presetting the communication protocol, the client and the server can maintain a long connection, making data transmission more efficient, reducing the time for connection establishment, and enabling communication resources to be used more effectively, reducing waste of resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 A first flow chart of a communication control method provided by an embodiment of the present invention;
[0019] Figure 2 A second flow chart of a communication control method provided by an embodiment of the present invention;
[0020] Figure 3 A schematic diagram of the structure of the client, proxy server and each server provided in an embodiment of the present invention;
[0021] Figure 4 A schematic diagram of the structure of a communication control device provided by an embodiment of the present invention;
[0022] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0023] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0024] Figure 1The first flow chart of a communication control method provided by an embodiment of the present invention. The method of the embodiment of the present invention can meet the requirements of not opening ports in the client environment, establishing connections only when needed, and maintaining connections for a certain period of time, while achieving real-time communication between the client and the server, improving the security and efficiency of the communication process between the client and the server, and reducing communication overhead. The information collected in the method of the embodiment of the present invention is information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data comply with the relevant laws, regulations and standards of relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse. The method can be executed by a communication control device provided by an embodiment of the present invention, and the device can be implemented in software and / or hardware. The following embodiments will be described by taking the device integrated in an electronic device as an example. The electronic device can be a proxy server or a computer device equipped with a virtual proxy server, etc., refer to Figure 1 , the method may specifically include the following steps:
[0025] Step 101: Receive a connection request sent by a client through a preset communication protocol.
[0026] Among them, the preset communication protocol is a network communication protocol. The network communication protocol is a standardized specification used to specify the method and format of data transmission in a computer network. The network communication protocol can ensure effective communication between different operating systems and hardware devices. The preset communication protocol in this scheme can be a network socket (WebSocket) communication protocol, and the proxy server can use the WebSocket communication protocol to connect the client and the corresponding server. The proxy server is an intermediate server between the client and the server. The proxy server can be a virtual server built on a physical device or a separate physical server. Specifically, when a client (such as a browser) needs to access a certain network resource, the client can send a connection request to the proxy server, and the connection request contains a specific header field (such as WebSocket). The proxy server can receive the connection request sent by the client through the WebSocket communication protocol, so as to connect to the target server corresponding to the request according to the connection request.
[0027] Step 102: In response to the connection request, based on the connection request and resource information of each server at the current moment, determine the target server of the connection request.
[0028] Among them, the target server is a server suitable for responding to the connection request. The resource information of each server includes the load information, geographical location and response time of each server. After receiving the connection request sent by the client, the proxy server can use a load balancing algorithm to determine the server that is most suitable for responding to the connection request, that is, the target server. The goal of load balancing is to evenly distribute requests to multiple servers to achieve high availability, scalability and performance optimization. Exemplarily, the proxy server can distribute the connection request to each server in a certain order. Alternatively, the proxy server can determine the weight of each server according to the processing power or capacity of each server, and when receiving the connection request, the server with the highest weight at the current moment is determined as the target server. Alternatively, the proxy server can also obtain the number of connections of each server at the current moment, and determine the server with the least number of connections as the target server. When selecting the target server, the proxy server can also consider other factors, such as geographical location, response time, etc. For example, if the network delay between the client and the server is high, the proxy server can select a server that is closer as the target server to reduce the impact of network delay on performance.
[0029] In an optional implementation, after receiving a connection request, the proxy server determines the requesting server based on the connection request and obtains the resource load information of the requesting server at the current moment; if the resource load information of the requesting server meets the preset conditions, the requesting server is determined to be the target server; if the resource load information of the requesting server does not meet the preset conditions, the request type of the connection request is determined; based on the request type, the load weight of the load information, the location weight of the geographical location and the duration weight of the response time are determined; and the target server is determined based on the load weight, location weight, duration weight and resource information of each other server.
[0030] Step 103: connect to the target server, and control the client and the target server to communicate data through a preset communication protocol until a disconnection request sent by the target server or the client is received, and then disconnect the connection between the target server and the client.
[0031] Specifically, the preset communication protocol in this solution can be a WebSocket communication protocol, which can maintain a long connection, that is, after the proxy server connects to the client and the target server, it will not only forward the connection request once and then disconnect, but can maintain the connection and forward the client's data request in real time until it receives a connection disconnection request sent by the target server or the client, and then disconnects the connection between the target server and the client. In this solution, optionally, controlling the client and the target server to communicate data through a preset communication protocol includes: receiving a data transmission request sent by the client based on the preset communication protocol; sending the data transmission request to the target server, and obtaining the target data determined by the target server based on the data transmission request; and sending the target data to the client.
[0032] Among them, the data transmission request is a request sent by the client to the proxy server to transmit data or obtain a specific service. In the WebSocket communication protocol, the data transmission request can be a request to open a connection or a specific data request sent after the connection is established. The target data is the data determined by the server and returned to the client based on the data transmission request forwarded by the proxy server. After determining the target server corresponding to the client's connection request, the proxy server can receive the data transmission request sent by the client based on the WebSocket communication protocol. After receiving the data transmission request, the proxy server sends the data transmission request to the target server. After receiving the data transmission request, the target server parses the data transmission request content and performs corresponding operations according to the type and content of the data transmission request to obtain the target data. For example, the server can determine the target data based on the client's request type and the server's own processing logic. The target data can be query results, file content, or calculation results.
[0033] In the process of controlling the client and the target server to communicate data through the WebSocket communication protocol, the proxy server can maintain the connection with the client and the target server, forward the message of the client or the target server in real time and continuously, until the connection disconnection request sent by the target server or the client is received, and the connection between the target server and the client is disconnected. Exemplarily, user A sends a connection request to the proxy server through the WebSocket protocol on the online chat application of the client. After the proxy server receives the connection request, it determines user B as the request object, that is, the target server, according to the connection request of user A. The proxy server establishes a WebSocket connection with the target server, that is, a communication channel is indirectly established between user A and user B through the proxy server. After the communication channel is established, user A sends a message on the online chat application, and the online chat application encapsulates the message into a WebSocket data frame and sends it to the proxy server through the established WebSocket connection. After the proxy server receives the message sent by user A, it forwards the message to the target server according to the previously established connection relationship. After the online chat application of user B (target server) receives the message, user B encapsulates the reply message into a WebSocket data frame in the online chat application of the target client and sends it to the proxy server through the WebSocket connection. After the proxy server receives the reply message from user B, it forwards it to user A. During the entire chat process, the proxy server maintains the connection with user A and user B through the WebSocket protocol, and forwards the messages of both parties in real time without frequently establishing and disconnecting the connection. User A and user B can chat continuously, and the transmission of messages is bidirectional and real-time, and both parties can see each other's replies in time. When user A or user B wants to end the chat, they can send a connection disconnection request to the proxy server through the chat application. For example, when user A clicks the "End Chat" button in the chat application, the application encapsulates the disconnection request into a WebSocket data frame and sends it to the proxy server. After receiving the connection disconnection request, the proxy server sends a disconnection signal to user A and user B respectively, disconnecting the connection with the target server (user B) and the client (user A).
[0034] In the above steps, the proxy server can transmit data between the client and the server in real time based on the WebSocket communication protocol, meeting the needs of real-time communication. By maintaining a long connection, data transmission is more efficient, reducing the time to establish a connection, thereby providing a faster and more instant data transmission experience.
[0035] The technical solution of this embodiment receives a connection request sent by a client through a preset communication protocol; in response to the connection request, determines the target server of the connection request based on the connection request and the resource information of each server at the current moment; connects to the target server, and controls the client and the target server to communicate data through the preset communication protocol until a connection disconnection request sent by the target server or the client is received, and then disconnects the connection between the target server and the client. The technical solution of this embodiment connects the client and the server through a proxy server, so that the communication between the client and the server is realized while the port is not opened in the client environment, the connection is established only when needed, and the connection is maintained for a certain period of time. Through the preset communication protocol, the client and the server can maintain a long connection, making data transmission more efficient, reducing the time for connection establishment, and enabling communication resources to be used more effectively, reducing resource waste.
[0036] Figure 2 The second flow chart of a communication control method provided by an embodiment of the present invention is a refinement of the above embodiment. The specific method can be as follows Figure 2 As shown, the method may include the following steps:
[0037] Step 201: Receive a connection request sent by a client through a preset communication protocol.
[0038] Step 202: In response to the connection request, determine the requesting server based on the connection request, and obtain resource load information of the requesting server at the current moment.
[0039] Among them, the request server is the server to which the connection request is to connect, and the resource load information includes the number of connections on the server: the number of connections currently established by the request server. The number of connections can reflect the concurrent processing capability of the server. If the number of connections is too high, it means that the server is heavily loaded and cannot effectively process new requests; CPU usage: The CPU usage reflects the computing resource occupancy of the server. If the CPU usage is too high, it means that the server is performing a large number of computing tasks, which may affect the processing speed of new requests; Memory usage: The memory usage of the server can reflect the data storage and processing capabilities of the server. If the memory usage is close to or reaches the upper limit, it may cause the server to be unable to allocate enough memory resources for new requests, thereby affecting the processing of requests; Network bandwidth usage: The proportion of network bandwidth currently used by the server. The network bandwidth usage can reflect the network transmission capability of the server. If the network bandwidth usage is too high, it may cause data transmission congestion and affect the communication quality between the client and the server.
[0040] After receiving the connection request, the proxy server parses the connection request, determines the request server to which the connection request is to connect, and obtains the resource load information of the request server at the current moment, so as to determine the target server based on its resource load information. In this solution, before executing the step of obtaining the resource load information of the request server at the current moment, the client can be authenticated to determine whether it has the authority to connect to the request server. Optionally, after determining the request server based on the connection request, the following steps A1-A2 are also included:
[0041] Step A1: sending an identity authentication request to a client, and obtaining authentication information sent by the client based on the identity authentication request; determining the request authority of the client based on the authentication information, and determining an available server for the client based on the request authority.
[0042] Among them, the authentication request is a request sent by the proxy server to the client for authenticating the client. The authentication information is the identity information sent by the client to the proxy server according to the authentication request. The available servers are all the servers that the client can access, determined by the proxy server according to the authentication information of the client. Specifically, after determining the request server, the proxy server sends an authentication request to the client. After receiving the authentication request, the client provides corresponding authentication information such as user name, password or digital certificate according to the request content, and sends it back to the proxy server. After receiving the authentication information of the client, the proxy server verifies the authentication information, obtains the verification result, and determines the client's request authority according to the verification result, including the range of servers that the client can access (available servers), the types of operations that can be performed, and the amount of resources that can be used.
[0043] Step A2: If the available servers do not include the request server, a request failure prompt message is sent to the client; if the available servers include the request server, a step of obtaining resource load information of the request server at the current moment is executed.
[0044] After determining the available servers, determine whether the requested server is included in the available servers. If the requested server is included in the available servers, it means that the client has the right to access the requested server. Further, perform the step of obtaining the resource load information of the requested server at the current moment to prepare for subsequent connection establishment and server selection. If the requested server is not included in the available servers, it means that the client does not have the right to access the requested server, or the requested server cannot meet the client's request requirements. In this case, the proxy server can send a request failure prompt message to the client, thereby informing the client that it cannot connect to the requested server and the reason for the failure to connect.
[0045] By sending an authentication request to the client and obtaining authentication information, the proxy server can determine the client's request permissions based on the authentication information. The available servers of the client are determined based on the client's request permissions, and the servers that the client has access to can be screened out. This avoids the situation where the client's request is assigned to an inappropriate server or a server that cannot meet the requirements, thereby improving the reasonable allocation and utilization efficiency of resources.
[0046] Step 203: If the resource load information of the requesting server meets the preset conditions, the requesting server is determined to be the target server.
[0047] Among them, the preset conditions are pre-determined based on domain big data, etc., and are used to determine whether the requesting server can respond to the connection request normally. The resource load information includes the number of connections, CPU usage, memory usage, and network bandwidth usage of the server. The preset conditions may include the preset number of connections, the preset CPU usage, the preset memory usage, and the preset network bandwidth usage. If the resource load information of the requesting server meets the preset conditions, for example, the number of connections of the server is less than the preset number of connections, the CPU usage is less than the preset CPU usage, the memory usage is less than the preset memory usage, or the network bandwidth usage is less than the preset network bandwidth usage, then the requesting server is determined to be the target server.
[0048] Step 204: If the resource load information of the requesting server does not meet the preset conditions, the target server is determined according to the resource information of other servers at the current moment.
[0049] Specifically, if the resource load information of the requesting server does not meet the preset conditions, it means that the requesting server may not send a normal response to the client's connection request. Further, the proxy server can determine the target server from other available servers. In this scheme, optionally, the target server is determined based on the resource information of other servers at the current moment, including: determining the load weight, location weight and duration weight corresponding to the connection request based on preset weight information; determining the target server based on the load weight, location weight, duration weight and resource information of each other server.
[0050] Among them, resource information includes load information, geographic location and response time. Load information includes the number of connections, CPU usage, memory usage and network bandwidth usage of the server. Geographic location indicates the geographical location information of the server, such as a city or data center. Geographic location information can be used to evaluate the distance between the client and the server, thereby determining the delay and speed of data transmission based on the distance. Response time is the average response time of the server to the request, and the response time can reflect the processing efficiency and performance of the server. The preset weight information is the predetermined resource weights corresponding to each type of connection request.
[0051] Specifically, different types of connection requests require different server resource conditions, so different types of connection requests correspond to different load weights, location weights, and duration weights. The proxy server can determine the load weight, location weight, and duration weight corresponding to the connection request in the preset weight information. For example, some types of requests require the server to have higher processing power and lower load to ensure real-time transmission and processing of data, and the corresponding load weight is higher. After determining the load weight, location weight, and duration weight of the connection request, the applicability of each available server is comprehensively evaluated and compared based on the load weight, location weight, duration weight, and resource information of other available servers obtained, and the target server is determined based on the practicality of each available server. For example, using a weighted scoring method, the load information, geographic location, and response time of each available server are multiplied by the corresponding weights, and then the sum is obtained to obtain the comprehensive score of each server, and the server with the highest comprehensive score is used as the target server.
[0052] Through the above steps, the proxy server can intelligently select other suitable servers as the target server when the request server cannot meet the conditions, ensuring that the client's request can be processed in a timely and effective manner, thereby improving overall availability and performance.
[0053] For example, Figure 3 The schematic diagram of the structure of the client, proxy server and each server provided in the embodiment of the present invention. Figure 3 As shown, the proxy server is connected to the client, and the client sends a connection request to the proxy server. The proxy server is connected to multiple servers at the same time, determines the target server according to the connection request, and controls the client and the target server to communicate data through a preset communication protocol.
[0054] Step 205: Determine the requested application type corresponding to the connection request.
[0055] Among them, the application type is a real-time type or a scheduled type. The request application type corresponding to the connection request can be the type of the application that issued the connection request, for example, the type of online chat is a real-time type. Real-time type applications refer to applications that need to be processed and responded to immediately after data is generated or an event occurs. Real-time type applications are time-sensitive and require data transmission and processing to have high real-time performance to ensure the timeliness and effectiveness of information. Scheduled type applications are applications that do not require real-time processing and response, but are executed according to pre-set time intervals or trigger conditions. Scheduled type applications are relatively less sensitive to time, and data transmission and processing can be performed according to a certain plan or cycle.
[0056] Step 206: When the application type is real-time, connect to the target server and control the client and the target server to communicate data through a preset communication protocol until a disconnection request is received from the target server or the client, and then disconnect the connection between the target server and the client.
[0057] Step 207: When the application type is a timing type, the requested connection duration is determined based on the predetermined requested application requirements, and the client and the target server are controlled to perform data communication through a preset communication protocol within the requested connection duration.
[0058] Specifically, a timed type application is an application that does not require real-time processing and response, but is executed according to a pre-set time interval or trigger condition. When the application type is a timed type, the proxy server can set the connection duration according to the specific needs and business logic of the application. During the connection duration, the client and the target server are controlled to communicate data through a preset communication protocol. Exemplarily, the application to which the client sends a connection request is a timed data backup application, which needs to automatically back up data from the client to the target server at 2 a.m. every day, and the time required to back up the data is 1 hour. After receiving the connection request, the proxy server determines that the requested connection duration is 1 hour based on the needs of the backup task. After 2 a.m., within the 1-hour connection duration, the proxy server can continuously forward the backup data from the client to the target server until 3 a.m., when the proxy server automatically disconnects the connection between the client server and the target backup server.
[0059] In the technical solution of this embodiment, a connection request sent by a client is received through a preset communication protocol. In response to the connection request, the request server is determined based on the connection request, and the resource load information of the request server at the current moment is obtained. If the resource load information of the request server meets the preset conditions, the request server is determined to be the target server. If the resource load information of the request server does not meet the preset conditions, the target server is determined according to the resource information of other servers at the current moment. The resource information includes load information, geographic location and response time; the request application type corresponding to the connection request is determined; the application type is a real-time type or a timing type. When the application type is a real-time type, the target server is connected, and the client and the target server are controlled to communicate data through a preset communication protocol until a connection disconnection request sent by the target server or the client is received, and the connection between the target server and the client is disconnected. When the application type is a timing type, the request connection duration is determined based on the predetermined request application requirements, and the client and the target server are controlled to communicate data through a preset communication protocol within the request connection duration to send the target data to the client. The technical solution of this embodiment selects the most suitable server as the target server by obtaining the resource load information of the requesting server in real time. That is, this solution reasonably allocates system resources through the load balancing mechanism to avoid overloading of some servers while other servers are idle, thereby improving the resource utilization efficiency and the overall performance of the system. The connection duration is determined according to different application types, and the long connection between the client and the target server is maintained within the connection duration through the WebSocket communication protocol, and data is forwarded in real time to ensure real-time transmission and processing of data. In addition, the technical solution of this embodiment has good applicability and can be applied to complex network topologies, including mobile networks, local area networks, and the Internet.
[0060] Figure 4 Schematic diagram of the structure of a communication control device provided by an embodiment of the present invention, the device is suitable for executing the communication control method provided by an embodiment of the present invention. Figure 4 As shown, the device may specifically include:
[0061] The information receiving module 401 is used to receive a connection request sent by a client through a preset communication protocol;
[0062] An information determination module 402, configured to determine, in response to the connection request, a target server of the connection request based on the connection request and resource information of each server at a current moment;
[0063] The communication control module 403 is used to connect to the target server and control the client and the target server to communicate data through the preset communication protocol until a connection disconnection request sent by the target server or the client is received, and then the connection between the target server and the client is disconnected.
[0064] Optionally, the information determination module 402 is specifically configured to: determine a requesting server based on the connection request, and obtain resource load information of the requesting server at a current moment;
[0065] If the resource load information of the requesting server meets a preset condition, determining the requesting server as the target server;
[0066] If the resource load information of the requesting server does not meet the preset condition, the target server is determined according to the resource information of other servers at the current moment.
[0067] Optionally, the information determination module 402 is further used to: determine the load weight, location weight and duration weight corresponding to the connection request according to preset weight information;
[0068] The target server is determined according to the load weight, the location weight, the duration weight and resource information of each other server.
[0069] Optionally, the communication control module 403 is specifically used to: determine a request application type corresponding to the connection request; the application type is a real-time type or a timing type;
[0070] When the application type is a real-time type, executing the step of connecting to the target server and controlling the client and the target server to perform data communication through the preset communication protocol until a connection disconnection request sent by the target server or the client is received, and disconnecting the connection between the target server and the client;
[0071] When the application type is a timing type, the requested connection duration is determined based on a predetermined requested application requirement, and the client and the target server are controlled to perform data communication through the preset communication protocol within the requested connection duration.
[0072] Optionally, the communication control module 403 is further configured to: receive a data transmission request sent by the client based on the preset communication protocol;
[0073] Sending the data transmission request to the target server, and obtaining target data determined by the target server based on the data transmission request;
[0074] The target data is sent to the client.
[0075] Optionally, the information determination module 402 is further used to: send an identity authentication request to the client, and obtain authentication information sent by the client based on the identity authentication request;
[0076] Determining the request authority of the client based on the authentication information, and determining the available server of the client based on the request authority;
[0077] If the available servers do not include the request server, a request failure prompt message is sent to the client; if the available servers include the request server, the step of obtaining the resource load information of the request server at the current moment is performed.
[0078] The communication control device provided in the embodiment of the present invention can execute the communication control method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. For the contents not described in detail in this embodiment, reference can be made to the description in any method embodiment of the present invention.
[0079] An embodiment of the present invention also provides a computer program product.
[0080] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer program products, which can include one or more computer programs, which can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor, which can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0081] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, referring to Figure 5 , Figure 5 The electronic device 12 shown is only an example and should not limit the functions and scope of use of the embodiments of the present application. Figure 5As shown, the electronic device 12 is in the form of a general purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).
[0082] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0083] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0084] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 5 not shown, usually called a "hard drive"). Although Figure 5 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical medium) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present application.
[0085] A program / utility 40 having a set (at least one) of program modules 46 may be stored, for example, in the memory 28, such program modules 46 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 46 generally perform the functions and / or methods of the embodiments described herein.
[0086] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), may communicate with one or more devices that enable a user to interact with the electronic device 12, and / or may communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the electronic device 12 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 via the bus 18. It should be understood that although Figure 5 Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0087] The processing unit 16 executes various functional applications and data processing by running the program stored in the system memory 28, for example, implementing a communication control method provided in an embodiment of the present invention: receiving a connection request sent by a client through a preset communication protocol; responding to the connection request, determining a target server of the connection request based on the connection request and resource information of each server at the current moment; connecting to the target server, and controlling the client and the target server to perform data communication through the preset communication protocol until receiving a connection disconnection request sent by the target server or the client, and disconnecting the connection between the target server and the client.
[0088] An embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, a communication control method as provided in all the embodiments of the present invention is implemented: receiving a connection request sent by a client through a preset communication protocol; in response to the connection request, determining the target server of the connection request based on the connection request and the resource information of each server at the current moment; connecting to the target server, and controlling the client and the target server to communicate data through the preset communication protocol until a connection disconnection request sent by the target server or the client is received, and disconnecting the connection between the target server and the client. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electronic device, device or device of electrical, magnetic, optical, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection with one or more conductors, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction-executing electronic device, apparatus, or device.
[0089] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction-executing electronic device, apparatus, or device.
[0090] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0091] Computer program code for performing the operations of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0092] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A communication control method, characterized in that: Applied to a proxy server, the method comprises: Receive a connection request sent by a client through a preset communication protocol; In response to the connection request, determining a target server of the connection request based on the connection request and resource information of each server at a current moment; Connect to the target server, and control the client and the target server to communicate data through the preset communication protocol until a connection disconnection request sent by the target server or the client is received, and then disconnect the connection between the target server and the client.
2. The method according to claim 1, characterized in that Determining a target server of the connection request based on the connection request and resource information of each server at a current moment includes: Determine a requesting server based on the connection request, and obtain resource load information of the requesting server at the current moment; If the resource load information of the requesting server meets a preset condition, determining the requesting server as the target server; If the resource load information of the requesting server does not meet the preset condition, the target server is determined according to the resource information of other servers at the current moment.
3. The method according to claim 2, characterized in that The resource information includes load information, geographic location and response time; Determining the target server according to the resource information of other servers at the current moment includes: Determine the load weight, location weight and duration weight corresponding to the connection request according to the preset weight information; The target server is determined according to the load weight, the location weight, the duration weight and resource information of each other server.
4. The method according to claim 1, characterized in that: After determining the target server of the connection request, the method further includes: Determine a request application type corresponding to the connection request; the application type is a real-time type or a timing type; When the application type is a real-time type, executing the step of connecting to the target server and controlling the client and the target server to perform data communication through the preset communication protocol until a connection disconnection request sent by the target server or the client is received, and disconnecting the connection between the target server and the client; When the application type is a timing type, the requested connection duration is determined based on a predetermined requested application requirement, and the client and the target server are controlled to perform data communication through the preset communication protocol within the requested connection duration.
5. The method according to claim 1, characterized in that Controlling the client and the target server to perform data communication through the preset communication protocol includes: Receiving a data transmission request sent by the client based on the preset communication protocol; Sending the data transmission request to the target server, and obtaining target data determined by the target server based on the data transmission request; The target data is sent to the client.
6. The method according to claim 2, characterized in that Before obtaining the resource load information of the request server at the current moment, the method further includes: Sending an identity authentication request to the client, and obtaining authentication information sent by the client based on the identity authentication request; Determining the request authority of the client based on the authentication information, and determining the available server of the client based on the request authority; If the available servers do not include the request server, a request failure prompt message is sent to the client; if the available servers include the request server, the step of obtaining the resource load information of the request server at the current moment is performed.
7. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements a communication control method according to any one of claims 1 to 6.
8. A communication control device, characterized in that: include: An information receiving module, used to receive a connection request sent by a client through a preset communication protocol; An information determination module, configured to respond to the connection request and determine a target server of the connection request based on the connection request and resource information of each server at a current moment; The communication control module is used to connect to the target server and control the client and the target server to communicate data through the preset communication protocol until a connection disconnection request sent by the target server or the client is received, and then the connection between the target server and the client is disconnected.
9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the communication control method according to any one of claims 1 to 6 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the communication control method according to any one of claims 1 to 6 is implemented.