Information push method, server, client, and storage medium
By establishing and storing the transmission control protocol connection on the server side, the problem of slow information push speed in the existing technology is solved, and faster information push speed is achieved.
Patent Information
- Application Number
- CN202210323009.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-29
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2042-03-29
Smart Images

Figure CN114900510B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of information push, and in particular to an information push method and a server, a client, and a storage medium. Background Art
[0002] With the rapid development of Internet technology, the usage of the network has gradually increased. In order to improve the loading speed of web pages, the server will predict the resources that the browser may use and push these resources to the client so that the browser can directly obtain them from the client memory where the browser is located when using the resources.
[0003] In the prior art, when a server receives a Hypertext Transfer Protocol (HTTP) request sent by a client, it obtains request information corresponding to the HTTP request and obtains the information to be pushed, and carries the information to be pushed when sending the request information to the client, thereby reducing the speed at which the server pushes information to the client. Summary of the invention
[0004] In order to solve the above technical problems, the embodiments of the present application hope to provide an information push method and a server, a client, and a storage medium, which can improve the speed of pushing information.
[0005] The technical solution of this application is implemented as follows:
[0006] The present application embodiment provides an information push method, which is applied to a server. The information push method includes:
[0007] When receiving a hypertext transfer request transmitted by a client, establishing a transmission control protocol connection with the client according to the hypertext transfer request;
[0008] adding the transmission control protocol connection to a storage pool, wherein the storage pool includes at least one transmission control protocol connection;
[0009] When the information to be pushed corresponding to the client is acquired, the information to be pushed is pushed to the client using the transmission control protocol connection in the storage pool.
[0010] The present application also provides an information push method, which is applied to a client. The information push method includes:
[0011] Sending a hypertext transfer request to a server; establishing a transmission control protocol connection with the server according to the hypertext transfer request;
[0012] The transmission control protocol connection is added to a connection pool, and the information to be pushed transmitted by the server is received according to the transmission control protocol connection in the connection pool.
[0013] An embodiment of the present application provides a server, wherein the server includes:
[0014] an establishing unit, configured to establish a transmission control protocol connection with the client according to the hypertext transfer request when receiving the hypertext transfer request transmitted by the client;
[0015] A first adding unit, configured to add the transmission control protocol connection to a storage pool, wherein the storage pool includes at least one transmission control protocol connection;
[0016] A pushing unit is used to push the information to be pushed to the client by using the transmission control protocol connection in the storage pool when the information to be pushed corresponding to the client is acquired.
[0017] An embodiment of the present application provides a client, the client comprising:
[0018] A transmission unit, configured to send a hypertext transfer request to a server, and to establish a transmission control protocol connection with the server according to the hypertext transfer request;
[0019] An adding unit, used for adding the transmission control protocol connection to a connection pool;
[0020] The second receiving unit is used to receive the information to be pushed transmitted by the server according to the transmission control protocol connection in the connection pool.
[0021] The present application embodiment further provides a server, the server comprising:
[0022] A first memory, a first processor and a first communication bus, wherein the first memory communicates with the first processor via the first communication bus, the first memory stores an information push program executable by the first processor, and when the information push program is executed, the above-mentioned information push method applied to the server is executed by the first processor.
[0023] The present application embodiment further provides a client, the client comprising:
[0024] A second memory, a second processor and a second communication bus, wherein the second memory communicates with the second processor via the second communication bus, and the second memory stores an information push program executable by the second processor. When the information push program is executed, the information push method applied to the client described above is executed by the second processor.
[0025] An embodiment of the present application provides a storage medium having a computer program stored thereon, which is applied to a client and a server, and is characterized in that when the computer program is executed by a first processor, the above-mentioned information push method applied to the server is implemented; when the computer program is executed by a second processor, the above-mentioned information push method applied to the client is implemented.
[0026] The embodiment of the present application provides an information push method and a server, a client, and a storage medium. The information push method includes: upon receiving a hypertext transfer request transmitted by a client, establishing a transmission control protocol connection with the client according to the hypertext transfer request; adding the transmission control protocol connection to a storage pool, wherein the storage pool includes at least one transmission control protocol connection; upon obtaining information to be pushed corresponding to the client, using the transmission control protocol connection in the storage pool to push the information to be pushed to the client. By adopting the above method implementation scheme, after the server establishes a transmission control protocol connection with the client, the server adds the transmission control protocol connection to the storage pool and uses the storage pool to store the transmission control protocol connection, so that when the server obtains the information to be pushed, the server can directly use the transmission control protocol connection to push the information to be pushed to the client, thereby improving the speed of pushing the information to be pushed. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] FIG1( a ) is a schematic diagram of a HTTP persistent connection in the prior art provided by an embodiment of the present application;
[0028] FIG. 1( b ) is a schematic diagram of an HTTP persistent connection in the prior art provided by an embodiment of the present application Figure 2 ;
[0029] FIG. 1( c ) is a schematic diagram of an HTTP persistent connection in the prior art provided by an embodiment of the present application Figure 3 ;
[0030] Figure 2 A schematic diagram of an HTTP / 2 service push protocol in the prior art provided in an embodiment of the present application;
[0031] Figure 3 A flow chart of an information push method provided in an embodiment of the present application;
[0032] Figure 4 A method for pushing information provided in this application embodiment Figure 2 ;
[0033] Figure 5 A schematic diagram of an exemplary improved HTTP / 2 service push protocol provided in an embodiment of the present application;
[0034] Figure 6 A schematic diagram of an exemplary information push structure provided in an embodiment of the present application;
[0035] Figure 7 A schematic diagram of the structure of a server provided in an embodiment of the present application;
[0036] Figure 8 A schematic diagram of the composition structure of a server provided in an embodiment of the present application Figure 2 ;
[0037] Fig. 9 A schematic diagram of the structure of a client provided in an embodiment of the present application;
[0038] Fig.10 A schematic diagram of a client structure provided in an embodiment of the present application Figure 2 . DETAILED DESCRIPTION
[0039] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. It should be understood that the specific embodiments described here are only used to explain the present application and are not used to limit the present application.
[0040] As shown in Figure 1(a): HTTP1.0 has no multiplexing, that is, when the server receives an HTTP request sent by the client, it obtains the request information corresponding to the HTTP request; transmits the request information to the client, and there is a period of time between the client receiving the request information and the client sending the next HTTP request; as shown in Figure 1(b): HTTP1.1 is connection multiplexing, when the server receives an HTTP request sent by the client, it obtains the request information corresponding to the HTTP request; transmits the request information to the client, and there is no interval between the client receiving the request information and the client sending the next HTTP request; as shown in Figure 1(c): HTTP / 2 is multiplexing, when the server receives an HTTP request sent by the client, it obtains the request information corresponding to the HTTP request; transmits the request information to the client, and the client can send the next HTTP request to the server before the client receives the request information.
[0041] like Figure 2As shown: the client sends a hypertext transfer request (index.html request, specifically including: stream 1type: 1; method get; path / index.html; ...) to the server; the server obtains request information corresponding to the HTTP request (stream 1type: 1; date xxxx; cache-controller...), and the server also obtains information to be pushed, and the server transmits the request information and the information to be pushed to the client; wherein, the information to be pushed includes index.css information and index.js information. It should be noted that the index.css information includes Push promise frame-push preamble (stream 2 type: 5; method get; path / index.css; authority ip:443; schemehttps), Header frame-Header (stream 2 type: 1; status 200; content-type xx; content-length xxx; ...), and Date frame-body (stream 2 type: 0; body{...}...); the index.js information includes Push promise frame-push preamble (stream 4 type: 5; method get; path / index.js; authority ip:443; scheme https), Header frame-Header (stream 4 type: 1; status 200; content-type xx; content-length xxx; ...), and Date frame-body (stream 4 type: 0; function click(){...}...).
[0042] The embodiment of the present application provides an information push method, which is applied to a server. Figure 3 A flow chart of an information push method provided in an embodiment of the present application, such as Figure 3 As shown, the information push method may include:
[0043] S101. When a hypertext transfer request transmitted by a client is received, a transmission control protocol connection is established with the client according to the hypertext transfer request.
[0044] An information push method provided in an embodiment of the present application is suitable for a scenario in which a server sends information to be pushed to a client.
[0045] In the embodiments of the present application, the server can be implemented in various forms. For example, the server described in the present application may include devices such as mobile phones, cameras, tablet computers, laptop computers, PDAs, portable media players (PMPs), navigation devices, wearable devices, smart bracelets, pedometers, and devices such as digital TVs, desktop computers, and servers.
[0046] In the embodiment of the present application, the hypertext transfer request may be an HTTP request. The transmission control protocol connection may be a transmission control protocol (TCP) connection.
[0047] In the embodiment of the present application, the process of the server establishing a transmission control protocol connection with the client according to a hypertext transfer request is a method of establishing a TCP connection between the server and the client in the prior art, and the specific embodiment of the present application is not elaborated here.
[0048] In an embodiment of the present application, the client is a client that integrates an open source network library that supports HTTP / 2; and the client has turned on the push switch of the HTTP / 2Setting frame.
[0049] In an embodiment of the present application, in the process of establishing a transmission control protocol connection between the server and the client based on a hypertext transfer request, a unique code (uuid) / user identity (userid) of the connection can be set for the server, and an HTTP request path (Path) with a response status code of 204 can be used to establish a TCP connection when the application (Application, App) is started (if the App starts to send an Http request to the target server, this Path is not defined).
[0050] It should be noted that a request with a response status code of 204 means a request with no response information.
[0051] In the embodiment of the present application, the server push server service is divided into push work (Worker) and push management (Manager), that is, the server is divided into push Worker and push Manager. Among them, Worker is used to collect and manage HTTP TCP long connections, send push messages and reverse proxy target server's Http requests; Manager is used to register and manage Worker, issue push tasks to Worker, provide content management system (CMS) application program interface (Application Programming Interface, API), etc. Manager and Worker can communicate through message queue (MQ).
[0052] In the embodiment of the present application, the server first generates a server certificate (Secure socket layer, SSL), builds a Netty HTTP / 2 container as a push Worker, turns on Http gzip compression, uses port 443, and responds to HTTP / 2 network requests; the server push Worker adds a reverse proxy function, and uses the configuration file push.properties to read the target server port (port). The Worker reads the port number of the target server port at startup and reverse proxies the http request of the target server (only one network access to http: / / localhost:port / {{path}} is made).
[0053] It should be noted that Netty is an asynchronous event-driven network application framework and tool used to implement HTTP / 2 protocol parsing and response.
[0054] It should be noted that by building a push manager and integrating message queues (MQ), push tasks can be issued to push workers through MQ, and cms push and api interfaces can be provided. Deploy push workers and push managers, and set the push.properties configuration file with the port used by the target server (since port 443 is used for push workers, the port here can be other ports except port 443), and deploy push workers to the target machine. Push managers can be deployed separately.
[0055] It should also be noted that CMS push means: pushing a task on a web page.
[0056] In an embodiment of the present application, a frequently accessed HTTP / 2 TCP connection is reused as a TCP long connection channel, the HTTP / 2 server is called a target server, and the host where it is located is called a target machine.
[0057] S102: Add a transmission control protocol connection to a storage pool, where the storage pool includes at least one transmission control protocol connection.
[0058] In an embodiment of the present application, after the server establishes a transmission control protocol connection with the client according to a hypertext transfer request, the server adds the transmission control protocol connection to the storage pool.
[0059] It should be noted that the storage pool includes at least one transmission control protocol connection.
[0060] In the embodiment of the present application, the storage pool may be a global Map; the storage pool may also be other storage areas; the specific storage pool may be determined based on actual conditions, and the embodiment of the present application does not limit this.
[0061] In an embodiment of the present application, before the server adds the Transmission Control Protocol connection to the storage pool, the server will also configure the correspondence between the Transmission Control Protocol connection and the client; accordingly, the process of the server adding the Transmission Control Protocol connection to the storage pool includes: the server adds the correspondence between the Transmission Control Protocol connection and the client and the Transmission Control Protocol connection to the storage pool.
[0062] In an embodiment of the present application, after the server establishes the TCP connection, the server can establish a transmission control protocol connection between the server and the client at the end of the HTTP / 2 request transmission (Netty HTTP / 2OnSettingsAckRead callback). The server then puts the TCP connection into a storage pool (global Map), where the key of the global Map is the client uuid / userid parameter carried by the Http request, and the value of the Map is the TCP connection (userid is a tcp list).
[0063] In an embodiment of the present application, after the server adds the transmission control protocol connection to the storage pool, the server will also delete the transmission control protocol connection from the storage pool when the transmission control protocol connection is disconnected.
[0064] S103: When the information to be pushed corresponding to the client is obtained, the information to be pushed is pushed to the client using the transmission control protocol connection in the storage pool.
[0065] In an embodiment of the present application, after the server adds the transmission control protocol connection to the storage pool, when the server obtains the information to be pushed corresponding to the client, the server uses the transmission control protocol connection in the storage pool to push the information to be pushed to the client.
[0066] In an embodiment of the present application, the information to be pushed may be a Cascading Style Sheets (CSS) resource; the information to be pushed may also be a javascript (JS) resource; the information to be pushed may also be other information; the specific information to be pushed may be determined based on actual conditions, and the embodiment of the present application does not limit this.
[0067] It should be noted that the information to be pushed is information that will be used by the client.
[0068] In an embodiment of the present application, the process of a server pushing information to be pushed to a client using a transmission control protocol connection in a storage pool includes: the server obtains an original header frame and an original information frame corresponding to the original push service; the server determines a client push path corresponding to the information to be pushed; and adds the client push path to the original header frame to obtain a header frame; the server adds the information to be pushed to the original information frame to obtain an information frame; the server obtains the service to be pushed based on the information frame and the header frame; and uses the transmission control protocol connection to push the service to be pushed to the client.
[0069] In an embodiment of the present application, the server adds the information to be pushed to the original information frame to obtain a process of the information frame, including the server encrypting the information to be pushed to obtain encrypted information, and then the server adds the encrypted information to the original information frame to obtain an information frame; the server can also compress the information to be pushed to obtain compressed information, and then the server adds the compressed information to the original information frame to obtain an information frame; the server can also directly add the information to be pushed to the original information frame to obtain an information frame; the specific server adds the information to be pushed to the original information frame to obtain the process of the information frame can be determined according to actual conditions, and the embodiment of the present application does not limit this.
[0070] It should be noted that the server encrypts the push information to obtain the encrypted information in a manner that the server uses the Advanced Encryption Standard (AES) to encrypt the push information to obtain the encrypted information; the server may also use other methods to encrypt the push information to obtain the encrypted information; the specific method in which the server encrypts the push information to obtain the encrypted information can be determined based on actual conditions, and the embodiments of the present application do not limit this.
[0071] It should also be noted that the server uses AES to encrypt the push information, and the encryption key when obtaining the encrypted information can be dynamically generated by using the magic number, device uuid, stream ID and path specified algorithm.
[0072] In an embodiment of the present application, when the push worker receives a push task issued by the push manager through a message queue (MQ), the server obtains the transmission control protocol connection (TCP connection) corresponding to the client from the storage pool (global Map), uses the client push path to add it to the original header frame (header frame) and sets the status (status) value in the header frame to 200, adds the information to be pushed (data AES encrypted) to the information frame (Data frame), and pushes the header frame and information frame to the client.
[0073] In an embodiment of the present application, the server also modifies Netty's HTTP / 2 parsing source code and deletes the relevant checksum logic processing corresponding to the Push Promise frame.
[0074] It should be noted that, in the process of the server pushing the information to be pushed to the client, three frames will be sent to the client in a connected manner. The first frame is a Push Promise frame, which contains the Path, Method (predicted http method), Scheme, Authority, push stream ID (even number) and active network request stream ID (odd number) of the resource to be pushed. When the client receives the Push Promise frame, it will check whether the client has enabled push, whether the current state of the main request stream can receive Push, and establish a mapping relationship between the Path and the push stream ID. After that, the server will also send the second frame, namely the Header (Http header), and the third frame, namely the Data (Http body) frame. In the embodiment of the present application, the Push Promise frame (i.e., the Push Promise frame is not sent) and the subsequent checks, related checks and logical processing corresponding to the Push Promise frame are deleted, and the Path in the Push Promise frame is added to the Header frame and sent down, and only the Header and Data frames are used to complete the push process of the information to be pushed.
[0075] In an embodiment of the present application, after the server pushes the information to be pushed to the client using the transmission control protocol connection in the storage pool, the server also receives a push success response message transmitted by the client.
[0076] It should be noted that the response information of successful push can be an ACK frame; the response information of successful push can also be other forms of response information; the specific response information of successful push can be determined according to actual conditions, and the embodiments of the present application do not limit this.
[0077] In the embodiment of the present application, the server is also configured to parse and process the push success receipt Ack frame (0x0A). The ID of the stream corresponding to the Ack frame is the ID of the push stream.
[0078] It should be noted that the format of the ACK frame is the same as the format of the Ping frame.
[0079] It can be understood that after the server establishes a transmission control protocol connection with the client, the server adds the transmission control protocol connection to the storage pool and uses the storage pool to store the transmission control protocol connection, so that when the server obtains the information to be pushed, the server can directly use the transmission control protocol connection to push the information to be pushed to the client, thereby improving the speed of pushing the information to be pushed.
[0080] The present application embodiment further provides an information push method, which is applied to a client. Figure 4 A method for pushing information provided in this application embodiment Figure 2 ,like Figure 4 As shown, the information push method may include:
[0081] S201, sending a hypertext transfer request to a server; establishing a transmission control protocol connection with the server according to the hypertext transfer request.
[0082] An information push method provided in an embodiment of the present application is suitable for a scenario in which a server sends information to be pushed to a client.
[0083] In the embodiments of the present application, the client can be implemented in various forms. For example, the client described in the present application may include devices such as mobile phones, cameras, tablet computers, laptop computers, PDAs, portable media players (PMPs), navigation devices, wearable devices, smart bracelets, pedometers, and devices such as digital TVs and desktop computers.
[0084] In the embodiment of the present application, the hypertext transfer request may be an HTTP request. The transmission control protocol connection may be a transmission control protocol (TCP) connection.
[0085] In the embodiment of the present application, the process of the server establishing a transmission control protocol connection with the client according to a hypertext transfer request is a method of establishing a TCP connection between the server and the client in the prior art, and the specific embodiment of the present application is not elaborated here.
[0086] In an embodiment of the present application, the client is a client that integrates an open source network library that supports HTTP / 2; and the client has turned on the push switch of the HTTP / 2Setting frame.
[0087] In the embodiment of the present application, the client modifies the network library, that is, deletes the Push Promise frame and the related checks before and after, and directly parses the header frame (Header) and information frame (Data) in the service to be pushed when the Stream ID is an even number.
[0088] It should be noted that, in the process of the server pushing the information to be pushed to the client, three frames will be sent to the client in a connected manner. The first frame is a Push Promise frame, which contains the Path, Method (predicted http method), Scheme, Authority, push stream ID (even number) and active network request stream ID (odd number) of the resource to be pushed. When the client receives the Push Promise frame, it will check whether the client has enabled push, whether the current state of the main request stream can receive Push, and establish a mapping relationship between the Path and the push stream ID. After that, the server will also send the second frame, namely the Header (Http header), and the third frame, namely the Data (Http body) frame. In the embodiment of the present application, the Push Promise frame (i.e., the Push Promise frame is not sent) and the subsequent checks, related checks and logical processing corresponding to the Push Promise frame are deleted, and the Path in the Push Promise frame is added to the Header frame and sent down, and only the Header and Data frames are used to complete the push process of the information to be pushed.
[0089] In an embodiment of the present application, after the client sends a hypertext transfer request to the server, the client will also obtain the sending time of the hypertext transfer request; the client adjusts the first time of sending heartbeat information to the server next time according to the sending time; when the first time arrives, the client sends the next heartbeat information to the server.
[0090] In the embodiment of the present application, HTTP / 2 provides a heartbeat (PING) mechanism to maintain the connection and calculate the RTT round-trip time. The RTT time can be optimized by reusing the PING. The client enables the heartbeat function of HTTP / 2, treats the Http request as a heartbeat, and optimizes the next heartbeat sending interval according to the network round-trip time (RTT) of the heartbeat frame.
[0091] It should be noted that the client can send a heartbeat frame to the server at a preset time period, such as a heartbeat frame at an interval of 5 minutes, that is, a heartbeat frame is sent to the server once every 1 minute, and then a heartbeat frame is sent to the server again after an interval of 5 minutes. At the 7th minute, a hypertext transfer request is received, then a hypertext transfer request is sent to the server at the 7th minute, and after 5 minutes, that is, at the 12th minute, heartbeat frames continue to be sent to the server,…
[0092] S202: Add a transmission control protocol connection to a connection pool, and receive information to be pushed transmitted by the server according to the transmission control protocol connection in the connection pool.
[0093] In an embodiment of the present application, the client sends a hypertext transfer request to the server; after establishing a transmission control protocol connection with the server based on the hypertext transfer request, the client can add the transmission control protocol connection to the connection pool, and receive the information to be pushed transmitted by the server based on the transmission control protocol connection in the connection pool.
[0094] In an embodiment of the present application, the connection pool includes at least one transmission control protocol connection.
[0095] In an embodiment of the present application, the client puts the TCP long connection (Transmission Control Protocol connection) of HTTP / 2 used for push into a reused connection pool (connection pool), adds it to the whitelist, never actively releases or eliminates the Transmission Control Protocol connection, and adds TCP anti-killing and automatic restart (if support for App offline push is required).
[0096] In an embodiment of the present application, the process of the client receiving the information to be pushed transmitted by the server according to the transmission control protocol connection in the connection pool also includes: the client receiving the service to be pushed transmitted by the server according to the transmission control protocol connection; accordingly, the process of the client receiving the information to be pushed transmitted by the server according to the transmission control protocol connection in the connection pool includes: the client obtains the header frame and the information frame from the service to be pushed; the client obtains the client push path from the header frame; and obtains the information to be pushed from the information; the client transmits the information to be pushed to the target application corresponding to the client push path.
[0097] In an embodiment of the present application, the client provides a push information registration and information distribution entry. When the client receives the service to be pushed, the client first decrypts the encrypted information in the information frame (Data frame) to obtain the information to be pushed, and then the client transmits the information to be pushed to the corresponding registrant (such as an application) according to the path (Path) in the header frame (Header).
[0098] In an embodiment of the present application, after the client receives the information to be pushed transmitted by the server according to the transmission control protocol connection in the connection pool, the client also sends a response message of successful push to the server.
[0099] In an embodiment of the present application, the response information of a successful push may be an ACK frame; the response information of a successful push may also be response information in other forms; the specific response information of a successful push may be determined based on actual conditions, and the embodiment of the present application does not limit this.
[0100] In the embodiment of the present application, when the client receives the Header frame and the Data frame, the client sends an ACK frame (frame type 0x0A) to the server, wherein the format of the ACK frame is the same as the format of the Ping frame. The ID of the stream corresponding to the ACK frame is the ID of the push stream.
[0101] For example, the Push protocol is Figure 5 As shown: the client sends a hypertext transfer request (index.html request, specifically including: stream 1 type: 1; method get; path / index.html; ...) to the server; the server obtains the request information corresponding to the HTTP request (stream 1 type: 1; date xxxx; cache-controller...), and the server transmits the request information to the client; the server establishes a transmission control protocol connection with the client according to the hypertext transfer request; the server adds the transmission control protocol connection to the storage pool; the client adds the transmission control protocol connection to the connection pool, and when the server obtains the information to be pushed corresponding to the client (x.json or xx.pb), the server uses the transmission control protocol connection in the storage pool to push the information to be pushed to the client, and when the client receives the information to be pushed, the client sends a response message (ACK frame) of successful push to the server.
[0102] It should be noted that x.json includes: push service identifier (stream 2n type: 1; status: 200; path / service xxx) and push message (stream 2n type: 0{"xx"; "xxx"}). xx.pb includes: push service identifier (stream 2n+2 type: 1; status: 200; path / service xxxxx) and push message (stream 2n+2 type: 0; 0101111000...).
[0103] For example, Figure 6 As shown: the push manager obtains the push CMS (including information source: businessid; information content (msg): hello; client (user): xxxx), and the push manager queries the push path (path) in the database (DB) according to the businessid. Then the push manager creates a push task based on the information obtained, and broadcasts the push task (path: / xxx; client: xxxx; msg: 010100111...) to the push workers of each target machine. The push worker obtains the information to be pushed from the push task (header frame, data frame: aes(msg)), and pushes the push information to the corresponding client (APP). The push worker can also be connected to the target server Http or nginx through a reverse proxy. The server also receives the Http request transmitted by the APP through the push worker.
[0104] It can be understood that after the client establishes a transmission control protocol connection with the server based on the hypertext transfer request, the client adds the transmission control protocol connection to the connection pool and uses the connection pool to store the transmission control protocol connection, so that the client can use the transmission control protocol connection to promptly receive the information to be pushed sent by the server, thereby improving the speed of pushing the information to be pushed.
[0105] Based on the same inventive concept of the information push method applied in the server, the embodiment of the present application provides a server 1, corresponding to an information push method applied in the server; Figure 7 A schematic diagram of a composition structure of a server provided in an embodiment of the present application is shown in FIG. 1 . The server 1 may include:
[0106] An establishing unit 11 is used to establish a transmission control protocol connection with the client according to the hypertext transfer request when a hypertext transfer request transmitted by the client is received;
[0107] A first adding unit 12, configured to add the transmission control protocol connection to a storage pool, wherein the storage pool includes at least one transmission control protocol connection;
[0108] The pushing unit 13 is configured to push the information to be pushed to the client by using the transmission control protocol connection in the storage pool when the information to be pushed corresponding to the client is acquired.
[0109] In some embodiments of the present application, the server further includes a first obtaining unit and a determining unit;
[0110] The first acquisition unit is used to acquire the original header frame and the original information frame corresponding to the original push service;
[0111] The determining unit is used to determine the client push path corresponding to the information to be pushed;
[0112] The first adding unit 12 is used to add the client push path to the original header frame to obtain a header frame; add the information to be pushed to the original information frame to obtain an information frame; and obtain the service to be pushed according to the information frame and the header frame;
[0113] The push unit 13 is used to push the service to be pushed to the client by using the transmission control protocol connection.
[0114] In some embodiments of the present application, the server further includes a configuration unit;
[0115] The configuration unit is used to configure the corresponding relationship between the transmission control protocol connection and the client;
[0116] Correspondingly, the first adding unit 12 is used to add the corresponding relationship between the transmission control protocol connection and the client and the transmission control protocol connection to the storage pool.
[0117] In some embodiments of the present application, the server further includes a deletion unit;
[0118] The deleting unit is used to delete the transmission control protocol connection from the storage pool when the transmission control protocol connection is disconnected.
[0119] In some embodiments of the present application, the server further includes a first receiving unit;
[0120] The first receiving unit is used to receive push success response information transmitted by the client.
[0121] It should be noted that, in actual applications, the above-mentioned establishment unit 11, the first adding unit 12 and the pushing unit 13 can be implemented by the first processor 14 on the server 1, specifically a CPU (Central Processing Unit), an MPU (Microprocessor Unit), a DSP (Digital Signal Processing) or a field programmable gate array (FPGA); the above-mentioned data storage can be implemented by the first memory 15 on the server 1.
[0122] The present application embodiment also provides a server 1, such as Figure 8 As shown, the server 1 includes: a first processor 14, a first memory 15 and a first communication bus 16. The first memory 15 communicates with the first processor 14 through the first communication bus 16. The first memory 15 stores a program executable by the first processor 14. When the program is executed, the information push method described above is executed by the first processor 14.
[0123] In practical applications, the first memory 15 may be a volatile memory, such as a random access memory (RAM); or a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk (HDD) or a solid-state drive (SSD); or a combination of the above types of memories, and provide instructions and data to the first processor 14.
[0124] An embodiment of the present application provides a computer-readable storage medium having a computer program thereon, and when the program is executed by the first processor 14, the information push method as described above is implemented.
[0125] It can be understood that after the server establishes a transmission control protocol connection with the client, the server adds the transmission control protocol connection to the storage pool and uses the storage pool to store the transmission control protocol connection, so that when the server obtains the information to be pushed, the server can directly use the transmission control protocol connection to push the information to be pushed to the client, thereby improving the speed of pushing the information to be pushed.
[0126] The embodiment of the present application provides a client 2, corresponding to an information push method applied in the client; Fig. 9 A schematic diagram of a structure of a client provided in an embodiment of the present application is shown in FIG. 1 . The client 2 may include:
[0127] The transmission unit 21 is used to send a hypertext transfer request to the server, so as to establish a transmission control protocol connection with the server according to the hypertext transfer request;
[0128] A second adding unit 22, configured to add the transmission control protocol connection to a connection pool;
[0129] The second receiving unit 23 is configured to receive the information to be pushed transmitted by the server according to the transmission control protocol connection in the connection pool.
[0130] In some embodiments of the present application, the second receiving unit 23 is used to connect and receive the service to be pushed transmitted by the server according to the transmission control protocol;
[0131] Correspondingly, the client further includes a second acquisition unit;
[0132] The second acquisition unit is used to acquire a header frame and an information frame from the service to be pushed; acquire a client push path from the header frame; and acquire the information to be pushed from the information;
[0133] The transmission unit 21 is used to transmit the information to be pushed to the target application corresponding to the client push path.
[0134] In some embodiments of the present application, the client further includes an adjustment unit and a sending unit;
[0135] The second acquisition unit is used to acquire the sending time of the hypertext transfer request;
[0136] The adjusting unit is used to adjust the first time of sending the heartbeat information to the server next time according to the sending time;
[0137] The sending unit is used to send the next heartbeat information to the server when the first time arrives.
[0138] In some embodiments of the present application, the sending unit is used to send a push success response message to the server.
[0139] It should be noted that, in actual applications, the above-mentioned transmission unit 21, the second adding unit 22 and the second receiving unit 23 can be implemented by the second processor 24 on the client 2, specifically a CPU (Central Processing Unit), an MPU (Microprocessor Unit), a DSP (Digital Signal Processing) or a field programmable gate array (FPGA); the above-mentioned data storage can be implemented by the second memory 25 on the client 2.
[0140] The present application embodiment also provides a client 2, such as Fig.10 As shown, the client 2 includes: a second processor 24, a second memory 25 and a second communication bus 26. The second memory 25 communicates with the second processor 24 via the second communication bus 26. The second memory 25 stores a program executable by the second processor 24. When the program is executed, the information push method described above is executed by the second processor 24.
[0141] In practical applications, the second memory 25 may be a volatile memory, such as a random access memory (RAM); or a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or a combination of the above types of memories, and provide instructions and data to the second processor 24.
[0142] An embodiment of the present application provides a computer-readable storage medium having a computer program thereon, and when the program is executed by the second processor 24, the information push method as described above is implemented.
[0143] It can be understood that after the client establishes a transmission control protocol connection with the server based on the hypertext transfer request, the client adds the transmission control protocol connection to the connection pool and uses the connection pool to store the transmission control protocol connection, so that the client can use the transmission control protocol connection to promptly receive the information to be pushed sent by the server, thereby improving the speed of pushing the information to be pushed.
[0144] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of hardware embodiments, software embodiments, or embodiments in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.
[0145] The present application is described with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, and the combination of the process and / or box in the flowchart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one process or multiple processes in the flowchart and / or one box or multiple boxes in the block diagram.
[0146] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0147] These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0148] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application.
Claims
1. An information push method, characterized in that: The method comprises: When receiving a hypertext transfer request transmitted by a client, establishing a transmission control protocol connection with the client according to the hypertext transfer request; adding the transmission control protocol connection to a storage pool, the storage pool including at least one transmission control protocol connection; the server including the storage pool; When the information to be pushed corresponding to the client is acquired, the information to be pushed is pushed to the client by using the transmission control protocol connection in the storage pool; Wherein, the using the transmission control protocol connection in the storage pool to push the information to be pushed to the client includes: Add the client push path corresponding to the information to be pushed to the original header frame to obtain a header frame; Add the information to be pushed to the original information frame to obtain an information frame; The header frame and the information frame are pushed to the client using the transmission control protocol.
2. The method according to claim 1, characterized in that The using the transmission control protocol connection in the storage pool to push the information to be pushed to the client includes: Get the original header frame and original information frame corresponding to the original push service; Determine the client push path corresponding to the information to be pushed; The service to be pushed is obtained according to the information frame and the header frame; and the service to be pushed is pushed to the client by using the transmission control protocol connection.
3. The method according to claim 1, characterized in that Before adding the transmission control protocol connection to the storage pool, the method further includes: Configuring a correspondence between the transmission control protocol connection and the client; Accordingly, the adding the transmission control protocol connection to the storage pool includes: The corresponding relationship between the transmission control protocol connection and the client and the transmission control protocol connection are added to the storage pool.
4. The method according to claim 1, characterized in that: After adding the transmission control protocol connection to the storage pool, the method further includes: In case the transmission control protocol connection is disconnected, the transmission control protocol connection is deleted from the storage pool.
5. The method according to claim 1, characterized in that After pushing the information to be pushed to the client by using the transmission control protocol connection in the storage pool, the method further includes: Receive push success response information transmitted by the client.
6. An information push method, characterized in that: The method comprises: Sending a hypertext transfer request to a server; establishing a transmission control protocol connection with the server according to the hypertext transfer request; Add the transmission control protocol connection to the connection pool, and receive the header frame and information frame transmitted by the server using the transmission control protocol in the storage pool according to the transmission control protocol connection in the connection pool; wherein the server includes the storage pool; the header frame is obtained by adding the client push path corresponding to the information to be pushed to the original header frame; and the information frame is obtained by adding the information to be pushed to the original information frame.
7. The method according to claim 6, characterized in that The receiving the information to be pushed transmitted by the server according to the transmission control protocol connection in the connection pool also includes: Receive the service to be pushed transmitted by the server according to the transmission control protocol connection; Correspondingly, receiving the information to be pushed transmitted by the server according to the transmission control protocol connection in the connection pool includes: Obtaining a header frame and an information frame from the service to be pushed; Obtaining a client push path from the header frame; and obtaining the information to be pushed from the information; The information to be pushed is transmitted to the target application corresponding to the client push path.
8. The method according to claim 6, characterized in that After sending the hypertext transfer request to the server, the method further comprises: Obtaining the sending time of the hypertext transfer request; Adjust the first time of sending the heartbeat information to the server next time according to the sending time; When the first time arrives, the next heartbeat information is sent to the server.
9. The method according to claim 6, characterized in that After receiving the information to be pushed transmitted by the server according to the transmission control protocol connection in the connection pool, the method further includes: Send a push success response message to the server.
10. A server, characterized in that: The server comprises: an establishing unit, configured to establish a transmission control protocol connection with the client according to the hypertext transfer request when receiving the hypertext transfer request transmitted by the client; A first adding unit is used to add the transmission control protocol connection to a storage pool, wherein the storage pool includes at least one transmission control protocol connection; the server includes the storage pool; A push unit is used to add the client push path corresponding to the information to be pushed to the original header frame to obtain a header frame when the information to be pushed corresponding to the client is obtained; add the information to be pushed to the original information frame to obtain an information frame; and use the transmission control protocol connection in the storage pool to push the header frame and the information frame to the client.
11. A client, characterized in that: The client comprises: A transmission unit, configured to send a hypertext transfer request to a server, and to establish a transmission control protocol connection with the server according to the hypertext transfer request; A second adding unit, configured to add the transmission control protocol connection to a connection pool; A second receiving unit is used to receive the header frame and information frame transmitted by the server using the transmission control protocol in the storage pool according to the transmission control protocol connection in the connection pool; wherein the server includes the storage pool; the header frame is obtained by adding the client push path corresponding to the information to be pushed to the original header frame; and the information frame is obtained by adding the information to be pushed to the original information frame.
12. A server, characterized in that: The server comprises: A first memory, a first processor and a first communication bus, wherein the first memory communicates with the first processor via the first communication bus, the first memory stores an information push program executable by the first processor, and when the information push program is executed, the method described in any one of claims 1 to 5 is performed by the first processor.
13. A client, characterized in that: The client comprises: A second memory, a second processor and a second communication bus, wherein the second memory communicates with the second processor via the second communication bus, and the second memory stores an information push program executable by the second processor, and when the information push program is executed, the method described in any one of claims 6 to 9 is executed by the second processor.
14. A storage medium having a computer program stored thereon, applied to a server and a client, characterized in that: When the computer program is executed by a first processor, the method described in any one of claims 1 to 5 is implemented. When the computer program is executed by a second processor, the method described in any one of claims 6 to 9 is implemented.
