Web page heartbeat connection maintenance method and related equipment
By analyzing the historical traffic data of the server, filtering static access requests and verifying the validity of cookies, controlling the client to send access requests at intervals, solving the problem of probes required for the existing technology center jump connection maintenance, and realizing resource-saving connection maintenance.
Patent Information
- Application Number
- CN202011272791.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-12
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2040-11-12
AI Technical Summary
In the prior art, maintaining the heartbeat connection between the client and the server requires installing probes on the client to occupy processing resources and affecting device stability.
By obtaining the historical traffic data of the access server, filtering out the target traffic of the static access request, verifying the validity of the cookie carried by the target access request. If it is valid, during the validity period of the cookie, the target client will control the interval to send the target access request to the server to maintain the heartbeat connection.
It realizes that the heartbeat connection is maintained without installing a probe on the client side, avoiding additional resource usage and has a wide range of applications.
Smart Images

Figure CN114500631B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer and communication technology, and in particular to a method for maintaining a heartbeat connection of a web page and related equipment. Background Art
[0002] In the related art, in order to maintain the heartbeat connection between the client and the server, a probe (a kind of software) needs to be installed on the client, and then the probe is used to actively send heartbeat requests regularly. This heartbeat maintenance method is implemented based on the probe installed in the client. The installed probe will occupy processing resources and may affect the stability of the device. Therefore, a method for maintaining a heartbeat connection without the help of a probe is urgently needed. Summary of the invention
[0003] The embodiments of the present application provide a method for maintaining a heartbeat connection of a web page and related devices, so as to provide a method for maintaining a heartbeat connection without the need for a probe.
[0004] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.
[0005] According to one aspect of an embodiment of the present application, a method for maintaining a heartbeat connection of a web page is provided, comprising: obtaining historical traffic data of accessing a server; performing traffic screening on the historical traffic data to obtain target traffic, wherein a target access request in the target traffic is a static access request; verifying the validity of a cookie carried by the target access request in the server; if the cookie carried by the target access request has not expired in the server, then within the validity period of the cookie carried by the target access request, controlling a target client corresponding to the target access request to send the target access request to the server at intervals to maintain a heartbeat connection between the target client and the server.
[0006] According to one aspect of an embodiment of the present application, a device for maintaining a heartbeat connection of a web page is provided, the device comprising: a historical traffic data acquisition module, used to acquire historical traffic data of a target client accessing a server; a traffic screening module, used to screen the historical traffic data to obtain target traffic, wherein the target access request in the target traffic is a static access request; a validity verification module, used to verify the validity of a cookie carried by the target access request in the server; and a control module, used to control the target client to send the target access request to the server at intervals within the validity period of the cookie carried by the target access request if the cookie carried by the target access request has not expired in the server.
[0007] According to one aspect of an embodiment of the present application, an electronic device is provided, including: a processor; a memory, wherein computer-readable instructions are stored in the memory, and when the computer-readable instructions are executed by the processor, the method described above is implemented.
[0008] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor, the method described above is implemented.
[0009] In the scheme of the present application, the target traffic corresponding to the access request being a static access request is screened out based on the historical traffic data of the access server, and when the Cookie in the target traffic has not expired, the target client corresponding to the target access request is controlled to resend the target access request to the server at intervals, thereby maintaining the heartbeat connection between the target client and the server based on the historical traffic data, without the need to install a probe in the target client to maintain the heartbeat connection, and without the need to occupy additional resources in the client, and has a wide range of applications.
[0010] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0012] Figure 1 A schematic diagram showing an application scenario to which the technical solution of the embodiments of the present application can be applied;
[0013] Figure 2 is a flow chart of a method for maintaining a web page heartbeat connection according to an embodiment of the present application;
[0014] Figure 3 is a flowchart showing step 220 according to an embodiment of the present application;
[0015] Figure 4 is a flowchart showing step 230 according to an embodiment of the present application;
[0016] Figure 5 is a flow chart of a method for maintaining a web page heartbeat connection according to another embodiment of the present application;
[0017] Figure 6is a flow chart of a method for maintaining a web page heartbeat connection according to a specific embodiment of the present application;
[0018] Figure 7 A device for maintaining a heartbeat connection of a web page according to an embodiment;
[0019] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0020] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.
[0021] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.
[0022] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0023] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0024] Figure 1 A schematic diagram shows an application scenario to which the technical solution of the embodiments of the present application can be applied. Figure 1 The application scenario shown includes a terminal 110 , a server 120 and a traffic collection platform 130 .
[0025] The terminal 110 may be a desktop computer, a laptop computer, a smart phone, or other device that can access the server.
[0026] The server 120 is used to provide services for the client program running in the terminal 110, so that the terminal 110 can have a conversation with the server 120 as a client, and generate corresponding traffic. Specifically, the terminal can initiate an access request to the server and receive response data returned by the server.
[0027] The traffic collection platform 130 is used to collect the traffic generated by the communication between the terminal 110 and the server 120. Then, the method of the present application is implemented based on the collected traffic. Of course, the method of the present application can be executed by the traffic collection platform 130, or by other computer devices that can obtain traffic data from the traffic collection platform 130, and no specific limitation is made here.
[0028] The implementation details of the technical solution of the embodiment of the present application are described in detail below:
[0029] Figure 2 is a flowchart of a method for maintaining a web page heartbeat connection according to an embodiment of the present application. The method can be applied to Figure 1 The traffic collection platform shown. Figure 2 As shown, the method for maintaining the heartbeat connection includes at least steps 210 to 240, which are described in detail as follows.
[0030] Step 210, obtaining historical traffic data of access to the server.
[0031] The historical traffic data is the traffic generated by historical access to the server. Of course, the historical traffic data may include only the traffic generated by one client accessing the server, or may include the traffic generated by multiple clients accessing the server.
[0032] The historical traffic data records the data generated by the historical conversations between the server and each client. The data generated by a conversation between the server and the client includes at least the request data generated by the access request initiated by the client and the response data generated by the server in response to the client.
[0033] In some embodiments of the present application, since the long connection between the client and the server is time-sensitive, and in order to improve the efficiency of data processing, the historical traffic data obtained in step 210 can be traffic data within a set time period from the current time. The set time period can be set according to actual needs, for example, it can be set with reference to the longest time that the client and the server can maintain a long connection, and it can also be determined with reference to the validity period of the Cookie generated by the server.
[0034] Step 220, filtering the historical traffic data to obtain target traffic, wherein the target access request in the target traffic is a static access request.
[0035] The target access request refers to the access request in the target traffic, and the target traffic refers to the traffic selected from the historical traffic.
[0036] A static access request is a request that will not affect the data stored in the server. In other words, no matter how the parameters of the request change, the returned result remains basically the same. Since a static access request will not affect the data stored in the server, the server will not modify the data stored in the server during the process of processing the static access request. Therefore, even if an access request that is a static access request is repeatedly sent to the server, the response data returned by the server is the same. In some scenarios, the server will add a timestamp to the response data before returning the response data to the client. In this case, if an access request is a static access request, the multiple response data obtained by sending the access request to the server multiple times are basically the same, that is, except for the different timestamps carried in the response data, the data included in the response data that represents the processing result of the server for the access request is the same.
[0037] In some embodiments of the present application, it is possible to reversely judge whether the corresponding access request is a static access request based on the response data returned by the server to the access request. This is done by judging whether the response data obtained from multiple access requests initiated for the same service are consistent or whether the similarity of the response data meets the set requirements. If so, it is confirmed that the access request initiated for the service is a static access request.
[0038] In some embodiments of the present application, in order to avoid the judgment of whether an access request is a static access request by the timestamp carried by the response data, the multiple response data obtained by initiating access requests to the same service multiple times can also first extract data representing the processing results of the server side for the access request from the response data. Since the extracted data does not include the timestamp added to the response data, the data extracted from the multiple response data can be directly compared to see if they are the same. If they are the same, it indicates that the access request initiated for the service is a static access request.
[0039] In some embodiments of the present application, Figure 3 The process shown in the figure selects and determines the target traffic from the historical traffic data. Figure 3 As shown, step 220 further includes:
[0040] Step 310: Filter the historical traffic data according to a preset response condition to obtain a first traffic set that meets the preset response condition.
[0041] In step 310, it is equivalent to screening the historical traffic data according to the preset response condition, and the traffic in which the response data that meets the preset response condition is determined is the traffic in the first traffic set.
[0042] In some embodiments of the present application, the response condition may be that the response data includes a response packet and the response status code indicates a successful response. In this embodiment, step 310 may further include: filtering the historical traffic data to obtain traffic including a response packet and a corresponding response status code indicating successful processing of the access request; and adding the traffic including the response packet and the corresponding response status code indicating successful processing of the access request to the first traffic set.
[0043] For a complete session, such as a session based on HTTP (HyperText Transfer Protocol), the traffic generated during a session includes request data and response data, and the response data includes a response packet, but in reality there is also a situation where there is no response packet. Since in the solution of this solution, it is necessary to judge whether the corresponding access request is a static access request based on the response data returned by the server, it is necessary to analyze based on the traffic with the response packet, so it is necessary to extract the traffic including the response packet from the historical traffic data.
[0044] The response status code is used to identify the response status. Different response status codes identify different statuses. In the HTTP protocol, the response status codes can be divided into the following five categories: 1) 1xx--Informational, indicating that the accepted request is being processed; 2) 2xx----Success, indicating that the request has been processed normally; 3) 3xx----Redirection, indicating that the request is to be redirected, of course, 304 is excluded; 4) 4xx----Client Error, the server cannot process the request; 5) 5xx----Server Error, the server has an error when processing the request. Specifically, in the HTTP protocol, the response status code indicating the successful processing of the access request is 200. Therefore, traffic screening can be further performed based on the response status code in the response data.
[0045] Step 320: Acquire multiple flows of the target client corresponding to the target service and whose access requests are static access requests from the first flow set to obtain a target flow set.
[0046] In some embodiments of the present application, the target traffic set may be determined according to the following process of steps 321 - 325 .
[0047] Step 321: Classify the traffic in the first traffic set according to the client that initiates the access, and obtain a second traffic set corresponding to each client.
[0048] Specifically, the traffic in the first traffic set may be classified according to the client identifier or the IP address (Internet Protocol Address) where the client is located to obtain the second traffic set corresponding to each client.
[0049] Step 322: Acquire multiple flows corresponding to the selected target service from the second flow set of the target client to obtain a third flow set.
[0050] The target client refers to the client that needs to maintain a heartbeat connection with the server. Therefore, any client that needs to maintain a heartbeat connection with the server can be used as the target client in the present application solution.
[0051] In the second traffic set of the target client, there may be traffic generated by access requests initiated for multiple services. Therefore, in step 322, the traffic in the second traffic set of the target client is first classified according to the requested service to further determine whether the access request initiated for the service is a static access request.
[0052] The target service refers to the service requested by the access request that needs to be confirmed as a static access request. In a specific embodiment, after the traffic in the second traffic set of the target client is classified according to the requested service, the service corresponding to each type of traffic can be used as the target service to obtain the corresponding third traffic set.
[0053] In some embodiments of the present application, there may be sub-access requests in the process of initiating access to certain services. For example, when accessing the target page, the server may return a javascript script, and the javascript script will request other resources, resulting in the generation of a sub-request; for example, loading image resources in the target page also generates a corresponding sub-access request. For this kind of situation where there are sub-access requests, in the process of classifying the traffic in the second traffic set according to the requested service, it is necessary to attribute the traffic corresponding to the sub-access request to the traffic corresponding to the corresponding main access request. In other words, the traffic of the sub-access request generated in the process of accessing a service belongs to the traffic corresponding to the service. In a specific embodiment, the traffic corresponding to the same service can be determined in the form of IP+URL (Uniform Resource Locator)+Cookie.
[0054] Step 323: In the third traffic set, similarity calculation is performed on the response data corresponding to any two traffic flows.
[0055] Traffic includes response data and request data. Request data includes access requests, and response data includes response packets, response status codes, and cookies mentioned below. Response data is reflected in the form of response messages. Calculating the similarity of response data is equivalent to calculating the similarity between response messages.
[0056] Step 324: If the calculated similarity is not lower than the similarity threshold, it is determined that the traffic corresponding to the calculated similarity is the traffic of the access request being a static access request.
[0057] The similarity threshold can be set according to actual needs. For example, the similarity threshold can be set to 100%, which indicates that the two response data are completely consistent. In practice, the response data may also carry a timestamp. The initiation time of the access request for the same service is different, and the corresponding response time is different, so the timestamps carried in the response data are also different. In this case, the two response data are not completely consistent. Therefore, the similarity threshold can be set to a value less than 100%, such as 95%.
[0058] If the calculated similarity of two response data for the same service is not less than the similarity threshold, it indicates that the two response data are substantially the same or completely the same, and therefore, it can be determined that the access request initiated for the service is a static access request.
[0059] Step 325: Add the traffic whose access request is determined to be a static access request in the third traffic set to the target traffic set.
[0060] In some embodiments of the present application, the traffic for the same service in the third traffic set may include multiple groups, such as two groups or more. In order to improve processing efficiency, similarity calculation can be performed on the response data in N (N is an integer greater than or equal to 2) groups of traffic for the same service to determine whether the access request initiated for the service is a static access request. If so, the traffic corresponding to the identification information is directly extracted from other traffic in the third traffic set except for the traffic for which similarity calculation is performed, without further calculating the similarity between the response data in the two traffics.
[0061] Step 330: Select the flow containing the cookie with the shortest remaining validity period in the target flow set as the target flow.
[0062] The response data in the traffic includes at least the response packet, the response status code, and the cookie generated by the server.
[0063] Cookie refers to data stored on the client's local terminal by the server in order to identify the user and track the session. Cookie is a piece of text information.
[0064] After the client initiates an access request to the server, if the server needs to record the status of the client user, it will issue a cookie to the client. The client will save the cookie. When the client accesses the server again, the client will send the address information of the requested page and other information together with the cookie to the server. The server identifies the user's status and identity by checking the cookie. Of course, the server can modify the content of the cookie according to actual needs.
[0065] When the client accesses the server, the server records the client information in some form on the server. The client information recorded in the server is called Session. It can be understood that Session is information stored in the server to determine and represent the client's identity. Like Cookie, Session is also a piece of text information. When the client accesses the server again, it only needs to find the client's information from the stored Session.
[0066] When a client accesses a website corresponding to a server, website authentication is generally required. Website authentication refers to verifying whether the user's client has the right to access certain resources of the corresponding website. If the authentication is successful, the user is allowed to access certain resources. If the authentication is unsuccessful, the user is not allowed to access certain resources.
[0067] In the related art, website authentication is generally performed through the Cookie+Session method. Specifically, the user enters the username and password in the client, and the client initiates an access request to the server. After receiving the access request, the server queries the corresponding password stored in the database based on the username carried in the access request, and then matches it with the password carried in the access request. If the two match, a Session object is generated. Part of the Session object is stored in the server, namely the Session, and the other part of the Session object is sent to the client for storage, namely the Cookie. After the client receives the Cookie, the subsequent access requests sent to the server will carry the Cookie. When the server receives the access request, it determines the resource access rights of the client user based on the Cookie carried in the access request and the Session stored in the server.
[0068] The Session object generated by the server has a validity period, and correspondingly, the Cookie stored in the client also has a validity period.
[0069] As described above, the access request initiated by the client to the server carries a cookie, so the traffic for a session corresponds to a cookie, that is, the cookie carried by the access request in the traffic. Since cookies have an expiration date, the remaining validity period of the cookie can be calculated based on the current time and the expiration time of the cookie.
[0070] In the solution of the present application, the flow containing the cookie with the shortest remaining validity period in the target flow set is selected as the target flow.
[0071] Please continue reading Figure 2 As shown, step 230 verifies the validity of the Cookie carried by the target access request in the server.
[0072] As described above, cookies have an expiration date, so cookies can become invalid. Cookies can become invalid because the validity period of the cookie has expired, or because the client's status has changed and the server has generated a new cookie for the client, which means the previous cookie generated by the server for the client will become invalid.
[0073] For example, when a user on the client browses a web page, the server returns a Cookie to the client (for ease of description, let's call it CookieA) to indicate that "a user is browsing". If the user logs in to the website while browsing this web page, the server returns a new Cookie (let's call it CookieB) to indicate that "user xxx is browsing". Although both CookieB and CookieA are used to identify identities, CookieB carries the identity information of the logged-in user. After the user logs in to the website, the Cookie carried by the website is CookieB instead of CookieA, and CookieA becomes invalid on the server, regardless of whether it is within the validity period set for CookieA.
[0074] In step 230, the validity of the Cookie carried by the target access request in the server is verified, that is, whether the Cookie carried by the target access request satisfies the above two expiration conditions. If any of the above expiration conditions is met, the Cookie carried by the target access request is invalid in the server; conversely, if neither of the above two expiration conditions is met, the Cookie carried by the target access request is not invalid.
[0075] In some embodiments of the present application, step 230 includes Figure 4 The process of steps 411-418 is described in detail as follows.
[0076] Step 411: Send the target access request to the server for the second time.
[0077] It is worth mentioning that if the execution subject of the present application solution is not the computing device where the target client is located, the address information of the request initiator in the target access request needs to be modified. The address information is, for example, an IP address. The address information of the request initiator in the target access request is the address of the computer of the target client, and in step 411, the address information of the request initiator in the target access request needs to be modified to the address information of the computer device executing the present application solution.
[0078] Step 412: Receive second response data returned by the server in response to the target access request sent for the second time.
[0079] The second response data refers to the response data returned by the server in response to the target access request sent for the second time.
[0080] Step 413: compare the second response data with the first response data in the target traffic for the target access request.
[0081] The first response data refers to the response data returned by the server in response to the target access request sent historically.
[0082] If the first response data is consistent with the second response data, step 414: determine whether the Cookie carried by the target access request is valid in the server.
[0083] On the contrary, if the first response data is inconsistent with the second response data, step 415 is executed: comparing the Cookie in the first response data with the Cookie in the second response data.
[0084] If the Cookie in the first response data is the same as the Cookie in the second response data, it is determined that the Cookie carried by the target access request is valid in the server.
[0085] On the contrary, if the Cookie in the first response data is different from the Cookie in the second response data, step 416 is executed: sending the target access request to the server for the third time.
[0086] If the Cookie in the first response data is different from the Cookie in the second response data, it indicates that the Cookie for the target client may have changed. Therefore, in order to confirm whether the Cookie for the target client in the server has changed, step 416 is performed.
[0087] Step 417: Receive third response data returned by the server corresponding to the server in response to the target access request sent for the third time.
[0088] The third response data refers to the response data returned by the server in response to the target access request sent for the third time.
[0089] If the Cookie in the first response data is the same as the Cookie in the third response data, it is determined that the Cookie carried by the target access request is valid in the server.
[0090] If the Cookie in the first response data is different from the Cookie in the third response data, execute step 418: generate a first prompt message, and indicate through the first prompt message that the Cookie carried by the target traffic has expired.
[0091] If the Cookie in the first response data is different from the Cookie in the third response data, it is confirmed that the Cookie in the first response data is invalid.
[0092] Through the above process, the validity of the Cookie carried by the target access request is verified on the server side.
[0093] In some embodiments of the present application, since the target traffic is only the traffic for a selected service, if the Cookie in the first response data is different from the Cookie in the third response data, the traffic for other services and the access requests therein are static access requests can also be selected from the historical traffic data as the target traffic, and then the validity of the Cookie carried by the target access request in the target traffic can be verified through the above steps.
[0094] If the cookies carried by the target access requests in the target traffic for each service selected from the historical traffic data are all verified to be invalid, a first prompt message is generated accordingly and sent to the target client to prompt the target client to access the server to generate new traffic.
[0095] In some embodiments of the present application, since the traffic containing the cookie with the shortest remaining effective time in the target traffic set is selected as the target traffic (for ease of description, it is assumed that the remaining effective time of the cookie carried by the target access request in the traffic selected as the target traffic is T1), and there are other traffic in the target traffic set, a traffic with a remaining effective time greater than T1 can also be selected from the target traffic set as the target traffic, and then Figure 4 The process shown verifies the validity of the corresponding cookie.
[0096] In some embodiments of the present application, since the traffic initially selected as the target traffic is the traffic containing the cookie with the shortest remaining validity period in the target traffic set, it can be determined that the cookie with the shortest remaining validity period in the target traffic set has expired.
[0097] In this case, in order to improve processing efficiency, the traffic containing the cookie with the longest remaining validity period in the target traffic set can be re-selected as the target traffic. Since the remaining validity period of this cookie is the longest, it means that in the target traffic set, the generation time corresponding to this cookie is closest to the current time. Figure 4 Steps 411-418 verify that the cookie with the longest remaining validity period is also invalid. There is no need to continue to verify the validity of the cookies corresponding to other flows in the target flow set. Instead, it can be directly confirmed that the cookies corresponding to each flow in the target flow set are invalid, thereby improving verification efficiency.
[0098] Please continue reading Figure 2 , step 240, if the Cookie carried by the target access request has not expired in the server, then within the validity period of the Cookie carried by the target access request, the target client corresponding to the target access request is controlled to send the target access request to the server again at intervals to maintain the heartbeat connection between the target client and the server.
[0099] In the case where the target client corresponding to the target access request is controlled to resend the target access request to the server at intervals, the server will respond to the target access request accordingly, thereby maintaining the heartbeat connection between the server and the target client.
[0100] In some embodiments of the present application, step 240 further includes: obtaining configured heartbeat interval information; generating heartbeat prompt information based on the heartbeat interval information and the target access request; sending the heartbeat prompt information to the target client corresponding to the target access request; and controlling the target client through the heartbeat prompt information to send the target access request to the server at the interval indicated by the heartbeat interval information.
[0101] The heartbeat interval information is used to indicate the heartbeat interval, that is, the interval for sending the target access request, which can be configured according to actual needs, such as 15 minutes, half an hour, one hour, etc., which is not specifically limited here.
[0102] The generated heartbeat prompt information indicates, on the one hand, the sending interval (ie, the interval for sending the target access request); on the other hand, it indicates the target access request to be sent in order to maintain the heartbeat connection.
[0103] In some embodiments of the present application, the method also includes: calculating the remaining validity period of the Cookie carried by the target access request; determining a sending priority based on the remaining validity period, and the sending priority is used to indicate the priority of sending the heartbeat prompt information to the target client.
[0104] The scheme of the present application can maintain a heartbeat connection with a server facing multiple clients, and correspondingly, corresponding heartbeat prompt information needs to be generated for multiple clients respectively. In this case, there may be a situation where the heartbeat prompt information is queued and waiting to be sent. The validity period of the Cookie carried by the target access request corresponding to each client is already set, that is, when the server generates the Cookie, it initially sets a validity period for the Cookie. Therefore, the queuing time of the heartbeat prompt information may be longer than the remaining validity period of the Cookie, resulting in the target client sending the target access request to the server again after receiving the heartbeat prompt information. It is also impossible to maintain the heartbeat connection with the server.
[0105] In order to avoid the situation where the queuing time of the heartbeat reminder information exceeds the validity period of the cookie, the shorter the remaining validity period, the higher the sending priority can be set, so that the client corresponding to the cookie with the shorter remaining validity period can receive the heartbeat reminder information faster to send the corresponding target access request and maintain the heartbeat connection between it and the server.
[0106] In the scheme of the present application, the target traffic corresponding to the access request being a static access request is screened out based on the historical traffic data of the access server, and when the Cookie in the target traffic has not expired, the target client corresponding to the target access request is controlled to resend the target access request to the server at intervals, thereby maintaining the heartbeat connection between the target client and the server based on the historical traffic data, without the need to install a probe in the target client to maintain the heartbeat connection. Therefore, the scheme of the present application has a wide range of applications.
[0107] In some embodiments of the present application, Figure 5 As shown, after step 240, the method further includes: monitoring the remaining validity period of the Cookie carried by the target access request; if the remaining validity period of the Cookie carried by the target access request is not greater than the duration threshold, reselecting the traffic containing the Cookie that has not expired and has the shortest remaining validity period in the target traffic set as the target traffic; and jumping to the step of verifying the validity of the Cookie carried by the target access request in the server.
[0108] It is understandable that if the expiration time set by the server for the Cookie carried by the target access request is reached, even if the target access request is sent to the server again, the server cannot respond to the target access request because the Cookie therein has expired. Correspondingly, the heartbeat connection with the server cannot be maintained.
[0109] Therefore, it is necessary to monitor the remaining effective duration of the cookie carried by the target access request to determine whether it is close to the expiration time of the cookie. When it is monitored that the remaining effective duration of the cookie carried by the target access request is not greater than the duration threshold, it indicates that it is close to the expiration time of the cookie. Therefore, a flow is reselected from the target flow set as the target flow, and the process jumps to step 230 to continue to maintain the heartbeat connection between the target client and the server.
[0110] In some embodiments of the present application, in addition to selecting the traffic containing the Cookie that has not expired and has the shortest remaining validity period in the target traffic set as the target traffic, you can also select the traffic containing the Cookie that has not expired and has the longest remaining validity period in the target traffic set as the target traffic, which is not specifically limited here.
[0111] In some embodiments of the present application, the method also includes: if the Cookies carried by each flow in the target flow set are expired, generating a second prompt message; sending the second prompt message to the target client, and instructing the target client to re-make a service request through the second prompt message to generate new flow.
[0112] If the cookies carried by each flow in the target flow set are all expired, then the corresponding traffic is invalid, so the traffic in the target flow set can no longer be used to maintain the heartbeat connection between the target client and the server. In this case, the new traffic generated by the conversation between the target client and the server can be used to implement the method of the present application.
[0113] The solution of the present application is described in detail below with reference to a specific embodiment. Figure 6 1 is a flowchart of a method for maintaining a web page heartbeat connection according to a specific embodiment. The method can be executed by a computer device that is in communication with a traffic collection platform, and of course, can also be executed by the traffic collection platform. Figure 6 As shown, the method includes steps 611-620.
[0114] Step 611, determine the server that needs to maintain the heartbeat connection.
[0115] Specifically, the address of the website that needs to maintain the heartbeat connection can be input, which can be an IP address or a URL address, can be directly obtained from the user input, or can be read from a file. The server where the input address is located is the server that needs to maintain the heartbeat connection.
[0116] Step 612, determine whether there is any historical traffic accessing the server.
[0117] According to the input address, it is determined whether there is historical traffic of the access server in the traffic collection platform. If there is, step 613 is executed. Otherwise, if there is no historical traffic, the access server is prompted to generate normal traffic.
[0118] Step 613, communication connection detection. By monitoring whether the communication connection between the computer device executing this method and the server is normal, that is, whether the two are IP interconnected, if not, notify the technician to detect and repair the network between the two machines to enable the two to communicate.
[0119] Step 614: Obtain historical traffic data. Obtain historical traffic data of accessing the server from the traffic collection platform.
[0120] In the process of obtaining traffic, it is necessary to detect the traffic and only obtain the traffic that contains response packets and the response status code is 200. The response status code 200 indicates a successful response from the server.
[0121] If the traffic with a response packet and a response status code of 200 cannot be obtained in step 614, a message notification is sent to prompt the user that the traffic that meets the response condition cannot be obtained.
[0122] Step 615, historical traffic data processing.
[0123] Specifically include:
[0124] (1) Grouping historical traffic data according to the client that initiated the access request, with the traffic of each client as one group;
[0125] (2) Classify each flow according to the requested service to obtain a flow set corresponding to the same service; the flow generated by the sub-access request initiated during the access process to a service also needs to be included in the flow set corresponding to the service. Specifically, the flow of the same service can be confirmed in the form of IP+URL+Cookie.
[0126] (3) In the traffic of the same service, based on the request parameters and the return results of the request, filter out the traffic whose access request is a static access request; if the traffic corresponding to the static access request cannot be obtained according to the return results, the traffic of the page with the largest number of search requests is regarded as the traffic whose access request is a static access request;
[0127] (4) Determine the traffic containing the cookie with the shortest remaining validity period from the traffic whose access requests are static access requests as the target traffic.
[0128] (5) Determine the sending priority and configure the heartbeat interval based on the remaining validity period of the cookie carried by the target access request in the target traffic: if the remaining validity period is less than one hour, set it to be sent with priority, and then set the heartbeat interval to once an hour; if the remaining validity period is not less than one hour, set it not to be sent with priority, and set the heartbeat interval to once an hour.
[0129] Step 616, verify the validity of the Cookie.
[0130] By verifying the validity of the Cookie carried in the selected target traffic, it is determined whether the target access request in the target traffic can be used to maintain the heartbeat connection. For the verification process, see Figure 4 In this step, if information notification is required (for example, the generated first prompt information or second prompt information needs to be sent), the process goes to step 620: information notification.
[0131] Step 617, heartbeat monitoring.
[0132] In the process of controlling the target client to send a target access request to the server according to the set heartbeat interval, monitor whether the Cookie carried in the target access request has reached the expiration time. If it has, execute step 620: information notification to notify the user that the Cookie has expired and request to access the server to generate new traffic.
[0133] Step 618, traffic is saved.
[0134] The request and response packets sent in the process of maintaining the heartbeat connection by sending the target access request are saved, specifically including: calculating the MD5 values of the request and response packets for each request, and then associating the two MD5 values with the request and response packets, and then saving them in a file. Each line in the file records the request time, request packet path, request packet MD5 value, response packet path and response packet MD5 value. The file name is xxx web page heartbeat record.
[0135] Step 619, output; the program running information in the entire process of steps 611-618 can be displayed.
[0136] The following describes an apparatus embodiment of the present application, which can be used to execute the method in the above-mentioned embodiment of the present application. For details not disclosed in the apparatus embodiment of the present application, please refer to the above-mentioned method embodiment of the present application.
[0137] Figure 7 A device for maintaining a heartbeat connection of a web page according to an embodiment is shown. Figure 7 As shown, the device for maintaining the heartbeat connection of the web page includes:
[0138] The historical traffic data acquisition module 710 is used to acquire the historical traffic data of the target client accessing the server;
[0139] A traffic screening module 720 is used to screen the historical traffic data to obtain target traffic, wherein the target access request in the target traffic is a static access request;
[0140] A validity verification module 730 is used to verify the validity of the Cookie carried by the target access request in the server;
[0141] The control module 740 is used to control the target client to send the target access request to the server at intervals within the validity period of the Cookie carried by the target access request if the Cookie carried by the target access request has not expired in the server.
[0142] In some embodiments of the present application, the validity verification module 730 includes: a first sending unit, used to send the target access request to the server for the second time; a first receiving unit, used to receive second response data returned by the server for the target access request sent for the second time; a first comparison unit, used to compare the second response data with the first response data for the target access request in the target traffic; and a first determination unit, used to determine that the Cookie carried by the target access request is valid in the server if the first response data is consistent with the second response data.
[0143] In some embodiments of the present application, the validity verification module 730 also includes: a second comparison unit, used to compare the Cookie in the first response data and the Cookie in the second response data if the first response data is inconsistent with the second response data; a second determination unit, used to determine that the Cookie carried by the target access request is valid in the server if the Cookie in the first response data is the same as the Cookie in the second response data.
[0144] In some embodiments of the present application, the validity verification module 730 also includes: a second sending unit, used to send the target access request to the server for the third time if the Cookie in the first response data is different from the Cookie in the second response data; a second receiving unit, used to receive third response data returned by the server corresponding to the server for the target access request sent for the third time; a third determination unit, used to determine that the Cookie carried by the target access request is valid in the server if the Cookie in the first response data is the same as the Cookie in the third response data.
[0145] In some embodiments of the present application, the heartbeat connection maintenance device also includes: a first prompt information generation module, which is used to generate a first prompt information if the Cookie in the first response data is different from the Cookie in the third response data, and the first prompt information is used to indicate that the Cookie carried by the target traffic has expired.
[0146] In some embodiments of the present application, the traffic screening module 720 includes: a first traffic set determination unit, used to screen the historical traffic data according to a preset response condition to obtain a first traffic set that meets the preset response condition; a target traffic set determination unit, used to obtain from the first traffic set multiple flows of the target client corresponding to the target service and whose access requests are static access requests to obtain a target traffic set; a target traffic determination unit, used to select the flow containing the cookie with the shortest remaining validity period in the target traffic set as the target traffic.
[0147] In some embodiments of the present application, the first traffic set determination unit includes: a screening unit, used to screen out traffic including response packets and corresponding response status codes indicating successful processing of access requests from the historical traffic data; and a first adding unit, used to add the traffic including response packets and corresponding response status codes indicating successful processing of access requests to the first traffic set.
[0148] In some embodiments of the present application, the target traffic set determination unit includes: a second traffic set determination unit, which is used to classify the traffic in the first traffic set according to the client that initiates the access, and obtain a second traffic set corresponding to each client; a third traffic set determination unit, which is used to obtain multiple traffic corresponding to the selected target service from the second traffic set of the target client, and obtain a third traffic set; a similarity calculation unit, which is used to perform similarity calculation on the response data corresponding to any two traffics in the third traffic set; a traffic determination unit, which is used to determine that the traffic corresponding to the calculated similarity is the traffic whose access request is a static access request if the calculated similarity is not lower than the similarity threshold; a second adding unit, which is used to add the traffic whose access request is determined to be a static access request in the third traffic set to the target traffic set.
[0149] In some embodiments of the present application, the device for maintaining a heartbeat connection of a web page also includes: a monitoring module for monitoring the remaining validity period of the cookie carried by the target access request; a reselection module for reselecting the traffic containing the cookie that has not expired and has the shortest remaining validity period in the target traffic set as the target traffic if the remaining validity period of the cookie carried by the target access request is not greater than a duration threshold; and jumping to the step of verifying the validity of the cookie carried by the target access request in the server.
[0150] In some embodiments of the present application, the device for maintaining a web page heartbeat connection also includes: a second prompt information generation module, which is used to generate a second prompt information if the cookies carried by each flow in the target flow set are expired; a second prompt information sending module, which is used to send the second prompt information to the target client, and instruct the target client to re-make a service request through the second prompt information to generate new traffic.
[0151] In some embodiments of the present application, the control module 740 includes: a heartbeat interval information acquisition unit, used to acquire the configured heartbeat interval information; a heartbeat prompt information generation unit, used to generate heartbeat prompt information based on the heartbeat interval information and the target access request; a heartbeat prompt information sending unit, used to send the heartbeat prompt information to the target client corresponding to the target access request; and a control unit, used to control the target client through the heartbeat prompt information to send the target access request to the server at the interval indicated by the heartbeat interval information.
[0152] In some embodiments of the present application, the device for maintaining a web page heartbeat connection also includes: a remaining effective time calculation module, used to calculate the remaining effective time of the Cookie carried by the target access request; a priority determination module, used to determine the sending priority according to the remaining effective time, and the sending priority is used to indicate the priority of sending the heartbeat prompt information to the target client.
[0153] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.
[0154] It should be noted that Figure 8 The computer system 800 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0155] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 802 or the program loaded from the storage part 808 to the random access memory (RAM) 803, such as executing the method in the above embodiment. In the RAM 803, various programs and data required for system operation are also stored. The CPU 801, ROM 802 and RAM 803 are connected to each other through a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0156] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed so that a computer program read therefrom is installed into the storage section 808 as needed.
[0157] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 809, and / or installed from a removable medium 811. When the computer program is executed by a central processing unit (CPU) 801, various functions defined in the system of the present application are executed.
[0158] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0159] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0160] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0161] As another aspect, the present application further provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable storage medium carries computer-readable instructions, and when the computer-readable storage instructions are executed by a processor, the method in the above embodiment is implemented.
[0162] According to one aspect of the present application, an electronic device is also provided, which includes: a processor; a memory, in which computer-readable instructions are stored, and when the computer-readable instructions are executed by the processor, the method in the above embodiment is implemented.
[0163] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0164] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.
[0165] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.
[0166] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for maintaining a heartbeat connection of a web page, characterized in that: include: Get historical traffic data of accessing the server; Performing traffic screening on the historical traffic data to obtain target traffic, wherein the target access request in the target traffic is a static access request; Verify the validity of the cookie carried by the target access request in the server; If the Cookie carried by the target access request has not expired in the server, then within the validity period of the Cookie carried by the target access request, the target client corresponding to the target access request is controlled to send the target access request to the server at intervals to maintain the heartbeat connection between the target client and the server.
2. The method according to claim 1, characterized in that: The verifying the validity of the Cookie carried by the target access request in the server includes: Sending the target access request to the server for a second time; Receiving second response data returned by the server in response to the target access request sent for the second time; Comparing the second response data with the first response data in the target traffic for the target access request; If the first response data is consistent with the second response data, it is determined that the Cookie carried by the target access request is valid in the server.
3. The method according to claim 2, characterized in that The verifying the validity of the Cookie carried by the target access request in the server side also includes: If the first response data is inconsistent with the second response data, comparing the Cookie in the first response data with the Cookie in the second response data; If the Cookie in the first response data is the same as the Cookie in the second response data, it is determined that the Cookie carried by the target access request is valid in the server.
4. The method according to claim 3, characterized in that The verifying the validity of the Cookie carried by the target access request in the server side also includes: If the Cookie in the first response data is different from the Cookie in the second response data, sending the target access request to the server for the third time; Receiving third response data returned by the server corresponding to the server in response to the target access request sent for the third time; If the Cookie in the first response data is the same as the Cookie in the third response data, it is determined that the Cookie carried by the target access request is valid in the server.
5. The method according to claim 4, characterized in that The method further comprises: If the Cookie in the first response data is different from the Cookie in the third response data, a first prompt information is generated, where the first prompt information is used to indicate that the Cookie carried by the target traffic has expired.
6. The method according to claim 1, characterized in that The filtering of the historical traffic data to obtain the target traffic includes: Filter the historical traffic data according to a preset response condition to obtain a first traffic set that meets the preset response condition; Acquire multiple flows of the target client corresponding to the target service and whose access requests are static access requests from the first flow set to obtain a target flow set; The flow containing the cookie with the shortest remaining validity period in the target flow set is selected as the target flow.
7. The method according to claim 6, characterized in that The filtering of the historical traffic data according to the preset response condition to obtain a first traffic set that meets the preset response condition includes: Filtering the historical traffic data to obtain traffic including a response packet and a corresponding response status code indicating successful processing of the access request; The traffic including the response packet and the corresponding response status code indicating successful processing of the access request is added to the first traffic set.
8. The method according to claim 6, characterized in that The step of acquiring, from the first traffic set, a plurality of traffics of the target client corresponding to the target service and whose access requests are static access requests, to obtain a target traffic set includes: Classifying the traffic in the first traffic set according to the client initiating the access, to obtain a second traffic set corresponding to each client; Acquire multiple flows corresponding to the selected target service from the second flow set of the target client to obtain a third flow set; In the third traffic set, similarity calculation is performed on the response data respectively corresponding to any two traffic flows; If the calculated similarity is not lower than the similarity threshold, determining that the traffic corresponding to the calculated similarity is the traffic of the access request being a static access request; The traffic whose access request is determined to be a static access request in the third traffic set is added to the target traffic set.
9. The method according to claim 6, characterized in that After the target client corresponding to the target access request is controlled to resend the target access request to the server at intervals within the validity period of the Cookie carried by the target access request, the method further includes: Monitor the remaining validity period of the cookie carried by the target access request; If the remaining validity period of the cookie carried by the target access request is not greater than the duration threshold, then reselect the traffic containing the cookie that has not expired and has the shortest remaining validity period from the target traffic set as the target traffic; Jump to the step of verifying the validity of the Cookie carried by the target access request in the server.
10. The method according to claim 9, characterized in that After reselecting the traffic containing the cookie that has not expired and has the shortest remaining validity period from the target traffic set as the target traffic, the method further includes: If all Cookies carried by the flows in the target flow set are expired, a second prompt message is generated; The second prompt information is sent to the target client, and the target client is instructed to make a new service request through the second prompt information to generate new traffic.
11. The method according to claim 1, characterized in that The controlling the target client corresponding to the target access request to resend the target access request to the server at an interval comprises: Get the configured heartbeat interval information; Generate heartbeat prompt information according to the heartbeat interval information and the target access request; Sending the heartbeat prompt information to the target client corresponding to the target access request; The target client is controlled by the heartbeat prompt information to send the target access request to the server at an interval indicated by the heartbeat interval information.
12. The method according to claim 11, characterized in that Before sending the heartbeat prompt information to the target client corresponding to the target access request, the method further includes: Calculate the remaining validity period of the cookie carried by the target access request; A sending priority is determined according to the remaining effective time, and the sending priority is used to indicate a priority for sending the heartbeat prompt information to the target client.
13. A device for maintaining a heartbeat connection of a web page, characterized in that: The device comprises: The historical traffic data acquisition module is used to obtain the historical traffic data of the target client accessing the server; A traffic screening module, used for screening the historical traffic data to obtain target traffic, wherein the target access request in the target traffic is a static access request; A validity verification module, used to verify the validity of the Cookie carried by the target access request in the server; The control module is used to control the target client to send the target access request to the server at intervals within the validity period of the Cookie carried by the target access request if the Cookie carried by the target access request has not expired in the server.
14. An electronic device, characterized in that: include: processor; A memory having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by the processor, the method according to any one of claims 1 to 12 is implemented.
15. A computer-readable storage medium having computer-readable instructions stored thereon, characterized in that: When the computer-readable instructions are executed by a processor, the method according to any one of claims 1 to 12 is implemented.
Citation Information
Patent Citations
Website access method and device
CN103152406A
Data acquisition method and device, terminal equipment and medium
CN110633432A