Interface connection method and device, electronic equipment and readable storage medium
By obtaining the communication status parameters of the interface and calculating the stability coefficient, the reconnection time interval is dynamically adjusted, which solves the problem of low interface connection efficiency and achieves more efficient interface connection.
Patent Information
- Application Number
- CN202411763961.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2044-12-03
AI Technical Summary
Existing technologies have low flexibility in interface connection methods, resulting in low interface connection efficiency and long time required for successful connection.
By obtaining the communication status parameters of the target interface within a historical time period, the stability coefficient is calculated, and the time interval for the next connection is determined based on the stability coefficient and the preset time interval, thus dynamically adjusting the reconnection time.
It improves the adaptability and intelligence of interface connections, reduces unnecessary reconnections, and increases the efficiency of successful interface connections.
Smart Images

Figure CN119946120B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computer technology, and specifically relates to an interface connection method, device, electronic device, and readable storage medium. Background Technology
[0002] An interface is a connection point between different services or components in a distributed system. To ensure the normal operation of a distributed system, it is necessary to ensure the normal connection of interfaces.
[0003] In related technologies, when an interface connection fails, the interface is reconnected at fixed time intervals until the connection is successful.
[0004] However, this interface connection method has low flexibility, long connection time, and low connection efficiency. Summary of the Invention
[0005] This application aims to provide an interface connection method, apparatus, electronic device, and readable storage medium, which at least solves the problems of time difference required for interface connection and low interface connection efficiency in the prior art.
[0006] In a first aspect, embodiments of this application disclose an interface connection method, the method comprising:
[0007] Obtain the connection status of the target interface at the current moment; the connection status includes: connection successful or connection failed.
[0008] If the connection status is a connection failure, then the communication status parameters of the target interface within a preset historical time period are obtained; the communication status parameters are used to reflect the stability of the target interface.
[0009] The stability coefficient of the target interface is obtained based on the communication status parameters, and the time interval from the current moment to the next connection to the target interface is obtained based on the stability coefficient and the preset time interval.
[0010] Based on the current time and the time interval, determine the next connection time for connecting to the target interface, and reconnect to the target interface at the specified connection time.
[0011] Optionally, the communication status parameters include at least one; the step of obtaining the stability coefficient of the target interface based on the communication status parameters, and obtaining the time interval from the current moment to the next connection to the target interface based on the stability coefficient and a preset time interval, includes:
[0012] The stability coefficient of the target interface is obtained based on the preset weight value corresponding to each communication state parameter.
[0013] Retrieve the historical time interval of the target interface from the last connection failure to the current time;
[0014] Based on the historical time interval and the stability coefficient, the time interval from the current moment to the next connection to the target interface is obtained.
[0015] Optionally, obtaining the time interval from the current moment to the next connection to the target interface based on the historical time interval and the stability coefficient includes:
[0016] Obtain the first product of the stability coefficient and the preset adjustment coefficient, and obtain the dynamic adjustment factor based on the first product;
[0017] Obtain the second product of the historical time interval and the dynamic adjustment factor;
[0018] The time interval from the current moment to the next connection to the target interface is obtained based on the second product.
[0019] Optionally, if the connection status is a connection failure, then the communication status parameters of the target interface within a preset historical time period are obtained, including:
[0020] Obtain the communication status parameters of the target interface at each first preset historical moment within a preset historical time period;
[0021] The step of obtaining the stability coefficient of the target interface based on the preset weight value corresponding to each communication state parameter includes:
[0022] For each communication status parameter, the average value of the communication status parameter is obtained based on the communication status parameter at each first preset historical moment;
[0023] For each communication state parameter, the average value of the communication state parameter is normalized to obtain the normalized value of the communication state parameter.
[0024] Based on the preset weight values corresponding to each communication state parameter, the normalized values of each communication state parameter are weighted and summed, and the stability coefficient of the target interface is obtained based on the weighted summation result.
[0025] Optionally, obtaining the stability coefficient of the target interface based on a preset weight value corresponding to each communication state parameter includes:
[0026] Obtain the communication status parameters of the target interface at each first preset historical moment within a preset historical time period;
[0027] For each communication status parameter, the dispersion value of the communication status parameter within the preset historical time period is obtained based on the communication status parameter of the target interface at each first preset historical moment.
[0028] If the dispersion value is outside the range of the first preset dispersion value corresponding to the communication state parameter, then the preset weight value corresponding to the communication state parameter is increased according to the first preset adjustment step size.
[0029] If the dispersion value is within the range of the second preset dispersion value corresponding to the communication state parameter, then the preset weight value corresponding to the communication state parameter is reduced according to the second preset adjustment step size.
[0030] Optionally, determining the next connection time for connecting to the target interface based on the current time and the time interval, and reconnecting to the target interface at the specified connection time, includes:
[0031] Get the number of consecutive connection failures of the target interface within the historical time period from the current time to the second preset historical time.
[0032] If the number of failures is less than or equal to a preset threshold, then the next connection time for connecting to the target interface is determined based on the current time and the time interval, and the target interface is reconnected at the specified connection time.
[0033] Optionally, determining the next connection time for connecting to the target interface based on the current time and the time interval, and reconnecting to the target interface at the specified connection time, includes:
[0034] Determine whether the time interval is less than or equal to a preset time interval threshold;
[0035] If the time interval is less than or equal to the preset time interval threshold, then the connection time for the next connection to the target interface is determined based on the current time and the time interval, and the target interface is reconnected at the connection time.
[0036] Secondly, embodiments of this application disclose an interface connection device, the device comprising:
[0037] The first acquisition module is used to acquire the connection status of the target interface at the current moment; the connection status includes: connection successful or connection failed.
[0038] The second acquisition module is used to acquire the communication status parameters of the target interface within a preset historical time period if the connection status is a connection failure; the communication status parameters reflect the stability of the target interface.
[0039] The first determining module is used to obtain the stability coefficient of the target interface according to the communication status parameters, and to obtain the time interval from the current moment to the next connection to the target interface according to the stability coefficient and the preset time interval.
[0040] The second determining module is used to determine the next connection time for connecting to the target interface based on the current time and the time interval, and to reconnect to the target interface at the connection time.
[0041] Thirdly, embodiments of this application also disclose an electronic device, including a processor and a memory, wherein the memory stores a program or instructions that can run on the processor, and the program or instructions, when executed by the processor, implement the steps of the method described in the first aspect.
[0042] Fourthly, embodiments of this application also disclose a readable storage medium storing a program or instructions that, when executed by a processor, implement the steps of the method described in the first aspect.
[0043] In summary, in this embodiment, when the target interface connection fails, the communication status parameters of the target interface within a historical time period are obtained. Based on the communication status parameters, the time interval from the current moment to the next connection to the target interface is obtained. Based on the current moment and the time interval determined by the communication status parameters, the connection time for the next connection to the target interface is determined. This connection time is obtained based on the actual communication status parameters of the target interface and reflects these parameters. Compared to related technologies that reconnect to the interface at fixed time intervals or increase the reconnection time interval based on the number of reconnections, this embodiment can flexibly and accurately determine the reconnection time interval based on the actual communication status parameters of the target interface, improving the adaptability and intelligence of the interface connection method and increasing the efficiency of successful target interface connection. Attached Figure Description
[0044] In the attached diagram:
[0045] Figure 1 This is a flowchart illustrating the steps of an interface connection method provided in an embodiment of this application;
[0046] Figure 2 This is a flowchart of another interface connection method provided in an embodiment of this application;
[0047] Figure 3 This is a schematic diagram of another interface connection system provided in the embodiments of this application;
[0048] Figure 4This is a flowchart illustrating the steps of an interface connection method provided in an embodiment of this application;
[0049] Figure 5 This is a block diagram of an interface connection device provided in an embodiment of this application;
[0050] Figure 6 This is a block diagram of an electronic device provided in one embodiment of this application;
[0051] Figure 7 This is a block diagram of an electronic device according to another embodiment of the present application. Detailed Implementation
[0052] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0053] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0054] Figure 1 This is a flowchart illustrating the steps of an interface connection method provided in this embodiment. The method may include the following steps:
[0055] Step 101: Obtain the connection status of the target interface at the current moment.
[0056] Connection status includes: connection successful or connection failed.
[0057] For example, the target interface can be an interface on the server that needs to be accessed.
[0058] For example, an interface access request can be sent to the target interface. If a response is received from the target interface within a preset historical time period, the connection status of the target interface is determined to be successful; if no response is received from the target interface within the preset historical time period, the connection status of the target interface is determined to be failed.
[0059] Step 102: If the connection status is "connection failed", then obtain the communication status parameters of the target interface within a preset historical time period.
[0060] Among them, the communication status parameters are used to reflect the stability of the target interface.
[0061] For example, communication status parameters may include at least one of the following: connection failure rate of the target interface within a preset historical time period, average response time, current load of the central processing unit (CPU) of the server where the target interface is located, and current network latency.
[0062] If the target interface is in a connection failure state, it is necessary to determine the reconnection time interval and reconnect to it according to the time interval.
[0063] Step 103: Obtain the stability coefficient of the target interface based on the communication status parameters, and obtain the time interval from the current moment to the next connection to the target interface based on the stability coefficient and the preset time interval.
[0064] For example, there is at least one communication status parameter. For each communication status parameter, the average value of the communication status parameter within a preset historical time period is obtained, the average value is normalized, and then the normalization results of all communication status parameters are weighted and summed to obtain a stability coefficient. The first product of the stability coefficient and the preset time interval is obtained, and the time interval from the current moment to the next connection to the target interface is obtained based on the first product.
[0065] For example, the time interval for the first reconnection to the target interface can be equal to the preset initial time interval. For example, the initial time interval can be 1 second, 1.1 seconds, or other values set according to user needs.
[0066] Step 104: Based on the current time and time interval, determine the next connection time for the target interface, and reconnect to the target interface at the connection time.
[0067] Get the next moment when the time difference between the current moment and the previous moment is equal to the time interval in this step, and determine the next moment obtained from this next moment as the connection time for the next connection to the target interface.
[0068] In distributed systems and network communication, interfaces serve as connection points between different services or components, and their stability and availability can affect the normal operation of the entire system. In practical applications, due to factors such as network fluctuations, server load changes, and software errors, interfaces often experience instability or failures, leading to connection failures. In the event of an interface connection failure, the client or interface caller needs to implement certain reconnection strategies to restore the connection and obtain the correct response from the interface.
[0069] Reconnection strategies in related technologies typically employ fixed reconnection intervals to determine the reconnection time, and then reconnect the interface at that time. Alternatively, they may use linear backoff strategies or simple exponential backoff strategies to determine the reconnection time. While these strategies can achieve interface reconnection and address interface instability to some extent, they have significant limitations. For example, linear backoff strategies lack flexibility in reconnection intervals and cannot dynamically adjust them based on the actual state of the interface. Although simple exponential backoff strategies can increase the interface reconnection interval with the number of reconnections, they also cannot comprehensively consider the actual communication state parameters of the interface when determining the interface reconnection interval.
[0070] The methods of related technologies cannot flexibly determine the reconnection time of the reconnection port based on the actual communication status parameters of the interface. This can lead to an inappropriate waiting time interval for the reconnection port, resulting in long connection times and low connection efficiency.
[0071] In this embodiment, when the target interface connection fails, the communication status parameters of the target interface within a historical time period are obtained. Based on these parameters, the stability coefficient of the target interface is calculated. Then, based on the stability coefficient and a preset time interval, the time interval from the current moment to the next connection to the target interface is determined. The next connection time is determined based on the current moment and the time interval determined by the communication status parameters. This connection time is obtained from the actual communication status parameters of the target interface and reflects these parameters. Compared to related technologies that reconnect to the interface at fixed time intervals or increase the reconnection time interval based on the number of reconnections, this embodiment can flexibly and accurately determine the reconnection time interval based on the actual communication status parameters of the target interface. Reconnection to the target interface is then performed based on this obtained time interval, improving the adaptability and intelligence of the interface connection method and increasing the efficiency of successful target interface connection.
[0072] Figure 2 A flowchart of another interface connection method is provided for reference. Figure 2 The method may include the following steps:
[0073] Step 201: Obtain the connection status of the target interface at the current moment.
[0074] The connection status includes: connection successful or connection failed. The method for this step has been described in step 101 above, and will not be repeated here.
[0075] Step 202: If the connection status is "connection failed", then obtain the communication status parameters of the target interface within a preset historical time period.
[0076] Communication status parameters are used to reflect the stability of the target interface. The method for this step has been described in step 102 above and will not be repeated here.
[0077] For example, communication status parameters may include at least one. For instance, communication status parameters may include the connection failure rate of the target interface within a preset historical time period, the average response time, the current CPU load of the server hosting the target interface, and the current network latency.
[0078] Step 203: Obtain the stability coefficient of the target interface according to the preset weight value corresponding to each communication state parameter.
[0079] For example, the preset weight value can be a fixed value set according to user needs, or it can be a value that is dynamically adjusted according to the communication status parameters of the interface.
[0080] For example, if a communication status parameter is stable within a preset time period, its preset weight value can be reduced; if the communication status parameter is unstable within a preset time period, its preset weight value can be increased.
[0081] Furthermore, after changing the preset weight value of one of the communication status parameters, the difference between the changed preset weight value and the original preset weight value can be proportionally distributed to the communication status parameters that have not been adjusted, so as to ensure that the sum of the preset weight values of all communication status parameters is equal to 1.
[0082] For example, there are four communication status parameters: connection failure rate of the target interface within a preset historical time period, average response time, current CPU load, and current network latency. If the dispersion value of the connection failure rate within the preset time period is higher than a first preset dispersion threshold, its preset weight value is increased by 0.02. After increasing the preset weight value of the connection failure rate by 0.02, the preset weight values of the average response time, current CPU load, and current network latency are decreased by approximately 0.02 / 3 ≈ 0.0067. Therefore, after adjusting the preset weight values of some communication status parameters, the sum of the preset weight values of all communication status parameters remains equal to 1.
[0083] For example, step 203 may include the following sub-steps:
[0084] Sub-step 2031: Obtain the communication status parameters of the target interface at each first preset historical moment within the preset historical time period.
[0085] Specifically, the communication status parameters include connection failure rate, average response time, current CPU load of the server hosting the target interface, and current network latency. These communication status parameters are acquired at each first preset historical moment.
[0086] Sub-step 2032: For each communication status parameter, based on the communication status parameters of the target interface at each first preset historical moment, obtain the dispersion value of the communication status parameter within the preset historical time period.
[0087] The dispersion value reflects the stability of the communication state parameter corresponding to that value within a preset historical time period. Specifically, a larger dispersion value indicates poorer stability of the communication state parameter within the preset historical time period, while a smaller dispersion value indicates better stability of the communication state parameter within the preset historical time period.
[0088] For example, the dispersion value can be either variance or standard deviation. For instance, communication status parameters include the connection failure rate and average response time of the target interface within a preset historical time period. If the dispersion value is variance, then the variance of the connection failure rate and the variance of the average response time can be obtained respectively.
[0089] Sub-step 2033: If the dispersion value is outside the range of the first preset dispersion value corresponding to the communication state parameter, then adjust the preset weight value corresponding to the communication state parameter according to the first preset adjustment step size.
[0090] If the dispersion value is outside the range of the first preset dispersion value corresponding to the communication status parameter, it indicates that the stability of the communication status parameter corresponding to the dispersion value is poor within the preset historical time period. To improve the influence of the communication status parameter on the reconnection time interval, the preset weight value corresponding to the communication status parameter is increased according to the first preset adjustment step size.
[0091] For example, if the dispersion value is greater than or equal to the first preset dispersion threshold, then the preset weight value corresponding to the communication state parameter is increased according to the first preset adjustment step size.
[0092] The first preset adjustment step size can be set by the user's experience; for example, the first preset adjustment step size can be set to 0.02.
[0093] Sub-step 2034: If the dispersion value is within the range of the second preset dispersion value corresponding to the communication state parameter, then adjust the step size according to the second preset and lower the preset weight value corresponding to the communication state parameter.
[0094] If the dispersion value is within the range of the second preset dispersion value corresponding to the communication status parameter, it indicates that the stability of the communication status parameter corresponding to the dispersion value is good. In this case, the influence of the communication status parameter on the reconnection target interface time interval can be reduced. Therefore, according to the second preset adjustment step size, the preset weight value corresponding to the communication status parameter is lowered.
[0095] For example, if the dispersion value is less than or equal to the second preset dispersion threshold, then the preset weight value corresponding to the communication state parameter is reduced according to the second preset adjustment step size.
[0096] For example, if the dispersion value is greater than the second preset dispersion threshold and less than the first dispersion threshold, then the preset weight value corresponding to the communication state parameter remains unchanged.
[0097] The second preset adjustment step size can be set by the user's experience; for example, the second preset adjustment step size can be set to 0.05.
[0098] In this embodiment, the dispersion value can be obtained through sub-steps 2031 to 2034, and the preset weight value of the communication state parameter can be adjusted according to the dispersion value. In one embodiment, the preset weight value of the communication state parameter can also be dynamically adjusted using the following method.
[0099] Specifically, by persistent data such as communication status parameters and time intervals during the target interface reconnection process, various communication status parameters of the target interface are obtained at multiple first preset historical moments within a preset historical time period. If the dispersion value of a certain communication status parameter within the preset historical time period is within a second preset dispersion range, it indicates that it has remained stable within the preset historical time period. In this case, the preset weight coefficient is reduced, with the adjusted preset weight coefficient not exceeding a preset weight coefficient threshold. For example, it is reduced by 0.05 each time until the minimum weight of 0.1 is reached.
[0100] If the dispersion value of a certain communication status parameter within a preset historical time period is outside the first preset dispersion range, it indicates that its fluctuation within the preset historical time period is large. For example, if the first preset dispersion range is 20%, then if the rate of change of this communication status parameter within the preset historical time period exceeds 20%, it indicates that its fluctuation within the preset historical time period is large. In this case, the weight coefficient is increased, with the constraint that the adjusted preset weight coefficient does not exceed the preset weight coefficient threshold. For example, it is increased by 0.02 each time, until the maximum weight of 0.4 is reached.
[0101] Furthermore, when the preset weight value of a certain communication status parameter is decreased or increased, the preset weight values of other communication status parameters are appropriately increased or decreased so that the sum of the preset weight values of all communication status parameters equals 1.
[0102] For example, communication status parameters include response time, network latency, connection failure rate, and server CPU load. If the rate of change of response time and network latency is less than 5% during the preset historical time period from time A to time B, then these two communication status parameters are considered relatively stable, and the preset weight values of response time and network latency are reduced.
[0103] For example, if the connection failure rate suddenly rises to 0.3% at a certain moment during the preset historical time period from time A to time B, and the rate of change exceeds 20%, then the communication state parameter is determined to be unstable, and its preset weight value is increased.
[0104] For example, if the server CPU load fluctuates within a preset time period but does not reach the threshold for increasing the preset weight value, then the preset weight value of the server CPU load remains unchanged, or it is reduced by a smaller preset step.
[0105] For example, for each communication state parameter, its minimum and maximum values at multiple first preset historical moments can be obtained, and then the difference between the maximum and minimum values can be calculated. When the difference is outside the first preset difference range, the preset weight value corresponding to the communication state parameter is increased according to the first preset adjustment step size; when the difference is within the second preset difference range, the preset weight value corresponding to the communication state parameter is decreased according to the second preset adjustment step size.
[0106] In one embodiment, the preset weight value of the communication state parameter can also be dynamically adjusted according to the following method: obtain the communication state parameter at the previous moment and the communication state parameter at the current moment, and obtain the rate of change of the communication state parameter at the current moment relative to the communication state parameter at the previous moment. If the rate of change exceeds a first rate of change threshold, the preset weight value corresponding to the communication state parameter is increased according to a first preset adjustment step size; if the rate of change does not exceed a second rate of change threshold, the preset weight value corresponding to the communication state parameter is decreased according to a second preset adjustment step size.
[0107] After dynamically adjusting the preset weight value, the reconnection time interval is recalculated based on the adjusted preset weight value when calculating the reconnection time interval next time.
[0108] Step 204: Obtain the historical time interval between the last connection failure and the current time for the target interface.
[0109] Furthermore, the last connection failure time refers to the time adjacent to the current time when the target interface connection failed. If the last connection status of the target interface was successful, then the preset time interval is determined as the historical time interval.
[0110] For example, three consecutive historical moments are T1, T2, and T3, and the current moment is T4. If the target interface connection fails at historical moment T3, then historical moment T3 is the moment when the connection failed last time. The time difference between historical moment T3 and the current moment T4 is the historical time interval between the target interface from the moment when the connection failed last time to the current moment in this step.
[0111] For example, if the target interface connection fails at historical time T2 but succeeds at historical time T3, this is a case of a previous successful connection. In this case, the first preset time interval is directly used to determine the historical time interval.
[0112] Step 205: Based on the historical time interval and stability coefficient, obtain the time interval from the current moment to the next connection to the target interface.
[0113] For example, obtain the first product of the historical time interval and the stability coefficient, and based on the first product, obtain the time interval from the current moment to the next connection to the target interface.
[0114] Furthermore, step 205 may include the following sub-steps:
[0115] Sub-step 2051: Obtain the first product of the stability coefficient and the preset adjustment coefficient, and obtain the dynamic adjustment factor based on the first product.
[0116] Furthermore, a preset benchmark factor can be obtained, and then the product of the benchmark factor and the first product can be obtained. The product of the benchmark factor and the first product is then determined as the dynamic adjustment factor.
[0117] For example, if the preset baseline factor is 2, the stability coefficient is 0.42, and the preset adjustment coefficient is 0.5, then the dynamic adjustment factor is: 2×e^(0.42×0.5)=2×e^(0.21)≈2.467.
[0118] Sub-step 2052: Obtain the second product of the historical time interval and the dynamic adjustment factor.
[0119] For example, if the previous connection status was successful, and the first preset time interval is 1 second with a dynamic adjustment factor of 2.467, then the second product is: 1 × 2.467 = 2.467.
[0120] Sub-step 2053: Based on the second product, obtain the time interval from the current moment to the next connection to the target interface.
[0121] For example, the second product is determined as the time interval from the current moment to the next connection to the target interface. Specifically, if the connection status of the target interface is successful at the current moment, then the preset time interval is determined as the time interval from the current moment to the next connection to the target interface.
[0122] Furthermore, the method of this embodiment, based on multi-dimensional communication state parameters and dynamic adjustment factors, realizes an adaptive exponential backoff reconnection strategy, and solves the problems of insufficient flexibility, uneven resource consumption, and lack of intelligence in related technologies. In this embodiment, by introducing multi-dimensional communication state parameters and obtaining time intervals based on these parameters, precise control is achieved over the growth rate of the time interval of the reconnection target interface, improving the adaptability and intelligence of the reconnection strategy.
[0123] Step 206: Determine the next connection time for the target interface based on the current time and the time interval, and reconnect to the target interface at the connection time.
[0124] The method for this step has been explained in step 104 above, and will not be repeated here.
[0125] For example, step 206 may include the following sub-steps:
[0126] Sub-step 2061: Obtain the number of consecutive connection failures of the target interface from the current time to the second preset historical time.
[0127] Specifically, if the connection status of the target interface is "connection failed" at the current moment, then the count is performed from the current moment back to the historical time to obtain the number of consecutive failures, including the current connection failure status.
[0128] For example, if three consecutive historical moments are T1, T2, and T3, and the current moment is T4, and the target interface connection fails at historical moment T1, succeeds at historical moment T2, and fails again at historical moment T3, then the consecutive failure moments are historical moment T3 and the current moment T4, and the number of consecutive failures is two.
[0129] For example, if the target interface fails to connect at historical times T1, T2, and T3, as well as at the current time T4, then the number of consecutive failures is 4.
[0130] Sub-step 2062: If the number of failures is less than or equal to the preset threshold, then determine the next connection time for the target interface based on the current time and the time interval, and reconnect to the target interface at the connection time.
[0131] If the number of failures is less than or equal to the preset threshold, it means that there is still a possibility of successfully connecting to the target interface. Therefore, based on the current time and the time interval, the connection time for the next connection to the target interface is determined, and the target interface is reconnected at the connection time.
[0132] The preset threshold can be the upper limit of the number of reconnections set by the user. For example, the preset threshold can be set to 10 times.
[0133] For example, step 206 may include the following sub-steps:
[0134] Sub-step 2063: Determine whether the time interval exceeds the preset time interval threshold.
[0135] For example, the preset time interval threshold is the upper limit of the time interval set by the user. For instance, the preset time interval threshold could be 10 minutes.
[0136] Sub-step 2064: If the time interval does not exceed the preset time interval threshold, determine the next connection time to the target interface based on the current time and the time interval, and reconnect to the target interface at the connection time.
[0137] If the time interval does not exceed the preset time interval threshold, it means that the currently calculated time interval has not exceeded the user-defined time interval limit, and the target interface has the possibility of successful connection. Therefore, based on the current time and the time interval, the connection time for the next connection to the target interface is determined, and the target interface is reconnected at the connection time.
[0138] The fixed reconnection strategy in related technologies cannot be flexibly adjusted according to the actual state of the interface, resulting in low interface reconnection efficiency and unnecessary waste of server resources. In this embodiment, by comprehensively considering multiple dimensions of communication status parameters, the connection time of the target interface to be reconnected is obtained based on these parameters. Based on these multiple dimensions of communication status parameters, the stability of the target interface can be more accurately assessed, and the interval time in the reconnection strategy can be adjusted accordingly. Based on the method of this embodiment, the time interval for reconnecting to the target interface can be accurately obtained, reducing unnecessary interface reconnections and improving the reconnection success rate when the target interface is unstable. In other words, in this embodiment, by comprehensively considering multiple dimensions of communication status parameters and obtaining the time interval for reconnecting to the target interface based on these parameters, precise control of the reconnection strategy can be achieved, improving the efficiency of successful interface reconnection.
[0139] In one embodiment, step 202 may include the following sub-steps:
[0140] Sub-step 2021: Obtain the communication status parameters of the target interface at each first preset historical moment within the preset historical time period.
[0141] The first preset historical time can be set according to user needs.
[0142] Correspondingly, step 203 may include the following sub-steps:
[0143] Sub-step 2031: For each type of communication status parameter, obtain the average value of the communication status parameter based on the communication status parameter at each first preset historical moment.
[0144] For each communication state parameter, the average value of the communication state parameter is obtained by averaging the communication state parameters at all first preset historical times.
[0145] Sub-step 2032: Normalize the average value of the communication status parameters to obtain the normalized value of the communication status parameters.
[0146] For example, obtain the maximum value of the preset communication status parameter, obtain the average value of the communication status parameter, and the ratio of the average value of the communication status parameter to the maximum value of the communication status parameter, and determine the ratio as the normalized value of the communication status parameter.
[0147] Sub-step 2033: Based on the preset weight values corresponding to each communication state parameter, perform weighted summation on the normalized values of each communication state parameter, and obtain the stability coefficient of the target interface based on the weighted summation result.
[0148] For example, communication status parameters include the connection failure rate of the target interface within a preset historical time period, the average response time, the current CPU load of the server where the target interface is located, and the current network latency.
[0149] For example, if the preset weight for connection failure rate is 0.3, the preset weight for average response time is 0.2, the preset weight for the current CPU load of the server where the target interface is located is 0.3, and the preset weight for current network latency is 0.3, the normalized values corresponding to these four communication status parameters are 0.1, 200 / 500, 0.7, and 100 / 200, respectively. Then the stability coefficient of the target interface is: 0.3×0.1+0.2×(200 / 500)+0.3×0.7+0.2×(100 / 200)=0.03+0.08+0.21+0.1=0.42.
[0150] Reference Figure 3 The present invention also provides an interface connection system, which includes a data collection module, a stability assessment module, a dynamic adjustment factor calculation module, a reconnection strategy execution module, and a log recording and alarm module.
[0151] The data collection module is used to collect key communication status parameters such as historical failure rate and response time of the target interface, and store these communication status parameters in the database for subsequent calculation of reconnection time interval and reconnection decision-making.
[0152] The stability assessment module calculates the stability coefficient of the target interface based on communication status parameters provided by the data collection module over a historical period. The stability coefficient is a value between 0 and 1, reflecting the stability and performance of the target interface over the historical period. The calculation method for the stability coefficient can be selected and optimized according to actual conditions; for example, the stability coefficient can be obtained by referring to step 203 mentioned above.
[0153] The dynamic adjustment factor calculation module is used to dynamically calculate the adjustment factor based on the stability coefficient calculated by the stability assessment module. The adjustment factor is a value greater than 1, used to adjust the growth rate of the reconnection time interval. For example, when the target interface has high stability, the adjustment factor is smaller, and the reconnection time interval grows more slowly; when the target's stability is low, the adjustment factor is larger, and the reconnection time interval grows more quickly. For instance, the adjustment factor can be obtained from the aforementioned sub-step 2051.
[0154] The reconnection strategy execution module is used to calculate the next reconnection interval based on the dynamic adjustment factor and the current reconnection target interface time interval, and to execute interface monitoring tasks. During the reconnection process, the reconnection strategy execution module also continuously collects interface status information and updates it to the database.
[0155] The logging and alarm module records information such as the reconnection interval and interface status for subsequent analysis and optimization. When the number of consecutive connection failures of the target interface reaches a preset threshold, or the determined time interval reaches a preset time interval threshold, it indicates that the target interface may have a connection failure and requires maintenance personnel to repair it. In this case, an alarm is triggered to notify the relevant maintenance personnel.
[0156] Figure 4 This is a flowchart illustrating the steps of another interface connection method provided in this embodiment of the invention, referred to... Figure 4 As shown, the method may include the following steps:
[0157] Step S1: Determine whether the target interface connection status is failed. If it fails, proceed to step S2; otherwise, proceed to step S12.
[0158] The method for this step has been explained in step 201 above, and will not be repeated here.
[0159] Step S2, prepare for reconnection.
[0160] For example, you can prepare to resend the access request to the target interface to complete the preparatory reconnection of the target interface.
[0161] Step S3: Obtain the target interface communication status parameters.
[0162] Communication status parameters are the basic data of the target interface. This basic data consists of key metrics stored in the database for the target interface, which may include historical failure rate, historical average response time, current CPU load, and current network latency.
[0163] For example, in one embodiment, the historical failure rate of the target interface is 10%, the historical average response time is 200ms, the current CPU load is 70%, and the current network latency is 100ms. Here, a load of 70% means that the current CPU load is 0.7 times the preset load threshold.
[0164] Step S4: Normalize the communication status parameters.
[0165] Based on the preset maximum value of the communication status parameters, the collected communication status parameters are normalized to convert them into percentages between 0 and 1.
[0166] For example, if the historical average response time is 200ms and the maximum historical response time is set to 500ms, then the result of normalizing the historical average response time is 200 / 500.
[0167] Step S5: Obtain the stability coefficient of the interface based on the normalized communication state parameters.
[0168] For example, preset weight values can be set for each dimension based on historical data and expert experience. In one embodiment, the preset weight value for historical failure rate can be set to 0.3, the preset weight value for historical average response time can be set to 0.2, the preset weight value for current load can be set to 0.3, and the preset weight value for network latency can be set to 0.2; the current CPU load is 70%, the response time is 50ms, and the preset maximum response time is 500ms; the network latency is 100ms, and the preset maximum network latency is 200ms.
[0169] Based on steps S4 to S5, the stability coefficient is: 0.3×0.1+0.2×(200 / 500)+0.3×0.7+0.2×(100 / 200)=0.03+0.08+0.21+0.1=0.42.
[0170] Step S6: Obtain the dynamic adjustment factor based on the stability coefficient.
[0171] For example, the baseline factor is set to 2, and the adjustment coefficient is set to 0.5. Based on the stability coefficient and the preset baseline factor and adjustment coefficient, the dynamic adjustment factor is calculated. For instance, in one embodiment, the stability coefficient is 0.42, and the calculated dynamic adjustment factor is: 2 × e (0.42×0.5) =2×e (0.21) ≈2.467.
[0172] Step S7: Obtain the reconnection time interval based on the dynamic adjustment factor.
[0173] When reconnecting to the target interface for the first time, the reconnection can be performed according to a set initial time interval, such as 1 second.
[0174] If the first reconnection fails, calculate the time interval for the second reconnection based on the time interval of the first reconnection. For example, if the dynamic adjustment factor for the second reconnection is calculated to be 2.467 according to the previous steps, then the time interval for the second reconnection would be: 1 second × 2.467. 1 ≈2.467 seconds.
[0175] If the second reconnection also fails, the next reconnection interval will be calculated as: 2.467 seconds × 2.467 seconds. 1 ≈6.086 seconds, and so on, to obtain the time interval for each reconnection, and reconnect to the target interface according to the time interval until the interface recovers the connection.
[0176] It should be noted that if the number of reconnections to the target interface reaches the maximum number of reconnections, or the calculated time interval reaches the maximum reconnection time interval, it indicates that the target interface may have a fault. Even if reconnection continues, the probability of successful reconnection is very low. In this case, reconnection can be stopped, and the reconnection data of the target interface can be generated as log data for maintenance personnel to repair the target interface based on the log data.
[0177] Step S8: Reconnect the interface according to the reconnection time interval.
[0178] Specifically, based on the current time and the reconnection time interval, the connection time for the next reconnection is calculated, and the target interface is connected at that connection time.
[0179] Step S9: Determine if the reconnection was successful. If it failed, proceed to step S10; otherwise, proceed to step S12.
[0180] For instructions on how to determine if the reconnection was successful, please refer to step 101. These instructions will not be repeated here.
[0181] Step S10: Determine whether the current reconnection time interval exceeds the preset time threshold. If yes, proceed to step S11; otherwise, proceed to step S12.
[0182] The method for this step has been explained in the aforementioned sub-step 2063, and will not be repeated here.
[0183] Step S11: Determine whether the current number of reconnections exceeds the preset threshold. If yes, proceed to step S12; otherwise, return to step S2.
[0184] The method for this step has been explained in the aforementioned sub-step 2062, and will not be repeated here.
[0185] Furthermore, during each reconnection process, the reconnection interval, interface status, and multi-dimensional communication status information can be recorded and persistently stored.
[0186] When the continuous failure of reconnection to the target interface reaches the preset failure count threshold, or when the calculated reconnection time interval exceeds the preset time interval threshold, an alarm mechanism is triggered, and the relevant data of the target interface is notified to the relevant personnel.
[0187] Step S12, stop reconnecting the port.
[0188] This embodiment can deeply optimize the reconnection strategy in complex interface monitoring services. When calculating the time interval, this embodiment not only takes into account the historical failure rate and response time of the interface, but also introduces multi-dimensional information such as interface load and network status. Based on multi-dimensional communication status information, more accurate and intelligent interface reconnection control can be achieved, thereby optimizing resource consumption, improving interface monitoring efficiency, and ensuring the stability and availability of the interface.
[0189] refer to Figure 5 It illustrates an interface connection device 30 provided in an embodiment of this application, the interface connection device 30 including:
[0190] The first acquisition module 301 is used to acquire the connection status of the target interface at the current moment; the connection status includes: connection successful or connection failed.
[0191] The second acquisition module 302 is used to acquire the communication status parameters of the target interface within a preset historical time period if the connection status is a connection failure; the communication status parameters are used to reflect the stability of the target interface.
[0192] The first determining module 303 is used to obtain the stability coefficient of the target interface according to the communication status parameters, and to obtain the time interval from the current moment to the next connection to the target interface according to the stability coefficient and the preset time interval.
[0193] The second determining module 304 is used to determine the next connection time to the target interface based on the current time and the time interval, and to reconnect the target interface at the connection time.
[0194] Optionally, the communication status parameters include at least one; the first determining module 303 may include:
[0195] The first acquisition submodule is used to acquire the stability coefficient of the target interface according to the preset weight value corresponding to each communication state parameter.
[0196] The second acquisition submodule is used to acquire the historical time interval of the target interface from the last connection failure to the current time.
[0197] The third acquisition submodule is used to obtain the time interval from the current moment to the next connection to the target interface based on historical time intervals and stability coefficients.
[0198] Optionally, the third acquisition submodule may include:
[0199] The first acquisition unit is used to acquire the first product of the stability coefficient and the preset adjustment coefficient, and to acquire the dynamic adjustment factor based on the first product;
[0200] The second acquisition unit is used to acquire the second product of the historical time interval and the dynamic adjustment factor;
[0201] The third acquisition unit is used to acquire the time interval from the current moment to the next connection to the target interface based on the second product.
[0202] Optionally, the first acquisition module 301 includes:
[0203] The fourth acquisition submodule is used to acquire the communication status parameters of the target interface at each first preset historical moment within a preset historical time period.
[0204] The first acquisition submodule includes:
[0205] The fourth acquisition unit is used to acquire the average value of the communication status parameter for each communication status parameter based on the communication status parameter at each first preset historical moment.
[0206] The fifth acquisition unit is used to normalize the average value of the communication state parameter for each type of communication state parameter to obtain the normalized value of the communication state parameter.
[0207] The sixth acquisition unit is used to perform weighted summation on the normalized value of each communication state parameter according to the preset weight value corresponding to each communication state parameter, and obtain the stability coefficient of the target interface based on the weighted summation result.
[0208] Optionally, the first acquisition submodule may include:
[0209] The seventh acquisition submodule is used to acquire the communication status parameters of the target interface at each first preset historical moment within a preset historical time period;
[0210] The eighth acquisition submodule is used to acquire the dispersion value of the communication status parameter within a preset historical time period based on the communication status parameter of the target interface at each first preset historical moment for each communication status parameter.
[0211] The first adjustment submodule is used to increase the preset weight value corresponding to the communication state parameter according to the first preset adjustment step size if the dispersion value is outside the range of the first preset dispersion value corresponding to the communication state parameter.
[0212] The second adjustment submodule is used to reduce the preset weight value corresponding to the communication state parameter according to the second preset adjustment step size if the dispersion value is within the range of the second preset dispersion value corresponding to the communication state parameter.
[0213] Optionally, the second determining module 304 may include:
[0214] The ninth submodule is used to obtain the number of consecutive connection failures of the target interface within the historical time period from the current time to the second preset historical time.
[0215] The first determination submodule is used to determine the next connection time to the target interface based on the current time and time interval if the number of failures is less than or equal to a preset threshold, and to reconnect to the target interface at the connection time.
[0216] Optionally, the second determining module 304 may include:
[0217] The judgment submodule is used to determine whether the time interval is less than or equal to a preset time interval threshold;
[0218] The second determining submodule is used to determine the next connection time to the target interface based on the current time and the time interval if the time interval is less than or equal to a preset time interval threshold, and to reconnect the target interface at the connection time.
[0219] In this embodiment, when the target interface connection fails, the communication status parameters of the target interface within a historical time period are obtained. Based on the communication status parameters, the time interval from the current moment to the next connection to the target interface is obtained. Based on the current moment and the time interval determined by the communication status parameters, the connection time for the next connection to the target interface is determined. This connection time is obtained based on the actual communication status parameters of the target interface and reflects these parameters. Compared to related technologies that reconnect to the interface at fixed time intervals or increase the reconnection time interval based on the number of reconnections, this embodiment can flexibly and accurately determine the reconnection time interval based on the actual communication status parameters of the target interface, improving the adaptability and intelligence of the interface connection method and increasing the efficiency of successful target interface connection.
[0220] Reference Figure 6 The electronic device 400 may include one or more of the following components: processing component 402, memory 404, power supply component 406, multimedia component 408, audio component 410, input / output (I / O) interface 412, sensor component 414, and communication component 416.
[0221] Processing component 402 typically controls the overall operation of electronic device 400, such as operations associated with display, telephone calls, data communication, camera operation, and recording. Processing component 402 may include one or more processors 420 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 402 may include one or more modules to facilitate interaction between processing component 402 and other components. For example, processing component 402 may include a multimedia module to facilitate interaction between multimedia component 408 and processing component 402.
[0222] Memory 404 is used to store various types of data to support the operation of electronic device 400. Examples of this data include instructions for any application or method operating on electronic device 400, contact data, phonebook data, messages, pictures, multimedia, etc. Memory 404 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0223] Power supply component 406 provides power to various components of electronic device 400. Power supply component 406 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 400.
[0224] Multimedia component 408 includes an interface that provides an output interface between electronic device 400 and a user. In some embodiments, the interface may include a liquid crystal display (LCD) and a touch panel (TP). If the interface includes a touch panel, the interface may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may not only sense the boundaries of touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 408 includes a front-facing camera and / or a rear-facing camera. When electronic device 400 is in an operating mode, such as a shooting mode or a multimedia mode, the front-facing camera and / or rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0225] Audio component 410 is used to output and / or input audio signals. For example, audio component 410 includes a microphone (MIC) used to receive external audio signals when electronic device 400 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 404 or transmitted via communication component 416. In some embodiments, audio component 410 also includes a speaker for outputting audio signals.
[0226] Input / output (I / O) interface 412 provides an interface between processing component 402 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0227] Sensor assembly 414 includes one or more sensors for providing state assessments of various aspects of electronic device 400. For example, sensor assembly 414 may detect the on / off state of electronic device 400, the relative positioning of components such as the display and keypad of electronic device 400, changes in position of electronic device 400 or a component of electronic device 400, the presence or absence of user contact with electronic device 400, orientation or acceleration / deceleration of electronic device 400, and temperature changes of electronic device 400. Sensor assembly 414 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 414 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 414 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.
[0228] Communication component 416 facilitates wired or wireless communication between electronic device 400 and other devices. Electronic device 400 can access wireless networks based on communication standards, such as WiFi, carrier networks (such as 2G, 3G, 4G, or 5G), or combinations thereof. In one exemplary embodiment, communication component 416 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 416 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0229] In an exemplary embodiment, the electronic device 400 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to implement an interface connection method provided in the embodiments of this application.
[0230] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 404 including instructions, which can be executed by a processor 420 of an electronic device 400 to perform the above-described method. For example, the non-transitory storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0231] Figure 7 This is a block diagram of an electronic device 500 according to another embodiment of the present invention. For example, the electronic device 500 may be provided as a server. (See also...) Figure 7 The electronic device 500 includes a processing component 522, which further includes one or more processors, and memory resources represented by a memory 532 for storing instructions, such as application programs, that can be executed by the processing component 522. The application programs stored in the memory 532 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 522 is configured to execute instructions to perform an interface connection method provided in embodiments of this application.
[0232] Electronic device 500 may also include a power supply component 526 configured to perform power management of electronic device 500, a wired or wireless network interface 550 configured to connect electronic device 500 to a network, and an input / output (I / O) interface 558. Electronic device 500 may operate on an operating system stored in memory 532, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or similar.
[0233] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0234] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. An interface connection method, characterized in that, include: Get the connection status of the target interface at the current moment; The connection status includes: connection successful or connection failed; If the connection status is a connection failure, then the communication status parameters of the target interface within a preset historical time period are obtained; the communication status parameters are used to reflect the stability of the target interface. The stability coefficient of the target interface is obtained based on the communication status parameters, and the historical time interval from the last connection failure to the current time is obtained. Obtain the first product of the stability coefficient and the preset adjustment coefficient, and obtain the dynamic adjustment factor based on the first product; Obtain the second product of the historical time interval and the dynamic adjustment factor; Based on the second product, obtain the time interval from the current moment to the next connection to the target interface; Based on the current time and the time interval, determine the next connection time for connecting to the target interface, and reconnect to the target interface at the specified connection time.
2. The method according to claim 1, characterized in that, The communication status parameters include at least one; obtaining the stability coefficient of the target interface based on the communication status parameters includes: The stability coefficient of the target interface is obtained based on the preset weight value corresponding to each communication state parameter.
3. The method according to claim 2, characterized in that, If the connection status is a connection failure, then obtain the communication status parameters of the target interface within a preset historical time period, including: The communication status parameters of the target interface are obtained at each first preset historical moment within a preset historical time period. The step of obtaining the stability coefficient of the target interface based on the preset weight value corresponding to each communication state parameter includes: For each communication status parameter, the average value of the communication status parameter is obtained based on the communication status parameter at each first preset historical moment; For each communication state parameter, the average value of the communication state parameter is normalized to obtain the normalized value of the communication state parameter. Based on the preset weight values corresponding to each communication state parameter, the normalized values of each communication state parameter are weighted and summed, and the stability coefficient of the target interface is obtained based on the weighted summation result.
4. The method according to claim 2, characterized in that, The step of obtaining the stability coefficient of the target interface based on the preset weight value corresponding to each communication state parameter includes: Obtain the communication status parameters of the target interface at each first preset historical moment within a preset historical time period; For each communication status parameter, based on the communication status parameters of the target interface at each first preset historical moment, the dispersion value of the communication status parameter within the preset historical time period is obtained; If the dispersion value is outside the range of the first preset dispersion value corresponding to the communication state parameter, then the preset weight value corresponding to the communication state parameter is increased according to the first preset adjustment step size. If the dispersion value is within the range of the second preset dispersion value corresponding to the communication state parameter, then the preset weight value corresponding to the communication state parameter is reduced according to the second preset adjustment step size.
5. The method according to claim 1, characterized in that, The step of determining the next connection time for connecting to the target interface based on the current time and the time interval, and reconnecting to the target interface at the specified connection time, includes: Get the number of consecutive connection failures of the target interface within the historical time period from the current time to the second preset historical time. If the number of failures is less than or equal to a preset threshold, then the next connection time for connecting to the target interface is determined based on the current time and the time interval, and the target interface is reconnected at the specified connection time.
6. The method according to claim 1, characterized in that, The step of determining the next connection time for connecting to the target interface based on the current time and the time interval, and reconnecting to the target interface at the specified connection time, includes: Determine whether the time interval is less than or equal to a preset time interval threshold; If the time interval is less than or equal to the preset time interval threshold, then the connection time for the next connection to the target interface is determined based on the current time and the time interval, and the target interface is reconnected at the connection time.
7. An interface connection device, characterized in that, include: The first acquisition module is used to acquire the connection status of the target interface at the current moment; The connection status includes: connection successful or connection failed; The second acquisition module is used to acquire the communication status parameters of the target interface within a preset historical time period if the connection status is a connection failure; the communication status parameters reflect the stability of the target interface. The first determining module is configured to obtain the stability coefficient of the target interface based on the communication status parameters, and obtain the historical time interval from the last connection failure of the target interface to the current time; obtain the first product of the stability coefficient and the preset adjustment coefficient, and obtain the dynamic adjustment factor based on the first product; obtain the second product of the historical time interval and the dynamic adjustment factor; and obtain the time interval from the current time to the next connection to the target interface based on the second product. The second determining module is used to determine the next connection time for connecting to the target interface based on the current time and the time interval, and to reconnect to the target interface at the connection time.
8. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a program or instructions that can run on the processor, the program or instructions being executed by the processor to implement the steps of the method as described in any one of claims 1 to 6.
9. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Network connection method and apparatus
CN107135536A
Equipment monitoring alarm method and device, storage medium and electronic equipment
CN110224885A