File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11const axios = require ( 'axios' ) ;
22const querystring = require ( 'querystring' ) ;
3+ const axiosRetry = require ( 'axios-retry' ) ;
34
45const TranscodingTask = require ( './Classes/TranscodingTask' ) ;
56
7+ // Set the retry logic
8+ axiosRetry ( axios , {
9+ retries : 20 ,
10+ retryDelay : ( retryCount ) => {
11+ return 3000 ; // time interval between retries
12+ } ,
13+ // retry on Network Error and 5xx responses
14+ retryCondition : ( error ) => {
15+ return axiosRetry . isNetworkOrIdempotentRequestError ( error ) || error . code === 'ECONNABORTED' ;
16+ } ,
17+ } ) ;
18+
619class QencodeApiClient {
720 constructor ( options ) {
821
@@ -103,24 +116,22 @@ class QencodeApiClient {
103116 // convert parameters to string like 'api_key=5adb0584aa29f'
104117 parameters = querystring . stringify ( parameters ) ;
105118 }
106-
119+
107120 try {
108-
109121 this . lastResponseRaw = await axios . post (
110122 requestUrl ,
111123 parameters ,
112124 {
113125 headers : {
114126 'Content-Type' : 'application/x-www-form-urlencoded'
115- }
127+ } ,
128+ timeout : this . ConnectTimeout * 1000
116129 }
117130
118131 ) ;
119-
120-
121132 } catch ( err ) {
122133 throw new Error ( "Error executing request to url: " + requestUrl , err ) ;
123- }
134+ }
124135
125136 let response = this . lastResponseRaw . data ;
126137
Original file line number Diff line number Diff line change 2626 "bundleDependencies" : [],
2727 "dependencies" : {
2828 "axios" : " ^1.2.1" ,
29+ "axios-retry" : " ^3.5.1" ,
2930 "querystring" : " ^0.2.1"
3031 },
3132 "deprecated" : false ,
You can’t perform that action at this time.
0 commit comments