HTTP communication method, apparatus, device and system
By extending the connection of the HTTP response client by a preset time before interrupting the connection of the HTTP request client, the problem of request timeout caused by the failure to forward HTTP response messages in a timely manner is solved, thus improving the stability and reliability of HTTP communication.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- EHANG INTELLIGENT EQUIP GUANGZHOU CO LTD
- Filing Date
- 2022-11-02
- Publication Date
- 2026-04-10
AI Technical Summary
In existing technologies, HTTP short-connection communication based on TCP pass-through services suffers from the problem of HTTP response messages not being forwarded to the HTTP request client in a timely manner, leading to request timeouts.
When the HTTP response client is detected to have disconnected, the connection termination operation with the HTTP request client is performed after a preset time is extended to ensure that the HTTP response message can be transmitted smoothly.
This avoids HTTP request timeouts, reduces the risk of data loss and network congestion, and improves the stability of HTTP communication.
Smart Images

Figure CN116155880B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of communication technology, in particular to a HTTP communication method, device, equipment and system. BACKGROUND
[0002] In the prior art, TCP transparent service is responsible for opening TCP connection between two clients. When any client is disconnected, TCP transparent service will actively cut off the TCP connection of the other client. This mechanism is normal for TCP communication, but it has problems for HTTP communication based on TCP connection: because most HTTP response clients (various third-party devices with fixed business functions such as central control machines, embedded devices, etc.) often only support HTTP short connection, such clients return HTTP response messages and then actively disconnect the connection. This "disconnection" will cause the HTTP response message to not be forwarded to the HTTP request client by the TCP transparent service in time, triggering the TCP transparent service to perform the disconnection operation on the HTTP request client, which often causes the HTTP request client to request timeout. SUMMARY
[0003] Embodiments of the present application aim to provide a HTTP communication method, device, equipment and system to solve the problem of HTTP request client request timeout caused by the HTTP response message not being forwarded to the HTTP request client by the TCP transparent service in time, triggering the TCP transparent service to perform the disconnection operation on the HTTP request client when using TCP transparent service based HTTP short connection communication in the prior art.
[0004] To solve the above technical problems, embodiments of the present application provide the following technical solutions:
[0005] According to an aspect of the present application, a HTTP communication method is provided, the method comprising:
[0006] receiving an HTTP request message sent by an HTTP request client;
[0007] forwarding the HTTP request message to an HTTP response client;
[0008] receiving an HTTP response message returned by the HTTP response client;
[0009] forwarding the HTTP response message to the HTTP request client;
[0010] monitoring the connection state of the HTTP request client and the HTTP response client, and when it is monitored that the HTTP response client is disconnected, prolonging for a preset time period before performing the disconnection operation with the HTTP request client.
[0011] Optionally, the method further comprises:
[0012] When the HTTP request client is monitored to be disconnected, the operation of interrupting the connection with the HTTP response client is performed immediately.
[0013] Optionally, when the HTTP response client is monitored to be disconnected, the operation of interrupting the connection with the HTTP request client is performed after the preset time period is prolonged, and the operation of prolonging the preset time period comprises:
[0014] When the HTTP response client is monitored to be disconnected, it is judged whether the HTTP response message returned by the HTTP response client is received, and if yes, the operation of interrupting the connection with the HTTP request client is performed after the preset time period is prolonged.
[0015] Optionally, when the HTTP response client is monitored to be disconnected, the operation of interrupting the connection with the HTTP request client is performed after the preset time period is prolonged, and the operation of prolonging the preset time period further comprises:
[0016] The time t1 of forwarding the HTTP response message to the HTTP request client and the time t2 of the HTTP response client being disconnected are acquired;
[0017] The time difference Δt between t2 and t1 is calculated;
[0018] If Δt is less than the transmission time threshold, the operation of interrupting the connection with the HTTP request client is performed after the preset time period is prolonged; and if Δt is greater than or equal to the transmission time threshold, the operation of interrupting the connection with the HTTP request client is performed immediately.
[0019] Optionally, the transmission time threshold is the time required for transmitting a maximum data packet that can be transmitted in a current service scenario between the HTTP request client and the HTTP response client.
[0020] Optionally, the preset time period is determined based on the transmission time threshold and the time difference Δt.
[0021] According to another aspect of the present application, an HTTP communication device is provided, and the device comprises:
[0022] An information receiving module is configured to receive the HTTP request message sent by the HTTP request client and the HTTP response message returned by the HTTP response client;
[0023] An information forwarding module is configured to forward the HTTP request message to the HTTP response client and forward the HTTP response message to the HTTP request client;
[0024] The monitoring processing module is configured to monitor connection states of the HTTP request client and the HTTP response client, and when it is monitored that the HTTP response client is disconnected, to perform a disconnection operation with the HTTP request client after a preset time period is prolonged.
[0025] According to still another aspect of the present application, there is provided an electronic device comprising a memory, a processor and a computer program stored in the memory and run on the processor, wherein the processor implements the steps of the HTTP communication method according to any one of the preceding aspects when running the computer program.
[0026] According to still another aspect of the present application, there is provided an HTTP communication system comprising an HTTP request client, a TCP transparent service server and an HTTP response client, wherein,
[0027] The HTTP request client is configured to establish a TCP connection with the TCP transparent service server, and send an HTTP request message to the TCP transparent service server, wherein the HTTP request message comprises identification information of the HTTP response client.
[0028] The TCP transparent service server is configured to receive the HTTP request message sent by the HTTP request client, establish a TCP connection with the HTTP response client according to the identification information of the HTTP response client comprised in the HTTP request message, forward the HTTP request message to the HTTP response client, receive an HTTP response message returned by the HTTP response client, forward the HTTP response message to the HTTP request client, monitor connection states of the HTTP request client and the HTTP response client, and when it is monitored that the HTTP response client is disconnected, perform a disconnection operation with the HTTP request client after a preset time period is prolonged.
[0029] The HTTP response client is configured to establish a TCP connection with the TCP transparent service server, receive the HTTP request message sent by the TCP transparent service server, generate an HTTP response message according to the HTTP request message, send the HTTP response message to the TCP transparent service server, and after the sending is completed, disconnect the connection with the TCP transparent service server.
[0030] According to still another aspect of the present application, there is provided a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the HTTP communication method according to any one of the preceding aspects.
[0031] The beneficial effect of the embodiment of the present application is that: different from the prior art, in the embodiment of the present application, when the HTTP response client is disconnected, the preset time period is extended before the interrupt connection operation with the HTTP request client is performed when the HTTP short connection communication between the HTTP request client and the HTTP response client is performed based on the TCP transparent service. By using the method of the present application, the HTTP request client request timeout problem caused by the TCP transparent service performing the interrupt connection operation on the HTTP request client before the HTTP response message is forwarded to the HTTP request client by the TCP transparent service can be avoided, the data loss risk and network congestion are reduced, and the stability of the HTTP communication is improved. BRIEF DESCRIPTION OF DRAWINGS
[0032] One or more embodiments are illustrated by way of example with reference to the drawings, which are not limiting of the embodiments and which are merely meant to explain the embodiments. The elements in the figures are not meant to be limiting of the embodiments, unless otherwise specifically noted and are meant to show like elements. The figures in the drawings are not to scale and are merely meant as illustrative, not limiting of the embodiments.
[0033] Figure 1 is an optional HTTP communication method flowchart provided by the embodiment one of the present application;
[0034] Figure 2 is Figure 1 is a detailed flowchart of step S105 in the embodiment;
[0035] Figure 3 is an optional HTTP communication three-end interaction flowchart provided by the embodiment one of the present application;
[0036] Figure 4 is an optional HTTP communication device structure schematic diagram provided by the embodiment two of the present application;
[0037] Figure 5 is an optional electronic device structure schematic diagram provided by the embodiment three of the present application.
[0038] Figure 6 is an optional HTTP communication system structure schematic diagram provided by the embodiment four of the present application. DETAILED DESCRIPTION
[0039] In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0040] In addition, the technical features involved in each embodiment of the application described below can be combined with each other as long as there is no conflict.
[0041] Embodiment one
[0042] According to the embodiment of the application, an HTTP communication method is provided, which is an improvement on the existing HTTP short connection communication method based on TCP transparent service. The method of the application can be applied to the scene of HTTP communication of a control software to various third-party devices, and the control software implementing the solution of the application can ensure that the HTTP communication can be normally carried out at any time. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a group of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here.
[0043] Please refer to Figure 1 , Figure 1 The flowchart of an optional HTTP communication method provided by the embodiment one of the application is shown, and the method is applied to a TCP transparent service end. The method comprises the following steps:
[0044] Step S101, receiving an HTTP request message sent by an HTTP request client.
[0045] In this embodiment, the HTTP request client initiates a TCP connection request to the TCP transparent service end before sending the HTTP request message to the TCP transparent service end, and sends a handshake packet to the TCP transparent service end after the connection to identify the HTTP request client; and then converts the HTTP request message into a TCP data packet and sends it to the TCP transparent service end.
[0046] Step S102, forwarding the HTTP request message to an HTTP response client.
[0047] After the TCP transparent service end receives the HTTP request message sent by the HTTP request client, a TCP connection is established between the TCP transparent service end and the HTTP response client according to the identification information of the HTTP response client contained in the HTTP request message, and the HTTP request message is forwarded to the HTTP response client.
[0048] Step S103, receiving an HTTP response message returned by the HTTP response client.
[0049] The HTTP response client generates an HTTP response message according to the HTTP request message and sends the HTTP response message to the TCP transparent server. Generally, the HTTP response client returns the HTTP response message and then actively disconnects.
[0050] In step S104, the HTTP response message is forwarded to the HTTP request client.
[0051] The TCP transparent server receives the HTTP response message returned by the HTTP response client, the HTTP response message carrying the identifier of the HTTP request client, and the TCP transparent server forwards the HTTP response message to the corresponding HTTP request client according to the identifier of the HTTP request client.
[0052] In step S105, the connection state of the HTTP request client and the HTTP response client is monitored, and when it is monitored that the HTTP response client is disconnected, the disconnection operation with the HTTP request client is performed after a preset time period is prolonged.
[0053] The TCP transparent server monitors the connection state of each HTTP request client and HTTP response client that establishes a connection with the TCP transparent server. Generally, when it is monitored that any party client is disconnected, the TCP connection of the other client is actively cut off. This mechanism is normal for TCP communication, but it has a problem for HTTP communication based on TCP connection. Because the third-party devices (such as a central control machine, an embedded device, etc.) that are various fixed business functions of the HTTP response client often only support HTTP short connection, the client returns the HTTP response message and then actively disconnects. The disconnection causes the HTTP response message to be not forwarded (to the HTTP request client) by the service before the disconnection triggers the service to perform the disconnection operation with the HTTP request client, which often causes the HTTP request client to request timeout.
[0054] To solve this problem, when it is monitored that the HTTP response client is disconnected, a preset time period is prolonged, so that the HTTP response message is successfully transmitted to the HTTP request client, and then the disconnection operation with the HTTP request client is performed.
[0055] In an embodiment, the preset time period can be determined according to a transmission time threshold required for transmitting a data packet between the HTTP request client and the HTTP response client, the transmission time threshold being a time required for transmitting a maximum data packet that can be transmitted in a current business scenario between the HTTP request client and the HTTP response client. Different business scenarios can correspond to different maximum data packet sizes.
[0056] In an embodiment, for simplicity, the preset time length can also be set in advance according to experience, for example, the preset time length is set to 1s.
[0057] In an embodiment, the implementation of step S105 is as shown in Figure 2
[0058] Step S1051, monitoring the connection state of the HTTP request client and the HTTP response client.
[0059] Step S1052, when the HTTP request client is monitored to be disconnected, immediately performing the interrupt connection operation with the HTTP response client.
[0060] In an embodiment, when the TCP transparent service monitors the HTTP request client to be disconnected, regardless of the state of the HTTP response client, the TCP transparent service immediately performs the interrupt connection operation with the HTTP response client.
[0061] Step S1053, when the HTTP response client is monitored to be disconnected, entering step S1054.
[0062] Step S1054, judging whether the HTTP response message returned by the HTTP response client is received, if yes, entering step S1055, if not, entering step S1056.
[0063] Step S1054, extending the preset time length and then performing the interrupt connection operation with the HTTP request client.
[0064] In an embodiment, the TCP transparent service side acquires the time t1 of forwarding the HTTP response message to the HTTP request client and the time t2 of the HTTP response client being disconnected (the time of the TCP transparent service side monitoring the HTTP response client to be disconnected); calculates the time difference Δt of t2 and t1; if Δt is less than the transmission time length threshold, it is indicated that the HTTP response message may not have been successfully transmitted to the HTTP request client, the preset time length is extended and then the interrupt connection operation with the HTTP request client is performed; if Δt is greater than or equal to the transmission time length threshold, it is indicated that the HTTP response message has been successfully transmitted to the HTTP request client, and the interrupt connection operation with the HTTP request client is immediately performed.
[0065] In an embodiment, the preset time length is determined based on the transmission time length threshold and the time difference Δt. Specifically, the preset time length = transmission time length threshold - Δt.
[0066] Step S1056, immediately performing the interrupt connection operation with the HTTP request client.
[0067] Referring to Figure 3 , Figure 3 An optional HTTP communication three-end interaction flowchart provided by the embodiment one of the present application is shown in the drawing, and the specific interaction steps are as follows:
[0068] Step S301, the HTTP request client initiates a TCP connection to the TCP transparent service end.
[0069] The HTTP request client and the TCP transparent service end establish a connection with the TCP transparent service end through three-way handshake.
[0070] Step S302, the HTTP request client generates an HTTP request message and sends the HTTP request message to the TCP transparent service end as a TCP data packet.
[0071] Specifically, the HTTP request message carries the identification information of the HTTP response client.
[0072] Step S303, the TCP transparent service end establishes a TCP connection with the HTTP response client according to the identification information of the HTTP response client carried in the HTTP request message, and forwards the HTTP request message to the HTTP response client.
[0073] Step S304, the HTTP response client generates an HTTP response message according to the HTTP request message and sends the HTTP response message to the TCP transparent service end.
[0074] Specifically, the HTTP response message carries the identification information of the HTTP request client.
[0075] Step S305, the TCP transparent service end forwards the HTTP response message to the HTTP request client according to the identification information of the HTTP request client carried in the HTTP response message.
[0076] Step S306, the HTTP response client sends the HTTP response message and immediately interrupts the connection with the TCP transparent service end.
[0077] Step S307, the TCP transparent service end monitors the disconnection of the HTTP response client, and interrupts the connection with the HTTP request client after prolonging the preset time length.
[0078] Step S308, the HTTP request client initiates the next HTTP request.
[0079] The HTTP communication method provided in this invention employs a TCP pass-through service for short-connection communication between an HTTP request client and an HTTP response client. When the HTTP response client is detected to have disconnected, the connection is extended for a preset time before the connection termination operation with the HTTP request client is executed. This method avoids the HTTP request client timeout problem caused by the TCP pass-through service terminating the connection before the HTTP response message has been forwarded to the HTTP request client, thus reducing the risk of data loss and network congestion, and improving the stability of HTTP communication.
[0080] Example 2
[0081] According to embodiments of the present invention, an HTTP communication device is provided, such as... Figure 4 The diagram shown is a schematic representation of an optional HTTP communication device according to Embodiment 2 of the present invention. The HTTP communication device 400 includes an information receiving module 402, an information forwarding module 404, and a connection monitoring module 406.
[0082] The information receiving module 402 is used to receive HTTP request messages sent by the HTTP request client and HTTP response messages returned by the HTTP response client.
[0083] The information forwarding module 404 is used to forward the HTTP request message to the HTTP response client and the HTTP response message to the HTTP request client;
[0084] The monitoring and processing module 406 is used to monitor the connection status of the HTTP request client and the HTTP response client. When the HTTP response client is detected to be disconnected, the connection is interrupted with the HTTP request client after a preset time.
[0085] The above-mentioned device can perform the operation described in Embodiment 1. Figures 1 to 3 Each of the described HTTP communication methods has corresponding functional modules and beneficial effects. Technical details not described in detail in this embodiment can be found in Embodiment 1 of this invention. Figures 1 to 3 Provided HTTP communication methods.
[0086] Example 3
[0087] According to embodiments of the present invention, an electronic device is provided, such as... Figure 5As shown in the figure, the optional electronic device structure schematic diagram provided by the embodiment three of the present application can include a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502 and the memory 503 complete mutual communication through the communication bus 504. The processor 501 can call the logical instructions in the memory 503 to execute the HTTP communication method, which includes: receiving the HTTP request message sent by the HTTP request client; forwarding the HTTP request message to the HTTP response client; receiving the HTTP response message returned by the HTTP response client; forwarding the HTTP response message to the HTTP request client; monitoring the connection state of the HTTP request client and the HTTP response client, and when the HTTP response client is disconnected, the disconnection operation with the HTTP request client is performed after the preset time period is prolonged.
[0088] In addition, the logical instructions in the memory 503 can be realized in the form of a software functional unit and sold or used as an independent product, and can be stored in several computer readable storage media. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a plurality of instructions to make a computer device (which can be a personal computer, a server or a network device, etc.) execute the HTTP communication method of the embodiment one of the present application Figures 1 to 3 The storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk and various program code storage media.
[0089] The above product can execute the HTTP communication method of the embodiment one Figures 1 to 3 Any of the HTTP communication methods has the function modules and beneficial effects corresponding to the method, and the technical details not described in detail in the embodiment can be referred to the embodiment one of the present application Figures 1 to 3 The HTTP communication method provided by the embodiment four of the present application.
[0090] Embodiment four
[0091] According to the embodiment of the present application, an HTTP communication system is provided. As shown in the figure, Figure 6 As shown in the figure, the optional HTTP communication system structure schematic diagram provided by the embodiment four of the present application includes an HTTP request client 601, a TCP transparent service end 602 and an HTTP response client 603, wherein,
[0092] The HTTP request client 601 is used for establishing a TCP connection with the TCP transparent service server 602, sending an HTTP request message to the TCP transparent service server 602, and the HTTP request message contains identification information of the HTTP response client 603.
[0093] The TCP transparent service server 602 is used for receiving the HTTP request message sent by the HTTP request client 601, establishing a TCP connection with the HTTP response client 603 according to the identification information of the HTTP response client 603 contained in the HTTP request message, forwarding the HTTP request message to the HTTP response client 603, receiving an HTTP response message returned by the HTTP response client 603, forwarding the HTTP response message to the HTTP request client 601, monitoring the connection state of the HTTP request client 601 and the HTTP response client 603, and when it is monitored that the HTTP response client 603 is disconnected, prolonging a preset time period and then performing a disconnection operation with the HTTP request client 601.
[0094] The HTTP response client 603 is used for establishing a TCP connection with the TCP transparent service server 602, receiving the HTTP request message sent by the TCP transparent service, generating an HTTP response message according to the HTTP request message, sending the HTTP response message to the TCP transparent service server 602, and interrupting the connection with the TCP transparent service server 602 after the sending is completed.
[0095] It can be understood that the HTTP communication system can include a plurality of HTTP request clients 601 and a plurality of HTTP response clients 603, the HTTP request clients 601 and the HTTP response clients 603 can be registered in the TCP transparent service server 602 in advance, obtain client identification, and be allocated IP addresses, so that the HTTP request clients 601 and the HTTP response clients 603 can communicate through the TCP transparent service server 602.
[0096] The HTTP communication system provided by the embodiment of the application adopts the TCP transparent service based HTTP short connection communication between the HTTP request client and the HTTP response client, when it is monitored that the HTTP response client is disconnected, prolongs a preset time period and then performs a disconnection operation with the HTTP request client. By using the method of the application, the HTTP request client request timeout problem caused by the TCP transparent service performing a disconnection operation on the HTTP request client before the HTTP response message is forwarded to the HTTP request client by the TCP transparent service can be avoided, the data loss risk and network congestion are reduced, and the stability of the HTTP communication is improved.
[0097] Embodiment five
[0098] According to an embodiment of the present application, there is provided a computer readable storage medium of the type described in embodiment three, storing a computer program which, when executed by a processor, causes the processor to perform the steps of the HTTP communication method described in embodiment one.
[0099] The product described above can perform the HTTP communication method described in any of embodiments one, and has the corresponding functional modules and beneficial effects of the method. Technical details not described in detail in the present embodiment can be referred to the HTTP communication method provided in embodiment one of the present application.
[0100] From the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, and of course can also be implemented by hardware. Based on such understanding, the above technical solutions, essentially or in terms of related art, can be embodied in the form of a software product, and the computer software product can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions to cause a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0101] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; under the idea of the present application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other changes of the different aspects of the present application as described above. In order to be brief, they are not provided in detail; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to some technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A HTTP communication method applied to a TCP transparent server, the TCP transparent server being responsible for opening a TCP connection between an HTTP request client and an HTTP response client, characterized in that, The HTTP response client is a third-party device with fixed service functions; The method comprises: receiving an HTTP request message sent by the HTTP request client; forwarding the HTTP request message to the HTTP response client; receiving an HTTP response message returned by the HTTP response client, wherein the HTTP response client actively disconnects after returning the HTTP response message; forwarding the HTTP response message to the HTTP request client; wherein, monitoring connection states of the HTTP request client and the HTTP response client, and when it is monitored that the HTTP response client disconnects, judging whether the HTTP response message returned by the HTTP response client is received, if yes, extending a preset time period and then performing a disconnection operation with the HTTP request client, and if no, immediately performing the disconnection operation with the HTTP request client; wherein, acquiring a time t1 at which the HTTP response message is forwarded to the HTTP request client and a time t2 at which the HTTP response client disconnects, and t2 is a time at which the TCP transparent server monitors that the HTTP response client disconnects; calculating a time difference Δt between t2 and t1; if Δt is less than a transmission time threshold, extending the preset time period and then performing the disconnection operation with the HTTP request client, and if Δt is greater than or equal to the transmission time threshold, immediately performing the disconnection operation with the HTTP request client; the transmission time threshold is a time required for transmitting a maximum data packet transmitted in a current service scenario between the HTTP request client and the HTTP response client; the preset time period is determined based on the transmission time threshold and the time difference Δt, wherein preset time period = transmission time threshold - Δt.
2. An HTTP communication device characterized by comprising: The HTTP communication device runs the HTTP communication method of claim 1, and the HTTP communication device comprises: an information receiving module configured to receive an HTTP request message sent by an HTTP request client and an HTTP response message returned by an HTTP response client; an information forwarding module configured to forward the HTTP request message to the HTTP response client and forward the HTTP response message to the HTTP request client; a monitoring processing module configured to monitor connection states of the HTTP request client and the HTTP response client, and when it is monitored that the HTTP response client disconnects, extend a preset time period and then perform a disconnection operation with the HTTP request client.
3. An electronic device comprising a memory, a processor, and a computer program stored on the memory to run on the processor, characterized in that, The processor implements the steps of the HTTP communication method of claim 1 when executing the program.
4. An HTTP communication system, characterized by The system comprises an HTTP request client, a TCP transparent server and an HTTP response client, wherein the HTTP response client is a third-party device with fixed service functions; The HTTP request client is configured to establish a TCP connection with the TCP transparent service end, send an HTTP request message to the TCP transparent service end, and the HTTP request message contains identification information of the HTTP response client; The TCP transparent service end is responsible for opening the TCP connection between the HTTP request client and the HTTP response client; The TCP transparent service end is further configured to receive the HTTP request message sent by the HTTP request client, establish a TCP connection with the HTTP response client according to the identification information of the HTTP response client contained in the HTTP request message, forward the HTTP request message to the HTTP response client, receive an HTTP response message returned by the HTTP response client, forward the HTTP response message to the HTTP request client, monitor the connection state of the HTTP request client and the HTTP response client, and when it is monitored that the HTTP response client is disconnected, determine whether the HTTP response message returned by the HTTP response client is received, if yes, perform the disconnection operation with the HTTP request client after prolonging a preset time length, and if no, immediately perform the disconnection operation with the HTTP request client; The TCP transparent service end is further configured to: Obtain a time t1 at which the HTTP response message is forwarded to the HTTP request client and a time t2 at which the HTTP response client is disconnected, and t2 is the time at which the TCP transparent service end monitors that the HTTP response client is disconnected; Calculate a time difference Δt between t2 and t1; If Δt is less than a transmission time length threshold, the disconnection operation with the HTTP request client is performed after prolonging the preset time length, and if Δt is greater than or equal to the transmission time length threshold, the disconnection operation with the HTTP request client is immediately performed; The transmission time length threshold is a time length required for transmitting a maximum data packet transmitted in a current service scenario between the HTTP request client and the HTTP response client; The preset time length is determined based on the transmission time length threshold and the time difference Δt, and the preset time length = transmission time length threshold - Δt; The HTTP response client is configured to establish a TCP connection with the TCP transparent service end, receive the HTTP request message sent by the TCP transparent service end, generate an HTTP response message according to the HTTP request message, send the HTTP response message to the TCP transparent service end, and immediately actively interrupt the connection with the TCP transparent service end after the sending is completed.
5. A computer readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the HTTP communication method in claim 1.
Citation Information
Patent Citations
Apparatus and method for reducing transmission delay of HTTP protocol and processing load of HTTP server in wireless communications network
US20140207960A1