CN117857351A - Request processing method and device, electronic equipment and storage medium - Google Patents

Request processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117857351A
CN117857351A CN202311775876.9A CN202311775876A CN117857351A CN 117857351 A CN117857351 A CN 117857351A CN 202311775876 A CN202311775876 A CN 202311775876A CN 117857351 A CN117857351 A CN 117857351A
Authority
CN
China
Prior art keywords
proxy server
message
network connection
received
request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311775876.9A
Other languages
Chinese (zh)
Inventor
刘志文
钟鹏超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Original Assignee
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Topsec Technology Co Ltd, Beijing Topsec Network Security Technology Co Ltd, Beijing Topsec Software Co Ltd filed Critical Beijing Topsec Technology Co Ltd
Priority to CN202311775876.9A priority Critical patent/CN117857351A/en
Publication of CN117857351A publication Critical patent/CN117857351A/en
Pending legal-status Critical Current

Links

Landscapes

  • Computer And Data Communications (AREA)

Abstract

The application provides a request processing method, a request processing device, electronic equipment and a storage medium, which are applied to a standby proxy server, wherein the method comprises the following steps: receiving network connection information sent by a main proxy server; the network connection information is the network connection information received by the main proxy server and used for communication between the upstream server and the client; the network connection information includes a network protocol, address information, and request data; under the condition that the main proxy server is monitored to be in fault, establishing network connection according to a network protocol and address information; and processing the request task corresponding to the incomplete request data of the main proxy server based on the network connection. When the standby proxy server detects that the main proxy server is down, network connection is established by utilizing the received network connection information, a request task corresponding to the request data is continuously processed based on the network connection, a user does not need to perceive a switching server, the user does not need to repeatedly submit the request, and the service stability and the user experience are improved.

Description

Request processing method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method and apparatus for processing a request, an electronic device, and a storage medium.
Background
The proxy server forwards the request sent by the client to the real server, and the response message returned by the server is forwarded to the client through the proxy server. In order to improve the reliability of the system, after the host proxy server is down, the server is usually switched, and the proxy work of the host proxy server is accepted by the standby proxy server. In the prior art, after a host proxy server is down, a request being processed by the host proxy server is disconnected, so that the access of a client is interrupted, and the access usually needs to be sent again by the client, so that the service is unstable.
Disclosure of Invention
The embodiment of the application aims at a request processing method, a request processing device, electronic equipment and a storage medium, which are used for solving the problem that access of a client is interrupted after a proxy server is down, and the client is usually required to send again for access, so that service is unstable.
In a first aspect, an embodiment of the present application provides a request processing method, which is applied to a standby proxy server, including: receiving network connection information sent by a main proxy server; the network connection information is the network connection information received by the main proxy server and used for communication between the upstream server and the client; the network connection information includes a network protocol, address information, and request data; under the condition that the main proxy server is monitored to be in fault, establishing network connection according to a network protocol and address information; based on the network connection, processing the request task corresponding to the incomplete request data of the main proxy server.
In the implementation process, when the main proxy server processes the connection, the necessary information of each connection is sent to the standby proxy server in real time through the cardiac jumper. When the standby proxy server detects that the main proxy server is down, network connection is established by utilizing the received network connection information, and based on the network connection, the request task corresponding to the incomplete request data of the main proxy server is continuously processed, so that the server switching is realized under the condition that a user does not feel, and after the main proxy server is down, the user does not need to repeatedly submit the request, thereby improving the service stability and the user experience.
Optionally, in the embodiment of the present application, in a case where a failure of the primary proxy server is detected, establishing a network connection according to the network protocol and address information includes: monitoring heartbeat data sent by a main proxy server through a heartbeat channel; if the heartbeat data sent by the main proxy server is not received within the preset time, determining that the main proxy server fails; creating a Socket object according to a network protocol; based on Socket object and address information, network connection is established.
In the implementation process, the standby proxy server detects whether the main proxy server is down by monitoring the heartbeat data sent by the main proxy server, and establishes network connection according to the network connection information after the main proxy server is down, so that the standby proxy server is started as soon as possible and the continuity of service is maintained when the main proxy server fails.
Optionally, in an embodiment of the present application, based on network connection, processing a request task corresponding to request data that is not completed by the master proxy server includes: based on network connection, receiving a message to be received except for request data corresponding to a request task; the request data is the received and processed data; the request task is a request task between the client and the upstream server; and calling a proxy process to process the message to be received so as to complete the unfinished request task of the main proxy server.
In the implementation process, the standby proxy server receives the message to be received, invokes the proxy process and processes the message to be received so as to complete the incomplete request task of the main proxy server, provide highly available and reliable proxy service, reduce single-point faults, prevent the access being processed from being interrupted when the main proxy server is down, and ensure the continuity of the user request to a certain extent.
Optionally, in this embodiment of the present application, based on network connection, receiving a message to be received corresponding to a request task except for request data includes: determining a message to be received according to a message corresponding to the request data; receiving a message to be received through network connection; the message to be received is sent by the client or the upstream server.
In the implementation process, the standby proxy server receives the message to be received, invokes the proxy process, processes the message to be received, and when the main proxy server is down, the access being processed is not interrupted, the availability and reliability of the proxy service are provided, and the user experience is improved.
Optionally, in this embodiment of the present application, determining, according to a message corresponding to the request data, a message to be received includes: determining a header message in the request data, wherein the header message comprises a packet body message length; if the request data comprises part of header messages, the messages to be received are header messages to be received and packet body messages corresponding to the request task; the length of the packet body message corresponding to the request task is consistent with the length of the packet body message; if the request data comprises a complete header message, the message to be received is a packet body message to be received; the length of the packet body message to be received is smaller than or equal to that of the packet body message.
In the implementation process, the header message in the request data is determined, the header message comprises the length of the packet body message, the length of the message to be received is determined according to the header message and the length of the packet body message, and the message to be received is received according to the length of the message to be received, so that the complete message to be received is received, and the accuracy of message processing is improved.
Optionally, in the embodiment of the present application, invoking a proxy process, and processing a message to be received, so as to complete a request task that is not completed by the master proxy server, including: if the request data comprises part of header messages, the received header messages in the request data are put into a buffer area; receiving a header message to be received and a packet body message corresponding to a request task, and placing the header message to be received into a buffer area so that the buffer area comprises a complete header message; and calling a proxy process, analyzing the complete header message in the buffer zone, and forwarding the analyzed message and the inclusion message to complete the request task.
In the implementation process, the proxy server puts the acquired header message into the buffer area, and after acquiring the complete HTTP header message, performs header analysis, possible header modification and message forwarding. The method and the system realize the provision of a safe and efficient communication pipeline between the client and the upstream server through the standby proxy server.
Optionally, in an embodiment of the present application, after receiving the network connection information sent by the master proxy server, the method further includes: and storing the network connection information into a preset storage unit, and updating the storage unit according to the subsequently received network connection information.
In the implementation process, when the main proxy server processes the connection, the necessary information of each connection is sent to the standby proxy server in real time through the cardiac jumper. The standby proxy server can establish network connection according to the received network connection information after the main proxy server is down, so that server switching is realized under the condition that a user does not feel, and the service stability and the user experience are improved.
In a second aspect, an embodiment of the present application further provides a request processing apparatus, including: the receiving information module is used for receiving the network connection information sent by the main proxy server; the network connection information is the network connection information received by the main proxy server and used for communication between the upstream server and the client; the network connection information includes a network protocol, address information, and request data; the connection establishment module is used for establishing network connection according to the network protocol and address information under the condition that the main proxy server is monitored to be in fault; and the processing request module is used for processing the request task corresponding to the incomplete request data of the main proxy server based on network connection.
In a third aspect, an embodiment of the present application further provides an electronic device, including: a processor and a memory storing machine-readable instructions executable by the processor to perform the method as described above when executed by the processor.
In a fourth aspect, embodiments of the present application also provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the method described above.
By adopting the request processing method, the request processing device, the electronic equipment and the storage medium, when the main proxy server processes the connection, the necessary information of each connection is sent to the standby proxy server in real time through the cardiac jumper. When the standby proxy server detects that the main proxy server is down, network connection is established by utilizing the received network connection information, and based on the network connection, the request task corresponding to the incomplete request data of the main proxy server is continuously processed, so that the server switching is realized under the condition that a user does not feel, and after the main proxy server is down, the user does not need to repeatedly submit the request, thereby improving the service stability and the user experience.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of a proxy server with dual hot standby according to an embodiment of the present application;
fig. 2 is a schematic diagram of downtime of a main proxy server according to an embodiment of the present application;
FIG. 3 is a flowchart of a request processing method according to an embodiment of the present disclosure;
FIG. 4 is a schematic structural diagram of a request processing device according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Embodiments of the technical solutions of the present application will be described in detail below with reference to the accompanying drawings. The following examples are only for more clearly illustrating the technical solutions of the present application, and thus are only examples, and are not intended to limit the scope of protection of the present application.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application.
In the description of the embodiments of the present application, the technical terms "first," "second," etc. are used merely to distinguish between different objects and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated, a particular order or a primary or secondary relationship. In the description of the embodiments of the present application, the meaning of "plurality" is two or more unless explicitly defined otherwise.
The high availability Cluster (High Availability Cluster, abbreviated as HA Cluster) is a technology for reducing service interruption time, and it provides service to the outside continuously by protecting the business program of the user, so as to minimize the influence of faults caused by software, hardware and man-made on the business.
The HA cluster technology is divided into a plurality of different cluster modes, such as a dual-machine hot standby (Active, passive), that is, two devices form a cluster to become a host machine and a standby machine respectively, one heartbeat line is used for connecting the two devices, the host machine is responsible for receiving the processing message, the standby machine detects the state of the host machine through the heartbeat line, when no heartbeat information exists on the heartbeat line, the host machine is considered to be down, and the standby machine starts to receive the processing message, so that the stability of service is ensured to a certain extent.
Proxy servers (Proxy servers) are a type of web Server that acts as an intermediary between clients and other servers when a client (e.g., computer, cell phone, etc.) sends a request, the Proxy Server communicates with the target Server on behalf of the client and returns a response to the client. The proxy server has the effect that if a site uses a server directly as the site portal, its performance is very limited. And one proxy server is used for proxy of a plurality of servers, the performance of the proxy server is close to the addition of the servers, and the performance of the servers is greatly improved.
The HTTP proxy analyzes the HTTP message on the proxy server, and can select the server according to the message content, perform the functions of safety detection, speed limitation and the like.
And (3) selecting a route: the HTTP proxy server selects one from a plurality of servers according to different algorithms to serve as an actual server of the current request
Upstream and downstream: in proxy servers, the connection to a server is referred to as an upstream connection and the connection to a client is referred to as a downstream connection.
Please refer to fig. 1, which illustrates a schematic diagram of a proxy server with dual hot standby provided in an embodiment of the present application.
The line is used to represent the network connection between proxy devices, wherein the solid line represents the network connection for normally receiving and sending messages; the broken line represents that only the connection on hardware is performed, and the network message is not processed in practice; the implementation with an arrow represents the heartbeat line between the host and the standby, and the arrow direction represents the transmission direction of the heartbeat information. And "1.1.1.10", "2.2.2.10" in the figures represent the same ip addresses on the host and the slave, which is only one illustration.
Please refer to the schematic diagram of the downtime of the main proxy server provided in the embodiment of the present application shown in fig. 2.
When the standby machine cannot receive the heartbeat information of the host machine on the heartbeat line within the preset time, the host machine is considered to be down, and the standby machine starts to receive the message.
When the host is down, the proxy server is switched, the standby server communicates with the target server on behalf of the client, and then the response is returned to the client. If the client has sent a request before the main proxy server is down, after the main proxy server is down, the connection being processed is disconnected because no corresponding connection exists in the standby server, and the access of the client is interrupted. This typically requires the client to resend the request, and the newly sent request is processed by the standby proxy server to complete the communication with the target server. The prior art cannot realize the switching proxy server which is not perceived by the user, and has certain influence on the use of the user.
The embodiment of the application provides a request processing method, a request processing device, electronic equipment and a storage medium, wherein when a main proxy server processes connection, necessary information of each connection is sent to a standby proxy server in real time through a cardiac jumper. When the standby proxy server detects that the main proxy server is down, network connection is established by utilizing the received network connection information, and based on the network connection, the request task corresponding to the incomplete request data of the main proxy server is continuously processed, so that the server switching is realized under the condition that a user does not feel, and after the main proxy server is down, the user does not need to repeatedly submit the request, thereby improving the service stability and the user experience.
Please refer to fig. 3, which is a flowchart illustrating a request processing method according to an embodiment of the present application. The request processing method provided by the embodiment of the application can be applied to the standby proxy server, and the standby proxy server is used as a backup of the proxy server and is used for providing redundancy and fault tolerance. When the primary proxy server fails or is unavailable, the standby proxy server will take over its functions, ensuring continuity and availability of service. The request processing method may include:
step S110: receiving network connection information sent by a main proxy server; the network connection information is the network connection information received by the main proxy server and used for communication between the upstream server and the client; the network connection information includes a network protocol, address information, and request data.
Step S120: and under the condition that the main proxy server is monitored to be in fault, establishing network connection according to the network protocol and address information.
Step S130: based on the network connection, processing the request task corresponding to the incomplete request data of the main proxy server.
In step S110, the master proxy server is a server that carries proxy traffic between an upstream server, which may be a target server for the client to send a request, and the client. For example, when the client sends a request, the proxy server may communicate with the target server on behalf of the client, and then return a response to the client, i.e., complete the proxy service.
The primary proxy server sends the received network connection information in real time to the standby proxy server as the proxy task is performed, the network connection information being used for communication between the upstream server and the client.
The network connection information includes a network protocol, address information, and request data. Wherein the network protocol is a protocol used in a computer network, such as TCP, UDP, HTTP, FTP, SMTP and the like; address information refers to a network address, including local and remote addresses required for network connection, such as information specifying an IP address of a local machine, an IP address and port number of a remote server, and the like; the request data refers to data that needs to be transmitted in a normal connection, where the transmitted data includes data that is received and transmitted, such as request, response data, message, file, etc., and the request data may further include an ack number of a transmitted message, an ack number of an accepted message, the number of bytes that have been transmitted and received, whether an HTTP header is transmitted, and an HTTP header in the received message.
The network connection information may also include data of communication between the upstream server and the client, such as deleted connection data or connection state of creating a connection, time stamp, error information, etc., connection state such as establishing a connection, waiting for a connection, transmitting data, etc.; the time stamp is the time stamp of each event; the error information is various errors that may occur during the connection process, such as connection timeout, data loss, routing error, etc.
The main server sends the network connection information to the standby proxy server in a manner of sending the network connection information through a heartbeat channel, and the standby proxy server can establish corresponding connection or perform operations such as checking information of the connection by using the network connection information after receiving the information.
The primary proxy server, upon receiving network connection information for communication between the upstream server and the client, passes the network connection information to the backup proxy server in real time.
In step S120, the standby proxy server monitors whether the primary proxy server fails, and the monitoring method includes heartbeat detection, port interception, resource detection, and the like. The heartbeat detection is that the main proxy server sends a heartbeat packet to the standby proxy server, and if the main proxy server does not send the heartbeat packet within a preset time, the standby server judges that the main server is down. Port listening as a backup proxy server may use a network port monitor to detect certain important ports of the primary proxy server, which may be deemed unavailable if they fail to respond. The resource detection as a backup proxy server may detect an application, service, process, or resource running on the primary proxy server. If these resources do not work properly, the primary proxy server may be deemed unavailable.
And under the condition that the main proxy server is monitored to be in fault, the standby proxy server establishes network connection according to the network protocol and the address information. Specifically, for example, the Socket interface may be used to create a network connection corresponding to the network connection information by acquiring a network protocol of the network connection and address information such as an IP address and a port number.
Because the main proxy server sends the received network connection information to the standby proxy server in real time, that is, all information received by the main proxy server before downtime is sent to the standby proxy server. Therefore, the standby proxy server can create the network connection processed by the main proxy server when the main proxy server is down according to the received network connection information, and continue to process the request task corresponding to the network connection, so that the network connection cannot be disconnected, and the situation that the connection in process is disconnected because the main proxy server is down is reduced.
In step S130, the standby proxy server processes a request task corresponding to the request data that the main proxy server has not completed, based on the network connection established in step S120. The network connection may represent a requested task handled by the primary proxy server at downtime.
The following describes, by way of example, a procedure for the standby proxy server to continue processing the request, where the primary proxy server receives a request header sent by the client, obtains therefrom the network protocol, the source address and source port of the client, the destination address and destination port of the destination server, and the message data of the request header portion, and transmits these data to the standby proxy server in real time. At this time, the main proxy server is down, the standby proxy server monitors that the main proxy is in fault, and establishes network connection by using network connection information such as a network protocol, a source address and a source port of the client, a destination address and a destination port of the target server, and the like.
The standby proxy server continues to receive the message data of the request body part sent by the client by using the established network connection, and the request head part sent by the client to the main proxy server does not need to be retransmitted. The standby proxy server receives the message data of the request header part from the main proxy server, and receives the message of the request body part from the client to obtain complete request data. And forwarding the received request header and the request body to the target server according to the destination address and the destination port of the target server. And the response message sent by the target server can be received, and the response message is returned to the client based on network connection.
In the implementation process, when the main proxy server processes the connection, the necessary information of each connection is sent to the standby proxy server in real time through the cardiac jumper. When the standby proxy server detects that the main proxy server is down, network connection is established by utilizing the received network connection information, and based on the network connection, the request task corresponding to the incomplete request data of the main proxy server is continuously processed, so that the server switching is realized under the condition that a user does not feel, and after the main proxy server is down, the user does not need to repeatedly submit the request, thereby improving the service stability and the user experience.
Optionally, in the embodiment of the present application, in a case where a failure of the primary proxy server is detected, establishing a network connection according to the network protocol and address information includes: monitoring heartbeat data sent by a main proxy server through a heartbeat channel; if the heartbeat data sent by the main proxy server is not received within the preset time, determining that the main proxy server fails; creating a Socket object according to a network protocol; based on Socket object and address information, network connection is established.
In the specific implementation process: the standby proxy server monitors heartbeat data sent by the main proxy server through the heartbeat channel, if the heartbeat data sent by the main proxy server is not received within preset time, the main proxy server is determined to be faulty, and the standby proxy server continues to process the request task according to the received network connection information.
Specifically, for example, a network protocol in the network information is obtained, and a corresponding Socket object is created. Socket objects are objects used for realizing data communication in network programming. Socket objects are communication interfaces between programs running on a computer and a network, providing an abstraction layer enabling applications to communicate over the network. Various programming languages provide corresponding libraries or classes to implement Socket programming, and Socket related functions or methods can be called to create and use Socket objects.
Establishing a network connection based on Socket objects and address information includes: setting address and port information to be connected by using a Socket object method or function, and calling a connection server or a connection client method to complete network connection.
After the network connection is established, the network connection can be processed according to the connection result, and if the connection is successful, the data exchange operation can be continued. If the connection fails, an error handling or retry connection operation may be performed.
In the implementation process, the standby proxy server detects whether the main proxy server is down by monitoring the heartbeat data sent by the main proxy server, and after the main proxy server is down, network connection is established according to the network connection information so as to start the standby server as soon as possible and maintain the continuity of the service when the main proxy server fails.
Optionally, in an embodiment of the present application, based on network connection, processing a request task corresponding to request data that is not completed by the master proxy server includes: based on network connection, receiving a message to be received except for request data corresponding to a request task; the request data is the received and processed data; the request task is a request task between the client and the upstream server; and calling a proxy process to process the message to be received so as to complete the unfinished request task of the main proxy server.
In the specific implementation process: the request data is data that the primary proxy server has received data sent by the upstream server or client, and the primary proxy server and sends the portion of the data to the backup proxy server, i.e., the backup proxy server also receives.
After the main proxy server is down, the standby proxy server receives messages to be received except for request data corresponding to the request task based on network connection. For example, when the client transmits a request task to the primary proxy server, the primary proxy server transmits the received ACK flag packet to the standby proxy server in real time after transmitting the ACK flag packet to the primary proxy server. The primary proxy server is then down. The ACK flag packet refers to a data packet used for acknowledging received data in TCP, that is, a data packet of the third handshake.
The ACK zone bit packet received by the standby proxy server is the request data, and the standby proxy server continuously receives the messages to be received except the ACK zone bit corresponding to the request task sent by the client based on network connection. It should be noted that, data that the client has already transmitted to the master proxy server is not repeatedly transmitted.
And after the standby proxy server receives the message to be received, calling a proxy process to process the message to be received so as to complete the unfinished request task of the main proxy server. Processing the message to be received includes forwarding the message to be received and the like.
In an alternative embodiment, if the message to be received by the standby proxy server is a SYN packet, the request task is processed according to the proxy flow. SYN (Synchronize) packet is the first packet in a three-way handshake procedure in TCP (transmission control protocol). It is used for synchronization and negotiation when setting up a TCP connection. And if the standby proxy server receives the SNY packet, namely the SNY packet is a new request task, the network connection is established to normally process the request task, and the request is not influenced by downtime of the main proxy server.
In the implementation process, the standby proxy server receives the message to be received, invokes the proxy process and processes the message to be received so as to complete the incomplete request task of the main proxy server, provide highly available and reliable proxy service, reduce single-point faults, prevent the access being processed from being interrupted when the main proxy server is down, and ensure the continuity of the user request to a certain extent.
Optionally, in this embodiment of the present application, based on network connection, receiving a message to be received corresponding to a request task except for request data includes: determining a message to be received according to a message corresponding to the request data; receiving a message to be received through network connection; the message to be received is sent by the client or the upstream server.
In the specific implementation process: the request task is a request task between the client and the upstream server; the request data and the data to be received can be a completed request task, the request data is the received data, and the message to be received can be determined according to the message data corresponding to the request data.
After determining the message to be received, the standby proxy server receives the message to be received through network connection; the message to be received is sent by the client or the upstream server.
In the implementation process, the standby proxy server receives the message to be received, invokes the proxy process, processes the message to be received, and when the main proxy server is down, the access being processed is not interrupted, the availability and reliability of the proxy service are provided, and the user experience is improved.
Optionally, in this embodiment of the present application, determining, according to a message corresponding to the request data, a message to be received includes: determining a header message in the request data, wherein the header message comprises a packet body message length; if the request data comprises part of header messages, the messages to be received are header messages to be received and packet body messages corresponding to the request task; the length of the packet body message corresponding to the request task is consistent with the length of the packet body message; if the request data comprises a complete header message, the message to be received is a packet body message to be received; the length of the packet body message to be received is smaller than or equal to that of the packet body message.
In the specific implementation process: determining a header message in the request data, wherein the header message can be an HTTP request header message or a response header message; the header message includes the Length of the packet body message, namely Content-Length. Content-Length is a field in a request header or response header that indicates the Length of the message body (i.e., the body of the request or the entity responding) and can be in bytes.
If the request data includes a part of header messages, that is, the request data does not include a completed header message, so that the message to be received includes the header message to be received and a packet body message corresponding to the request task, where the packet body message corresponding to the request task refers to a complete packet body message, and since the client does not send the packet body message yet, the packet body message corresponding to the request task in the message to be received is consistent with the Content-Length.
If the request data comprises a complete header message, the message to be received is a packet body message to be received; the packet body message to be received can be a packet body message corresponding to a complete request task or an incomplete packet body message, so that the length of the packet body message to be received is smaller than or equal to the length of the packet body message. If the packet to be received is incomplete, the request data includes the packet that has already been received, and the Length of the packet to be received may be Content-Length minus the packet that has already been received.
In the implementation process, the header message in the request data is determined, the header message comprises the length of the packet body message, the length of the message to be received is determined according to the header message and the length of the packet body message, and the message to be received is received according to the length of the message to be received, so that the complete message to be received is received, and the accuracy of message processing is improved.
Optionally, in the embodiment of the present application, invoking a proxy process, and processing a message to be received, so as to complete a request task that is not completed by the master proxy server, including: if the request data comprises part of header messages, the received header messages in the request data are put into a buffer area; receiving a header message to be received and a packet body message corresponding to a request task, and placing the header message to be received into a buffer area so that the buffer area comprises a complete header message; and calling a proxy process, analyzing the complete header message in the buffer zone, and forwarding the analyzed message and the inclusion message to complete the request task.
In the specific implementation process: if the request data comprises part of header messages, part of header messages in the request data are put into a buffer area; the partial header message is the header message received by the standby proxy server.
And receiving a header message to be received and a packet body message corresponding to the request task, which are sent by the client or the upstream server, and placing the header message to be received into a buffer zone, wherein the buffer zone already contains part of the header message to be received and the part of the header message to be received, so that the buffer zone comprises the complete header message.
Invoking the proxy process, parsing the complete header message in the buffer, e.g., the standby proxy server first needs to parse the received HTTP header to extract the relevant information and fields. These fields include request method, request address, protocol version, header field, etc. The backup proxy server may also make modifications to the header as needed, such as adding new header fields or modifying original fields.
And according to the target address information in the header, the standby proxy server forwards the analyzed message and the inclusion message, namely the complete HTTP request or response message, to the target server or the client. During the forwarding process, the proxy server needs to keep the connection with the client or server unchanged until the whole process is completed.
In an alternative embodiment, if the request data includes a complete header message, the complete header message that has been received in the request data is placed in the buffer; and calling a proxy process, analyzing the complete header message in the buffer zone, and forwarding the analyzed message and the inclusion message to complete the request task.
Before forwarding, the proxy process can acquire whether a target server is set from network connection, if so, skip route selection and connect the target server, and directly forward traffic; if the target server is not set, the routing process can be performed first.
In an alternative embodiment, if the standby proxy server encounters an error during processing, such as failing to parse the header or failing to connect to the target server, an error response or error message may be returned to the requestor (client) to ensure that the standby proxy server is able to process the client request and response normally.
In the implementation process, the proxy server puts the acquired header message into the buffer area, and after acquiring the complete HTTP header message, performs header analysis, possible header modification and message forwarding. The method and the system realize the provision of a safe and efficient communication pipeline between the client and the upstream server through the standby proxy server.
Optionally, in an embodiment of the present application, after receiving the network connection information sent by the master proxy server, the method further includes: and storing the network connection information into a preset storage unit, and updating the storage unit according to the subsequently received network connection information.
In the specific implementation process: after receiving the network connection information sent by the master proxy server, the received network connection information may be stored in a preset storage unit, where, as a way, the storage unit may be, for example, a ha mini Socket (high availability cluster Socket resource), where the mini Socket is a Socket containing necessary information, and the standby proxy server is used to store the network connection information sent by the master proxy server. And the standby proxy server creates, deletes and updates the corresponding ha mini sock according to the subsequently received network connection information.
In the implementation process, when the main proxy server processes the connection, the necessary information of each connection is sent to the standby proxy server in real time through the cardiac jumper. The standby proxy server can establish network connection according to the received network connection information after the main proxy server is down, so that server switching is realized under the condition that a user does not feel, and the service stability and the user experience are improved.
In an alternative embodiment, after recovery after a restart of the primary proxy server, heartbeat data is sent to the backup proxy server over a heartbeat channel informing the backup proxy server that the primary proxy server has been restarted and is free of failures. The subsequent processing may include two cases, the first: the primary and standby machines exchange identities, namely the standby proxy server can be used as a primary proxy server, and the original primary proxy server is used as the standby proxy server. The standby proxy server is used as a new main proxy server to send heartbeat data to the original main proxy server, and the received network connection information, such as HTTP proxy tcp connection which is currently being processed and HTTP information, is sent to the original main proxy server, and the original main proxy server monitors whether the new main proxy server fails or not through the heartbeat data.
In the second case, the primary proxy server still serves as a host, and the standby proxy server sends the received network connection information, including the HTTP proxy tcp connection currently being processed and the HTTP information, to the primary proxy server, and actively stops processing the network message. After the main proxy server receives the network connection information, the network connection is established, so that the connection established by the standby proxy server is not interrupted, and the request task is continuously processed. And the primary proxy server continues to send heartbeat data to the backup proxy server over the heartbeat channel. And the standby proxy server receives network connection information such as tcp connection and the like of HTTP (hyper text transport protocol) of heartbeat information sent by the host computer and monitors whether the main proxy server fails.
Please refer to fig. 4, which illustrates a schematic structural diagram of a request processing apparatus provided in an embodiment of the present application; the embodiment of the application provides a request processing device 200, which comprises:
a receiving information module 210, configured to receive network connection information sent by the master proxy server; the network connection information is the network connection information received by the main proxy server and used for communication between the upstream server and the client; the network connection information includes a network protocol, address information, and request data;
The connection establishment module 220 is configured to establish a network connection according to the network protocol and address information when it is detected that the primary proxy server fails;
the processing request module 230 is configured to process a request task corresponding to the request data that is not completed by the master proxy server based on the network connection.
Optionally, in the embodiment of the present application, the request processing device establishes a connection module, and is specifically configured to monitor heartbeat data sent by the master proxy server through a heartbeat channel; if the heartbeat data sent by the main proxy server is not received within the preset time, determining that the main proxy server fails; creating a Socket object according to a network protocol; based on Socket object and address information, network connection is established.
Optionally, in the embodiment of the present application, the request processing device and the processing request module are specifically configured to receive, based on network connection, a message to be received except for request data, where the message to be received corresponds to a request task; the request data is the received and processed data; the request task is a request task between the client and the upstream server; and calling a proxy process to process the message to be received so as to complete the unfinished request task of the main proxy server.
Optionally, in the embodiment of the present application, the request processing device, the processing request module, and the determining module are further configured to determine, according to a message corresponding to the request data, a message to be received; receiving a message to be received through network connection; the message to be received is sent by the client or the upstream server.
Optionally, in an embodiment of the present application, the request processing device, the processing request module, is further configured to determine a header packet in the request data, where the header packet includes a packet body packet length; if the request data comprises part of header messages, the messages to be received are header messages to be received and packet body messages corresponding to the request task; the length of the packet body message corresponding to the request task is consistent with the length of the packet body message; if the request data comprises a complete header message, the message to be received is a packet body message to be received; the length of the packet body message to be received is smaller than or equal to that of the packet body message.
Optionally, in the embodiment of the present application, the request processing device, the processing request module, and if the request data includes a part of header packet, the processing request module is further configured to put the header packet that has been received in the request data into the buffer; receiving a header message to be received and a packet body message corresponding to a request task, and placing the header message to be received into a buffer area so that the buffer area comprises a complete header message; and calling a proxy process, analyzing the complete header message in the buffer zone, and forwarding the analyzed message and the inclusion message to complete the request task.
Optionally, in an embodiment of the present application, the request processing device further includes a storage module, configured to store the network connection information to a preset storage unit, and update the storage unit according to the subsequently received network connection information.
It should be understood that, corresponding to the above request processing method embodiment, the apparatus is capable of executing each step related to the above method embodiment, and specific functions of the apparatus may be referred to the above description, and detailed descriptions are omitted herein as appropriate to avoid repetition. The device includes at least one software functional module that can be stored in memory in the form of software or firmware (firmware) or cured in an Operating System (OS) of the device.
Please refer to fig. 5, which illustrates a schematic structural diagram of an electronic device provided in an embodiment of the present application. An electronic device 300 provided in an embodiment of the present application includes: a processor 310 and a memory 320, the memory 320 storing machine-readable instructions executable by the processor 310, which when executed by the processor 310 perform the method as described above.
The present application also provides a storage medium having stored thereon a computer program which, when executed by a processor, performs a method as above.
The storage medium may be implemented by any type of volatile or nonvolatile Memory device or combination thereof, such as static random access Memory (Static Random Access Memory, SRAM), electrically erasable Programmable Read-Only Memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), erasable Programmable Read-Only Memory (Erasable Programmable Read Only Memory, EPROM), programmable Read-Only Memory (PROM), read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic disk, or optical disk.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. The apparatus embodiments described above are merely illustrative, for example, of the flowcharts and block diagrams in the figures that illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present application may be integrated together to form a single part, or each module may exist alone, or two or more modules may be integrated to form a single part.
The foregoing description is merely an optional implementation of the embodiments of the present application, but the scope of the embodiments of the present application is not limited thereto, and any person skilled in the art may easily think about changes or substitutions within the technical scope of the embodiments of the present application, and the changes or substitutions should be covered in the scope of the embodiments of the present application.

Claims (10)

1. A method for processing a request, applied to a standby proxy server, comprising:
receiving network connection information sent by a main proxy server; the network connection information is the network connection information received by the main proxy server and used for communication between an upstream server and a client; the network connection information comprises a network protocol, address information and request data;
under the condition that the main proxy server is monitored to be in fault, establishing network connection according to the network protocol and the address information;
And based on the network connection, processing the request task corresponding to the request data which is not completed by the master proxy server.
2. The method of claim 1, wherein the establishing a network connection according to the network protocol and the address information in the event that the primary proxy server is monitored to be malfunctioning comprises:
monitoring heartbeat data sent by the main proxy server through a heartbeat channel;
if the heartbeat data sent by the main proxy server is not received within the preset time, determining that the main proxy server fails;
creating a Socket object according to the network protocol;
and establishing the network connection based on the Socket object and the address information.
3. The method of claim 1, wherein the processing the requested task corresponding to the requested data that the master proxy server did not complete based on the network connection comprises:
based on the network connection, receiving a message to be received except the request data corresponding to the request task; the request data is received and processed data; the request task is a request task between the client and the upstream server;
And calling a proxy process, and processing the message to be received so as to complete the request task which is not completed by the main proxy server.
4. A method according to claim 3, wherein receiving, based on the network connection, a message to be received corresponding to the requested task, except for the requested data, includes:
determining the message to be received according to the message corresponding to the request data;
receiving the message to be received through the network connection; the message to be received is sent by the client or the upstream server.
5. The method of claim 4, wherein the determining the message to be received according to the message corresponding to the request data comprises:
determining a header message in the request data, wherein the header message comprises a packet body message length;
if the request data comprises part of header messages, the messages to be received are header messages to be received and inclusion messages corresponding to the request task; the length of the packet body message corresponding to the request task is consistent with the length of the packet body message;
if the request data comprises a complete header message, the message to be received is a packet body message to be received; the length of the packet body message to be received is smaller than or equal to that of the packet body message.
6. The method of claim 5, wherein the invoking a proxy process to process the message to be received to complete the requested task that the primary proxy server did not complete comprises:
if the request data comprises part of header messages, the received header messages in the request data are put into a buffer area;
receiving the header message to be received and the packet body message corresponding to the request task, and placing the header message to be received into the buffer area so that the buffer area comprises a complete header message;
and calling a proxy process, analyzing the complete header message in the buffer zone, and forwarding the analyzed message and the inclusion message to complete the request task.
7. The method of claim 1, wherein after receiving the network connection information sent by the master proxy server, the method further comprises:
and storing the network connection information into a preset storage unit, and updating the storage unit according to the subsequently received network connection information.
8. A request processing apparatus, for use with a backup proxy server, comprising:
The receiving information module is used for receiving the network connection information sent by the main proxy server; the network connection information is the network connection information received by the main proxy server and used for communication between an upstream server and a client; the network connection information comprises a network protocol, address information and request data;
the connection establishment module is used for establishing network connection according to the network protocol and the address information under the condition that the main proxy server is monitored to be in fault;
and the processing request module is used for processing the request task corresponding to the request data which is not completed by the master proxy server based on the network connection.
9. An electronic device, comprising: a processor and a memory storing machine-readable instructions executable by the processor to perform the method of any one of claims 1 to 7 when executed by the processor.
10. A computer-readable storage medium, characterized in that it has stored thereon a computer program which, when executed by a processor, performs the method according to any of claims 1 to 7.
CN202311775876.9A 2023-12-21 2023-12-21 Request processing method and device, electronic equipment and storage medium Pending CN117857351A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311775876.9A CN117857351A (en) 2023-12-21 2023-12-21 Request processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311775876.9A CN117857351A (en) 2023-12-21 2023-12-21 Request processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117857351A true CN117857351A (en) 2024-04-09

Family

ID=90542948

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311775876.9A Pending CN117857351A (en) 2023-12-21 2023-12-21 Request processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117857351A (en)

Similar Documents

Publication Publication Date Title
JP4087271B2 (en) Proxy response device and network system
CN107332726B (en) Communication link detection method and device
US7929422B2 (en) Method of moving a transport connection among network hosts
US7974186B2 (en) Connection recovery device, method and computer-readable medium storing therein processing program
US7996517B2 (en) Transparent network connection takeover
JP3932994B2 (en) Server handover system and method
CN111190747A (en) Message loss detection method and device for message queue
CN110971698B (en) Data forwarding system, method and device
US9992058B2 (en) Redundant storage solution
CN110912759A (en) Automatic connection method and system for VPN network abnormity
US8060628B2 (en) Technique for realizing high reliability in inter-application communication
JP5112246B2 (en) Storage system and communication method
WO2024074091A1 (en) Sip dynamic load balancing method and system, and device and storage medium
JP2006229399A (en) Communications system, relay node and communication method used for the same, and program thereof
CN108270593B (en) Dual-computer hot backup method and system
CN106708881B (en) Interaction method and device based on network file system
CN117857351A (en) Request processing method and device, electronic equipment and storage medium
JP2007141129A (en) System switching method, computer system and program
JP2016162324A (en) Information processing system, control program and control method
US11954509B2 (en) Service continuation system and service continuation method between active and standby virtual servers
KR20180099143A (en) Apparatus and method for recovering tcp-session
US10750383B2 (en) Method of providing management and control of hotspots with reduced messaging
CN114650213A (en) Method, device and storage medium for configuring Jenkins server cluster
US20240205139A1 (en) Communication system and communication control method
KR100793446B1 (en) Method for processing fail-over and returning of duplication telecommunication system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination