CN112905930B - Interface request retransmission method and device - Google Patents
Interface request retransmission method and device Download PDFInfo
- Publication number
- CN112905930B CN112905930B CN201911229042.1A CN201911229042A CN112905930B CN 112905930 B CN112905930 B CN 112905930B CN 201911229042 A CN201911229042 A CN 201911229042A CN 112905930 B CN112905930 B CN 112905930B
- Authority
- CN
- China
- Prior art keywords
- request
- retransmission
- interface
- interval time
- threshold
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 33
- 238000004590 computer program Methods 0.000 claims description 9
- 230000002159 abnormal effect Effects 0.000 claims description 4
- 238000010586 diagram Methods 0.000 description 9
- 238000004891 communication Methods 0.000 description 8
- 230000006870 function Effects 0.000 description 8
- 238000012545 processing Methods 0.000 description 8
- 238000001914 filtration Methods 0.000 description 4
- 230000003287 optical effect Effects 0.000 description 4
- 230000009286 beneficial effect Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 230000000694 effects Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 239000000835 fiber Substances 0.000 description 2
- 238000012423 maintenance Methods 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 230000004044 response Effects 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 239000006227 byproduct Substances 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 239000012467 final product Substances 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/958—Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Transfer Between Computers (AREA)
- Communication Control (AREA)
Abstract
The invention discloses a method and a device for retransmitting an interface request, and relates to the technical field of computers. One embodiment of the method comprises the following steps: a request is sent to a server, a request failure message fed back by the server is received, and a retransmission frequency threshold corresponding to an interface for sending the request is obtained; determining the resending times of the current request, and if the resending times are smaller than the resending times threshold, acquiring a resending interval time threshold corresponding to the interface; based on the retransmission interval time threshold and the remaining number of retransmissions, a retransmission interval time of the current pair of requests is determined to perform a request retransmission operation when the retransmission interval time is reached. According to the embodiment, two parameters of retransmission times and retransmission interval time are set for an interface, so that the ajax requests for automatic retransmission; in addition, the time of the retransmission interval with the number of times of retransmission being more than 1 can be adjusted according to the updating strategy, so that the flexibility of requesting retransmission is realized.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for retransmitting an interface request.
Background
The final product form of the Web front-end depends mostly on the browser, and ajax (Asynchronous Javascript And XML ) which is commonly used as the browser requests communication, axios is an ajax library with the largest current use proportion. And a Web front-end developer initiates an ajax request to communicate with the server through the ajax library to finish the adding and deleting operations on the data or the interface.
In carrying out the present invention, the inventors have found that at least the following problems exist in the prior art:
When the network environment is poor or the server is in an unstable scene, ajax request errors are easy to cause, and the existing axios library lacks the function of automatic retransmission of ajax requests, so that the use experience of users is affected, and the loss of users is caused.
Disclosure of Invention
In view of this, the embodiment of the invention provides a method and a device for retransmitting an interface request, which at least can solve the problem that the existing function of automatic retransmission of an ajax request cannot be realized.
To achieve the above object, according to one aspect of the embodiments of the present invention, there is provided an interface request retransmission method, including:
A request is sent to a server, a request failure message fed back by the server is received, and a retransmission frequency threshold corresponding to an interface for sending the request is obtained;
Determining the current resending times of the request, and if the resending times are smaller than the resending times threshold, acquiring a resending interval time threshold corresponding to the interface;
and determining the retransmission interval time of the request according to the retransmission interval time threshold and the residual retransmission times, so as to perform the retransmission request operation when the retransmission interval time is reached.
Optionally, after the receiving the request failure message fed back by the server, before the obtaining the retransmission frequency threshold corresponding to the interface, the method further includes:
And acquiring the status code in the request failure message, and if the status code is the first status code, determining that the request is a re-transmissible request.
Optionally, before the obtaining the threshold value of the retransmission times corresponding to the interface, the method further includes:
determining the interface type of the interface according to the interface information of the interface, and acquiring a retransmission time threshold and a retransmission interval time threshold corresponding to the interface type; and
And registering the retransmission times threshold and the retransmission interval time threshold in a database corresponding to the interface to obtain a configuration item of the interface.
Optionally, the determining the retransmission interval time of the current request based on the retransmission interval time threshold and the remaining number of retransmissions includes:
If the number of times of retransmission is zero, determining that the request is retransmitted for the first time, and taking the retransmission interval time threshold value as the retransmission interval time of the request; or (b)
If the number of times of retransmission is greater than zero, determining that the request is not first retransmitted, calculating the ratio of the retransmission interval time threshold value to the remaining number of times of retransmission, and taking the ratio as the retransmission interval time of the request.
Optionally, after the receiving the request failure message fed back by the server, the method further includes:
acquiring a status code in the request failure message, and if the status code is a second status code, determining that the request is a non-resendable request; and
And counting the number of request failures received in the preset time, and triggering abnormal reporting operation of the interface if the number of request failures is greater than or equal to a preset request failure number threshold.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided an interface request retransmission apparatus including:
The information receiving module is used for sending a request to the server, receiving a request failure message fed back by the server and acquiring a retransmission frequency threshold corresponding to an interface for sending the request;
The number comparison module is used for obtaining a retransmission interval time threshold corresponding to the interface if the number of times of retransmission of the request is smaller than the retransmission number threshold;
and the request retransmission module is used for determining the retransmission interval time of the request according to the retransmission interval time threshold and the residual retransmission times so as to perform request retransmission operation when the retransmission interval time is reached.
Optionally, the information receiving module is further configured to:
And acquiring the status code in the request failure message, and if the status code is the first status code, determining that the request is a re-transmissible request.
Optionally, the information receiving module is configured to:
determining the interface type of the interface according to the interface information of the interface, and acquiring a retransmission time threshold and a retransmission interval time threshold corresponding to the interface type; and
And registering the retransmission times threshold and the retransmission interval time threshold in a database corresponding to the interface to obtain a configuration item of the interface.
Optionally, the request resending module is configured to:
If the number of times of retransmission is zero, determining that the request is retransmitted for the first time, and taking the retransmission interval time threshold value as the retransmission interval time of the request; or (b)
If the number of times of retransmission is greater than zero, determining that the request is not first retransmitted, calculating the ratio of the retransmission interval time threshold value to the remaining number of times of retransmission, and taking the ratio as the retransmission interval time of the request.
Optionally, the system further comprises an exception reporting module, configured to:
acquiring a status code in the request failure message, and if the status code is a second status code, determining that the request is a non-resendable request; and
And counting the number of request failures received in the preset time, and triggering abnormal reporting operation of the interface if the number of request failures is greater than or equal to a preset request failure number threshold.
To achieve the above object, according to still another aspect of the embodiments of the present invention, there is provided an interface request retransmission electronic device.
The electronic equipment of the embodiment of the invention comprises: one or more processors; and a storage device for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement any of the interface request retransmission methods described above.
To achieve the above object, according to still another aspect of the embodiments of the present invention, there is provided a computer readable medium having stored thereon a computer program which, when executed by a processor, implements any of the interface request retransmission methods described above.
According to the solution provided by the present invention, one embodiment of the above invention has the following advantages or beneficial effects: setting two parameters of retransmission times and retransmission interval time aiming at an interface, so as to realize automatic retransmission of the ajax request without manual operation; in addition, the time of the retransmission interval with the number of times of retransmission being more than 1 can be adjusted according to the updating strategy, so that the flexibility of requesting retransmission is realized.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
Fig. 1 is a schematic flow chart of an interface request retransmission method according to an embodiment of the present invention;
Fig. 2 is a flow chart of a specific interface request retransmission method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of the main modules of an interface request retransmission apparatus according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 5 is a schematic diagram of a computer system suitable for use in implementing a mobile device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Referring to fig. 1, a main flow chart of an interface request retransmission method provided by an embodiment of the present invention is shown, including the following steps:
S101: a request is sent to a server, a request failure message fed back by the server is received, and a retransmission frequency threshold corresponding to an interface for sending the request is obtained;
S102: determining the current resending times of the request, and if the resending times are smaller than the resending times threshold, acquiring a resending interval time threshold corresponding to the interface;
s103: and determining the retransmission interval time of the request according to the retransmission interval time threshold and the residual retransmission times, so as to perform the retransmission request operation when the retransmission interval time is reached.
In the above embodiment, for step S101, the present invention is mainly applicable to browser-side products, and the request used is mainly an ajax request.
The asynchronous update of the webpage data is realized by mainly using an ajax request at a browser end, namely, only a certain part of the webpage is updated, and the whole webpage is not reloaded; wherein the ajax request specifies a web page development technique for the web page application at the time of creating the interaction.
Whether the ajax request is successful or not depends on the stability of the network and the server, the http state code fed back by the server usually presents different forms such as 2xx, 3xx, 4xx and the like, and a Web front-end developer can display different interface effects according to different http state codes.
For automatic retransmission of ajax requests, the status code of ajax error requests fed back by the server may be compared with the status pool status code to filter interface requests that are retransmitted and not retransmitted:
1) If the status code of the ajax error request is 3xx, 404, 451, 425, 500 or the status code agreed by the developer of the server (namely, the second status code), the retransmission processing is not performed, and the error request result is directly returned and the back-end service logic is triggered and reported;
2) For the remaining status codes (i.e., the first status code except the second status code), e.g., 2xx, etc., the ajax request is a re-writable request.
The http status code is a 3-bit digital code for representing the response status of the hypertext transfer protocol at the web server, and the first digit of all status codes represents one of the five statuses of the response.
The invention sets two parameters of retry and RETRYDELAY for each interface; wherein retry represents the number of retransmissions of registration axios, RETRYDELAY represents the retransmission interval time of registration axios; for example, retry=5, retry=2000.
It should be noted that different retry and RETRYDELAY values may be set for different interfaces, for example, retry for interface 1 is 5 times and retry for interface 2 is 7 times. The interface information is specifically determined in the following manner: and determining the interface type of the interface according to the interface information of the interface, and further acquiring a retransmission frequency threshold and a retransmission interval time threshold corresponding to the interface type.
Axios is an open source library of the ajax technology used by the developer, and the Web front-end developer initiates an ajax request to communicate with the server through the ajax library to complete the data or interface adding and deleting operations. After the retry and RETRYDELAY configuration is performed on the interface, the retry and RETRYDELAY parameters can be globally configured and registered in the axios library, so that the comparison and use of the subsequent retransmission times are facilitated.
For step S102, counting the resending times of the ajax request, judging whether the resending times are more than or equal to retry, if yes, directly returning an error and triggering reporting back-end service logic; otherwise, the subsequent retransmission interval time determining operation is performed.
Further, some interfaces may not have ajax request retransmission settings, so it may first determine whether retry is greater than 0, and for interface requests with retry not 0, when receiving a request failure message, may directly return an error and trigger reporting back-end service logic.
For step S103, it is determined whether the number of times the ajax request has been retransmitted is less than 1:
1) If the retransmission time is smaller than 1, the ajax request is the first retransmission, and the retransmission interval time threshold corresponding to the interface is used as the retransmission time interval of the ajax request, for example, a retransmission operation is performed at intervals of 2 seconds;
2) If the time is greater than or equal to 1, the ajax request is not retransmitted for the first time, and the RETRYDELAY time is required to be updated, specifically, the time is converted according to the following calculation formula:
RETRYDELAY = RETRYDELAY/number of retransmissions remaining; where the number of retransmissions remaining = replay-the number of retransmissions already.
Let the interface set retransmission rules retry=5, RETRYDELAY =2000. The first retransmission will trigger after an interval of 2 seconds, the second will be retransmitted after 500 milliseconds, the third will be retransmitted after 667 milliseconds, the fourth will be retransmitted after 1 second, and the fifth will be retransmitted after 2 seconds. And when the retransmission interval time is reached, ajax requests retransmission.
According to the method provided by the embodiment, two parameters of retransmission times and retransmission interval time are set for an interface, so that the ajax requests for automatic retransmission without manual operation; in addition, the time adjustment can be carried out on the retransmission interval time with the retransmission times more than 1 time according to the updating strategy, so that the flexibility of requesting retransmission is realized, and the condition that the server receives excessive request quantity at the same time is avoided.
Referring to fig. 2, a flowchart of a specific interface request retransmission method according to an embodiment of the present invention is shown, including the following steps:
s201: sending an ajax request from an interface to a server;
s202: receiving an ajax error request fed back by a server;
s203: acquiring a status code in the ajax error request;
S204: if the status code is the first status code, determining that the ajax request is a re-transmissible request;
S205: if the state code is the second state code, determining that the ajax request is a retransmission-impossible request, not performing retransmission processing, and reporting back-end service;
s206: acquiring a retransmission frequency threshold of the interface, and judging whether the retransmission frequency of the ajax request is smaller than the retransmission frequency threshold;
S207: if the retransmission interval time threshold value is smaller than the retransmission interval time threshold value corresponding to the interface is acquired;
S208: if the service request is greater than or equal to the service request, not performing retransmission processing and reporting back-end service;
s209: if the number of times of retransmission is zero, determining that the current ajax request is the first retransmission, and taking a retransmission interval time threshold value as the retransmission interval time of the current ajax request; or (b)
S210: if the number of times of retransmission is greater than zero, determining that the current request for ajax is non-first retransmission, calculating the ratio of the retransmission interval time threshold value to the remaining number of times of retransmission, and taking the ratio as the retransmission interval time of the current request for ajax;
S211: and when the retransmission interval time is reached, performing ajax request retransmission operation.
Compared with the prior art, the method provided by the embodiment of the invention has at least the following beneficial effects:
1) Analyzing which requests are suitable for retransmission according to an http state code filtering strategy, so as to realize ajax request filtering;
2) According to the data content provided by the interface, registering two parameters of ajax retransmission times (retry) and retransmission interval time (RETRYDELAY) in the code, so as to realize automatic retransmission of ajax requests and improve the success rate of ajax requests;
3) For the case that the retransmission times are not 1, adaptively increasing the retransmission interval time of the ajax request by triggering a time changing strategy, so as to reduce the service pressure of the server;
4) For the ajax request which fails to be retransmitted or cannot be retransmitted, the retransmission times and time consumption of the interface can be collected and the reporting back-end server processing is uniformly carried out, so that a basis is provided for the subsequent operation and maintenance personnel to judge the availability of the interface in different time periods and optimize the interface/server.
Referring to fig. 3, a schematic diagram of main modules of an interface request retransmission apparatus 300 according to an embodiment of the present invention is shown, including:
the information receiving module 301 is configured to send a request to a server, receive a request failure message fed back by the server, and obtain a retransmission frequency threshold corresponding to an interface for sending the request;
a number comparison module 302, configured to obtain a retransmission interval time threshold corresponding to the interface if the number of times of retransmission of the request is smaller than the retransmission number threshold;
A request retransmission module 303, configured to determine a retransmission interval time of the request according to the retransmission interval time threshold and the remaining number of retransmissions, so as to perform a request retransmission operation when the retransmission interval time is reached.
In the embodiment of the present invention, the information receiving module 301 is further configured to:
And acquiring the status code in the request failure message, and if the status code is the first status code, determining that the request is a re-transmissible request.
In the embodiment of the present invention, the information receiving module 301 is configured to:
determining the interface type of the interface according to the interface information of the interface, and acquiring a retransmission time threshold and a retransmission interval time threshold corresponding to the interface type; and
And registering the retransmission times threshold and the retransmission interval time threshold in a database corresponding to the interface to obtain a configuration item of the interface.
In the embodiment of the present invention, the request resending module 303 is configured to:
If the number of times of retransmission is zero, determining that the request is retransmitted for the first time, and taking the retransmission interval time threshold value as the retransmission interval time of the request; or (b)
If the number of times of retransmission is greater than zero, determining that the request is not first retransmitted, calculating the ratio of the retransmission interval time threshold value to the remaining number of times of retransmission, and taking the ratio as the retransmission interval time of the request.
The implementation device of the present invention further includes an exception reporting module 304 (not shown in the figure) configured to:
acquiring a status code in the request failure message, and if the status code is a second status code, determining that the request is a non-resendable request; and
And counting the number of request failures received in the preset time, and triggering abnormal reporting operation of the interface if the number of request failures is greater than or equal to a preset request failure number threshold.
In addition, the implementation of the apparatus in the embodiments of the present invention has been described in detail in the above method, so that the description is not repeated here.
Fig. 4 illustrates an exemplary system architecture 400 in which embodiments of the present invention may be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405 (by way of example only). The network 404 is used as a medium to provide communication links between the terminal devices 401, 402, 403 and the server 405. The network 404 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 405 via the network 404 using the terminal devices 401, 402, 403 to receive or send messages or the like. Various communication client applications can be installed on the terminal devices 401, 402, 403.
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 405 may be a server providing various services, such as a background management server (by way of example only) providing support for shopping-type websites browsed by users using the terminal devices 401, 402, 403.
It should be noted that the method provided by the embodiment of the present invention is generally performed by the server 405, and accordingly, the apparatus is generally disposed in the server 405.
It should be understood that the number of terminal devices, networks and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, there is illustrated a schematic diagram of a computer system 500 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 5 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input section 506 including a keyboard, a mouse, and the like; an output portion 507 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker, and the like; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The drive 510 is also connected to the I/O interface 505 as needed. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as needed so that a computer program read therefrom is mounted into the storage section 508 as needed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 509, and/or installed from the removable media 511. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 501.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: a processor comprises an information receiving module, a frequency comparison module and a request retransmission module. The names of these modules do not constitute limitations on the module itself in some cases, and for example, the information receiving module may also be described as a "reception request failure message module".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include:
A request is sent to a server, a request failure message fed back by the server is received, and a retransmission frequency threshold corresponding to an interface for sending the request is obtained;
the current retransmission times of the request are smaller than the retransmission times threshold, and a retransmission interval time threshold corresponding to the interface is obtained;
and determining the retransmission interval time of the request according to the retransmission interval time threshold and the residual retransmission times, so as to perform the retransmission request operation when the retransmission interval time is reached.
According to the technical scheme provided by the embodiment of the invention, compared with the prior art, the method has at least the following beneficial effects:
1) Analyzing which requests are suitable for retransmission according to an http state code filtering strategy, so as to realize ajax request filtering;
2) According to the data content provided by the interface, registering two parameters of ajax retransmission times (retry) and retransmission interval time (RETRYDELAY) in the code, so as to realize automatic retransmission of ajax requests and improve the success rate of ajax requests;
3) For the case that the retransmission times are not 1, adaptively increasing the retransmission interval time of the ajax request by triggering a time changing strategy, so as to reduce the service pressure of the server;
4) And for the ajax request which fails to be retransmitted or cannot be retransmitted, reporting back-end server processing can be uniformly performed, and a basis is provided for subsequent operation and maintenance personnel to judge the availability of the interface in different time periods and optimize the interface/server.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.
Claims (8)
1. An interface request retransmission method, comprising:
A request is sent to a server, a request failure message fed back by the server is received, and a retransmission frequency threshold corresponding to an interface for sending the request is obtained;
Determining the current resending times of the request, and if the resending times are smaller than the resending times threshold, acquiring a resending interval time threshold corresponding to the interface;
Determining the retransmission interval time of the request based on the retransmission interval time threshold and the residual retransmission times, so as to perform the retransmission request operation when the retransmission interval time is reached; if the number of times of retransmission is greater than zero, determining that the request is not first retransmitted, calculating the ratio of the retransmission interval time threshold to the remaining number of times of retransmission, and taking the ratio as the retransmission interval time of the request.
2. The method of claim 1, wherein after the receiving the request failure message fed back by the server, before the obtaining the threshold number of retransmissions corresponding to the interface, further comprises:
And acquiring the status code in the request failure message, and if the status code is the first status code, determining that the request is a re-transmissible request.
3. The method of claim 1, further comprising, prior to said obtaining a threshold number of retransmissions corresponding to said interface:
determining the interface type of the interface according to the interface information of the interface, and acquiring a retransmission time threshold and a retransmission interval time threshold corresponding to the interface type; and
And registering the retransmission times threshold and the retransmission interval time threshold in a database corresponding to the interface to obtain a configuration item of the interface.
4. A method according to any one of claims 1-3, wherein said determining the retransmission interval time for the current request based on the retransmission interval time threshold and the number of remaining retransmissions further comprises:
and if the number of times of retransmission is zero, determining that the request is retransmitted for the first time, and taking the retransmission interval time threshold value as the retransmission interval time of the request.
5. The method of claim 1, further comprising, after the receiving the request failure message fed back by the server,:
acquiring a status code in the request failure message, and if the status code is a second status code, determining that the request is a non-resendable request; and
And counting the number of request failures received in the preset time, and triggering abnormal reporting operation of the interface if the number of request failures is greater than or equal to a preset request failure number threshold.
6. An interface request retransmission apparatus, comprising:
The information receiving module is used for sending a request to the server, receiving a request failure message fed back by the server and acquiring a retransmission frequency threshold corresponding to an interface for sending the request;
The number comparison module is used for obtaining a retransmission interval time threshold corresponding to the interface if the number of times of retransmission of the request is smaller than the retransmission number threshold;
A request retransmission module, configured to determine a retransmission interval time of the request according to the retransmission interval time threshold and the remaining number of retransmissions, so as to perform a request retransmission operation when the retransmission interval time is reached; if the number of times of retransmission is greater than zero, determining that the request is not first retransmitted, calculating the ratio of the retransmission interval time threshold to the remaining number of times of retransmission, and taking the ratio as the retransmission interval time of the request.
7. An electronic device, comprising:
One or more processors;
Storage means for storing one or more programs,
When executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-5.
8. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911229042.1A CN112905930B (en) | 2019-12-04 | 2019-12-04 | Interface request retransmission method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911229042.1A CN112905930B (en) | 2019-12-04 | 2019-12-04 | Interface request retransmission method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112905930A CN112905930A (en) | 2021-06-04 |
CN112905930B true CN112905930B (en) | 2024-09-20 |
Family
ID=76111053
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911229042.1A Active CN112905930B (en) | 2019-12-04 | 2019-12-04 | Interface request retransmission method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112905930B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113656473A (en) * | 2021-07-30 | 2021-11-16 | 平安消费金融有限公司 | Interface access method, device, equipment and medium |
CN114244479A (en) * | 2021-12-20 | 2022-03-25 | 北京奕斯伟计算技术有限公司 | Data transmission method, data transmission device, electronic device and storage medium |
CN115225976A (en) * | 2022-06-16 | 2022-10-21 | 海南乾唐视联信息技术有限公司 | Data retransmission method, device, terminal equipment and storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104936156A (en) * | 2015-06-25 | 2015-09-23 | 走遍世界(北京)信息技术有限公司 | Short message sending method and device |
CN108880994A (en) * | 2018-07-02 | 2018-11-23 | 网宿科技股份有限公司 | A kind of method and apparatus for retransmitting mail |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6717915B1 (en) * | 1998-07-10 | 2004-04-06 | Openwave Systems, Inc. | Method and apparatus for dynamically configuring timing parameters for wireless data devices |
JP2008141633A (en) * | 2006-12-05 | 2008-06-19 | Sony Corp | Data communication system, data-receiving apparatus and method, and data transmitting apparatus and method |
JP2010199751A (en) * | 2009-02-23 | 2010-09-09 | Sony Corp | Communication system, communication apparatus, and packet length control method |
JP2011049852A (en) * | 2009-08-27 | 2011-03-10 | Ricoh Co Ltd | Image processing apparatus, data retransmission method, and data retransmission program |
JP4888571B2 (en) * | 2010-01-18 | 2012-02-29 | 富士通株式会社 | Reception device, reception method, wireless communication system, and communication method |
CN105824752B (en) * | 2016-03-16 | 2018-09-14 | 北京齐尔布莱特科技有限公司 | A kind of automatic interface testing method, device and computing device |
-
2019
- 2019-12-04 CN CN201911229042.1A patent/CN112905930B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104936156A (en) * | 2015-06-25 | 2015-09-23 | 走遍世界(北京)信息技术有限公司 | Short message sending method and device |
CN108880994A (en) * | 2018-07-02 | 2018-11-23 | 网宿科技股份有限公司 | A kind of method and apparatus for retransmitting mail |
Also Published As
Publication number | Publication date |
---|---|
CN112905930A (en) | 2021-06-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112905930B (en) | Interface request retransmission method and device | |
CN113760982B (en) | Data processing method and device | |
CN113360815B (en) | Request retry method and device | |
CN110620681B (en) | Network connection timeout time setting method, device, equipment and medium | |
CN111800223B (en) | Method, device and system for generating sending message and processing receiving message | |
CN110324384B (en) | Data pushing method and device | |
CN113761565B (en) | Data desensitization method and device | |
US10931791B2 (en) | Method and apparatus for processing request | |
CN110071952B (en) | Service call quantity control method and device | |
CN112784139B (en) | Query method, device, electronic equipment and computer readable medium | |
CN111787041A (en) | Method and apparatus for processing data | |
US10097613B2 (en) | Systems and methods for enhancing performance of resource state polling | |
CN111950232B (en) | Method and device for automatically switching number segments | |
CN110738509B (en) | Method and device for quantifying association degree between users | |
CN109087097B (en) | Method and device for updating same identifier of chain code | |
CN113778504B (en) | Publishing method, publishing system and routing device | |
CN112306791B (en) | Performance monitoring method and device | |
CN113726885B (en) | Flow quota adjusting method and device | |
CN113760487B (en) | Service processing method and device | |
CN114125066B (en) | Method and device for processing service request | |
CN114253520B (en) | Interface code generation method and device | |
CN110909269B (en) | Log reporting method and device | |
CN110888770B (en) | Method and device for transmitting information | |
CN113722193A (en) | Method and device for detecting page abnormity | |
CN112988408B (en) | Multi-terminal interaction method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |