Skip to content

Commit

Permalink
perf: adjust reconnect and retry settings
Browse files Browse the repository at this point in the history
  • Loading branch information
fent committed Oct 2, 2019
1 parent 5acf708 commit 02a0c2b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion lib/index.js
Expand Up @@ -96,7 +96,9 @@ const downloadFromInfoCallback = (stream, info, options) => {
format.url += '&begin=' + parseTime.humanStr(options.begin);
}
let requestOptions = Object.assign({}, options.requestOptions, {
maxReconnects: 5
maxReconnects: 6,
maxRetries: 3,
backoff: { inc: 500, max: 10000 },
});
if (options.range && (options.range.start || options.range.end)) {
requestOptions.headers = Object.assign({}, requestOptions.headers, {
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -31,7 +31,7 @@
"dependencies": {
"html-entities": "^1.1.3",
"m3u8stream": "^0.6.2",
"miniget": "^1.5.3",
"miniget": "^1.6.0",
"sax": "^1.1.3"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions test/download-test.js
Expand Up @@ -182,7 +182,7 @@ describe('Download video', () => {
let req, res;
stream.once('request', (a) => { req = a; });
stream.once('response', (a) => { res = a; });
stream.on('reconnect', () => { clock.tick(100); });
stream.on('reconnect', () => { clock.tick(500); });

scope.urlReplyWithFile(format.url, 200, video, {
'content-length': filesize,
Expand Down Expand Up @@ -233,7 +233,7 @@ describe('Download video', () => {
let req, res;
stream.on('request', (a) => { req = a; });
stream.on('response', (a) => { res = a; });
stream.on('reconnect', () => { clock.tick(100); });
stream.on('reconnect', () => { clock.tick(500); });

scope.urlReply(format.url, 206, () => {
return fs.createReadStream(video, { start, end });
Expand Down

0 comments on commit 02a0c2b

Please sign in to comment.