Node-ytdl-core: Error: Too many redirects (from miniget used by ytdl-core)

Created on 28 Aug 2017  路  31Comments  路  Source: fent/node-ytdl-core

2|Senpai   | Error: Too many redirects
2|Senpai   |     at ClientRequest.<anonymous> (/root/Senpai-Bot/Senpai-Bot-Discord/node_modules/miniget/lib/index.js:59:19)
2|Senpai   |     at Object.onceWrapper (events.js:316:30)
2|Senpai   |     at emitOne (events.js:115:13)
2|Senpai   |     at ClientRequest.emit (events.js:210:7)
2|Senpai   |     at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:565:21)
2|Senpai   |     at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23)
2|Senpai   |     at TLSSocket.socketOnData (_http_client.js:454:20)
2|Senpai   |     at emitOne (events.js:115:13)
2|Senpai   |     at TLSSocket.emit (events.js:210:7)
2|Senpai   |     at addChunk (_stream_readable.js:266:12)
2|Senpai   |     at readableAddChunk (_stream_readable.js:253:11)
2|Senpai   |     at TLSSocket.Readable.push (_stream_readable.js:211:10)
2|Senpai   |     at TLSWrap.onread (net.js:585:20)

i get this error often in the last time and im not quit sure how to handle properly since i cant catch it property (seems to be thrown in the miniget lib or smth) and maybe you could tell me if its an network issue or something like that

bug

Most helpful comment

Yeah that's how you ask open source software developers who do this as a hobby in their free time to fix something! Insult them! That seems like a great idea!

All 31 comments

Looks similar to the error from #187, but that one is too many reconnects. So possibly, this is a separate issue.

Do you have an example video where this happens?

oh not at the moment, i will try to get one ASAP to help you investigate the issue :)

I got the same while testing, and it appears that if the video does not exist, this happens:
Error: Too many redirects at ClientRequest.<anonymous> (/home/juusolain/CordBot/node_modules/miniget/lib/index.js:59:19) at Object.onceWrapper (events.js:316:30) at emitOne (events.js:115:13) at ClientRequest.emit (events.js:210:7) at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:565:21) at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23) at TLSSocket.socketOnData (_http_client.js:454:20) at emitOne (events.js:115:13) at TLSSocket.emit (events.js:210:7) at addChunk (_stream_readable.js:266:12)
This is probably the same thing

oh yea that would make sense since you get redirected if the video was claimed/deleted if i remember correct

Ahh it's happening still @fent pls fix kthx <3

Yep, still happening sometimes.

Are there any videos where this consistently happens?

My unit tests are now failing with this: https://www.youtube.com/watch?v=oVXg7Grp1W8

But I can override them with an environment variable and this worked: https://www.youtube.com/watch?v=OLxY0HDakRk

It is happening with this video: https://www.youtube.com/watch?v=PimVw0LomLs

Ok I'm able to replicate with itag 22 of this. Will investigate.

Using ytb2mp3:
ytb2mp3/ytb2mp3#2

This is using an outdated version of ytdl-core btw. You can see in the package-lock.json file. The error still happens with the video above, but you should always be using the latest version or you might run into other errors.

Going to keep this opened to remember to investigate video: https://www.youtube.com/watch?v=PimVw0LomLs

Any updates on this?

Been on a break for a while, will get back to it in a few weeks.

This 'Too many redirects' error seems to occur when multiple ytdl calls are being processed at the same time. If i download a single youtube video at a time i never get this, only when i download multiple videos without letting the previous one finish.

@ShawnAndrews I have this issue while downloading only one video at the same time

yo wtf fix this shit already

Yeah that's how you ask open source software developers who do this as a hobby in their free time to fix something! Insult them! That seems like a great idea!

Any updates on this?

I found out if you requeue the same video and it will actually play, so maybe you can fix it by making it retry on this error

Curious if people here are using proxies or not.
It only happens for me when I'm using a proxy.

Curious if people here are using proxies or not.
It only happens for me when I'm using a proxy.

And how you fix it with proxy?

@mh4ck I didn't.
Had I had the time I would fork ytdl to use request module instead of miniget, it is by far more robust.

we tried to stay away from request since it's a heavyweight at more then 200x the size of miniget

And apparently Request is also "unmaintained" now. I highly recommend Got as an alternative.

Error: input stream: Too many redirects
at ClientRequest. (/location_dont_matter/node_modules/ytdl-core/node_modules/miniget/dist/index.js:129:42)
at Object.onceWrapper (events.js:417:26)
at ClientRequest.emit (events.js:310:20)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:596:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
at HTTPParser.execute ()
at TLSSocket.socketOnData (_http_client.js:469:22)
at TLSSocket.emit (events.js:310:20)
at addChunk (_stream_readable.js:286:12)
at readableAddChunk (_stream_readable.js:268:9)

I m also facing same error anyone have fix this issue?

status update on this issue, I'm unable to download the following video

https://www.youtube.com/watch?v=PimVw0LomLs

however, this time there's no error, the download starts, only downloading around 500kb, then stalls

this problem might be caused by the command !serverQueue, try changing the volume to 5 maybe that could help i guess

I had this issue and then it got solved when I went to node_modules>miniget>dist>index.js and changed the value of maxRedirects on line 13 to a very big number or a number u see fit to change it. This worked for me. I never got this error again. It should say maxRedirects: {number}. The default value was set at 3 for me.
(Edited) I just changed it to a big number and it worked perfectly but feel free to change it to any number.
Try this out!

To implement the above suggestion by @Anastis without changing the miniget code (which will get overridden w/ npm updates), add the following to your ytdl options: requestOptions: { maxRedirects: 10 }. Change maxRedirects to any number you see fit, I haven't tested this much, although I wouldn't suggest making it too big as redirect loops do signal a broken page and will slow down both your client and YouTube. HTTP spec set the standard at 5 (RFC 2616 section 10.3), which Chrome/Firefox and probably others follow, more than miniget's 2 default but still not "a very big number."

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jan-tennert picture jan-tennert  路  6Comments

r0hin picture r0hin  路  3Comments

MidSpike picture MidSpike  路  4Comments

Asaduji picture Asaduji  路  6Comments

HcgRandon picture HcgRandon  路  5Comments