I have latest ytdl-core
`events.js:287
throw er; // Unhandled 'error' event
^
Error: Status code: 416
at ClientRequest.
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 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)
at TLSSocket.Readable.push (_stream_readable.js:209:10)
Emitted 'error' event on PassThrough instance at:
at PassThrough.
at PassThrough.emit (events.js:310:20)
at ClientRequest.
at Object.onceWrapper (events.js:417:26)
[... lines matching original stack trace ...]
at addChunk (_stream_readable.js:286:12)
[nodemon] app crashed - waiting for file changes before starting...`
I've seen this a few times. but have yet to be able to consistently get it myself.
I've noticed fiddling with the highWaterMark value can prevent it for me, though it causes other issues.
I've noticed fiddling with the highWaterMark value can prevent it for me, though it causes other issues.
Yeah using lower highWaterMark values causes 416 for me but using higher values prevents it. I haven't seen any 416 after increasing it.
if you're passing a range option to the download, make sure that the range is valid, because if not YouTube will return this error.
(416 => Range Not Satisfiable)
tried with a 1024kb highWaterMark, but I still have the issue
with a 8min long video, it stops around 6min with the 416 error
still with 1024kb, every videos with a length above 5-6 mins drop around 1 or 2 minutes before the end
I'm making a music discord bot, and this is a very annoying issue. I'm having it with about half of all the songs I play. The music jumps around, and then throws this error. This is my code.
let dispatcher = connection.play(ytdl(url, {filter: "audioonly"}));
What I'm reading here, is that this is a range issue, but I'm not using any custom range, so ytdl-core does this by itself. Is there maybe a way that I can force it to use a lower range, so my music bot just stays working?
Edit: I went as far back as version 2.1.5, and even on this version, I get the same kind of error, but I get it not as often.
Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27) {
errno: 'ECONNRESET',
code: 'ECONNRESET',
syscall: 'read'
}
Second edit: I was thinking, there can only be two reasons, because I never had problems before, and I even tried the same version.
- The issue is with a dependency of ytdl-core
ytdl-core uses miniget to download videos. it has a feature for retrying to download a video with a ranged request if the connection drops halfway. I'm guessing the error lies somewhere around there.
I had a similar issue. My problem was that i close the writestream, to which i pipe the download, in the 'finish' event. Maybe it could help someone.
And i'm using 8mb highwaterMark and got problems till now.
for those that keep getting this error, can you log the requests miniget makes? just add a console.log(url) at the start of doDownload in node_modules/miniget/dist/index.js
for those that get the error, do you know what formats it happens on?
another thing you can try, there was recently a change that chunks downloads for certain formats, you can try enabling that for all formats and see if you still get the error. to enable it, change this line to
const shouldBeChunked = true;
Hi, I have exactly the same problem :
I put the "console.log(url)" as you asked for :

Then I played a 5:40 youtube song with this link : https://www.youtube.com/watch?v=zUwEIt9ez7M
The first log output is :
https://www.youtube.com/watch?v=zUwEIt9ez7M&hl=en&bpctr=1598565478&pbj=1
https://www.youtube.com/s/player/eecb0f1e/player_ias.vflset/en_US/base.js
https://r3---sn-nfpnnjvh-b85e.googlevideo.com/videoplayback?expire=1598587059&ei=UyxIX4r8HY6A8gOj0r3ACg&ip=92.106.193.200&id=o-APDS4GKPPh5Iqh1LNeJCdOZDuxOiZeD8clyK4qc2fD_g&itag=251&source=youtube&requiressl=yes&mh=vI&mm=31%2C29&mn=sn-nfpnnjvh-b85e%2Csn-1gieen7e&ms=au%2Crdu&mv=m&mvi=3&pl=22&initcwndbps=2431250&vprv=1&mime=audio%2Fwebm&gir=yes&clen=5460482&dur=340.861&lmt=1593714887331490&mt=1598565282&fvip=3&keepalive=yes&c=WEB&txp=5511222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgZ0WUcA3ERgGKtCyiCggwWJGZWJxd-fP3riAD2un2y3wCIQCrAMeBU2sgLphyGqL_8Ff14-tJsOmqQoeJBYVKYeMl0w%3D%3D&ratebypass=yes&sig=AOq0QJ8wRgIhAPUYXcmH8ERAkzCIkEBMhY7ALNv04WvyLp8Rm0QN3kbzAiEAoS2fZTNeEfEp7q3K6voxwWxJFUE9O8szT9fP-HtS7zo%3D
After some time the console output that with the crash at the end :
https://r3---sn-nfpnnjvh-b85e.googlevideo.com/videoplayback?expire=1598587059&ei=UyxIX4r8HY6A8gOj0r3ACg&ip=92.106.193.200&id=o-APDS4GKPPh5Iqh1LNeJCdOZDuxOiZeD8clyK4qc2fD_g&itag=251&source=youtube&requiressl=yes&mh=vI&mm=31%2C29&mn=sn-nfpnnjvh-b85e%2Csn-1gieen7e&ms=au%2Crdu&mv=m&mvi=3&pl=22&initcwndbps=2431250&vprv=1&mime=audio%2Fwebm&gir=yes&clen=5460482&dur=340.861&lmt=1593714887331490&mt=1598565282&fvip=3&keepalive=yes&c=WEB&txp=5511222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgZ0WUcA3ERgGKtCyiCggwWJGZWJxd-fP3riAD2un2y3wCIQCrAMeBU2sgLphyGqL_8Ff14-tJsOmqQoeJBYVKYeMl0w%3D%3D&ratebypass=yes&sig=AOq0QJ8wRgIhAPUYXcmH8ERAkzCIkEBMhY7ALNv04WvyLp8Rm0QN3kbzAiEAoS2fZTNeEfEp7q3K6voxwWxJFUE9O8szT9fP-HtS7zo%3D
https://r3---sn-nfpnnjvh-b85e.googlevideo.com/videoplayback?expire=1598587059&ei=UyxIX4r8HY6A8gOj0r3ACg&ip=92.106.193.200&id=o-APDS4GKPPh5Iqh1LNeJCdOZDuxOiZeD8clyK4qc2fD_g&itag=251&source=youtube&requiressl=yes&mh=vI&mm=31%2C29&mn=sn-nfpnnjvh-b85e%2Csn-1gieen7e&ms=au%2Crdu&mv=m&mvi=3&pl=22&initcwndbps=2431250&vprv=1&mime=audio%2Fwebm&gir=yes&clen=5460482&dur=340.861&lmt=1593714887331490&mt=1598565282&fvip=3&keepalive=yes&c=WEB&txp=5511222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgZ0WUcA3ERgGKtCyiCggwWJGZWJxd-fP3riAD2un2y3wCIQCrAMeBU2sgLphyGqL_8Ff14-tJsOmqQoeJBYVKYeMl0w%3D%3D&ratebypass=yes&sig=AOq0QJ8wRgIhAPUYXcmH8ERAkzCIkEBMhY7ALNv04WvyLp8Rm0QN3kbzAiEAoS2fZTNeEfEp7q3K6voxwWxJFUE9O8szT9fP-HtS7zo%3D
https://r3---sn-nfpnnjvh-b85e.googlevideo.com/videoplayback?expire=1598587059&ei=UyxIX4r8HY6A8gOj0r3ACg&ip=92.106.193.200&id=o-APDS4GKPPh5Iqh1LNeJCdOZDuxOiZeD8clyK4qc2fD_g&itag=251&source=youtube&requiressl=yes&mh=vI&mm=31%2C29&mn=sn-nfpnnjvh-b85e%2Csn-1gieen7e&ms=au%2Crdu&mv=m&mvi=3&pl=22&initcwndbps=2431250&vprv=1&mime=audio%2Fwebm&gir=yes&clen=5460482&dur=340.861&lmt=1593714887331490&mt=1598565282&fvip=3&keepalive=yes&c=WEB&txp=5511222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgZ0WUcA3ERgGKtCyiCggwWJGZWJxd-fP3riAD2un2y3wCIQCrAMeBU2sgLphyGqL_8Ff14-tJsOmqQoeJBYVKYeMl0w%3D%3D&ratebypass=yes&sig=AOq0QJ8wRgIhAPUYXcmH8ERAkzCIkEBMhY7ALNv04WvyLp8Rm0QN3kbzAiEAoS2fZTNeEfEp7q3K6voxwWxJFUE9O8szT9fP-HtS7zo%3D
https://r3---sn-nfpnnjvh-b85e.googlevideo.com/videoplayback?expire=1598587059&ei=UyxIX4r8HY6A8gOj0r3ACg&ip=92.106.193.200&id=o-APDS4GKPPh5Iqh1LNeJCdOZDuxOiZeD8clyK4qc2fD_g&itag=251&source=youtube&requiressl=yes&mh=vI&mm=31%2C29&mn=sn-nfpnnjvh-b85e%2Csn-1gieen7e&ms=au%2Crdu&mv=m&mvi=3&pl=22&initcwndbps=2431250&vprv=1&mime=audio%2Fwebm&gir=yes&clen=5460482&dur=340.861&lmt=1593714887331490&mt=1598565282&fvip=3&keepalive=yes&c=WEB&txp=5511222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgZ0WUcA3ERgGKtCyiCggwWJGZWJxd-fP3riAD2un2y3wCIQCrAMeBU2sgLphyGqL_8Ff14-tJsOmqQoeJBYVKYeMl0w%3D%3D&ratebypass=yes&sig=AOq0QJ8wRgIhAPUYXcmH8ERAkzCIkEBMhY7ALNv04WvyLp8Rm0QN3kbzAiEAoS2fZTNeEfEp7q3K6voxwWxJFUE9O8szT9fP-HtS7zo%3D
events.js:292
throw er; // Unhandled 'error' event
^
Error: Status code: 416
at ClientRequest.<anonymous> (C:\Users\guill\Desktop\Creation\discord\GaspardSavoureuxBot\node_modules\miniget\dist\index.js:158:27)
at Object.onceWrapper (events.js:422:26)
at ClientRequest.emit (events.js:315:20)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:596:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
at TLSSocket.socketOnData (_http_client.js:469:22)
at TLSSocket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at TLSSocket.Readable.push (_stream_readable.js:212:10)
Emitted 'error' event on PassThrough instance at:
at errorOrDestroy (internal/streams/destroy.js:108:12)
at PassThrough.onerror (_stream_readable.js:752:7)
at PassThrough.emit (events.js:315:20)
at PassThrough.<anonymous> (C:\Users\guill\Desktop\Creation\discord\GaspardSavoureuxBot\node_modules\ytdl-core\lib\index.js:96:16)
at PassThrough.emit (events.js:315:20)
at ClientRequest.<anonymous> (C:\Users\guill\Desktop\Creation\discord\GaspardSavoureuxBot\node_modules\miniget\dist\index.js:163:28)
at Object.onceWrapper (events.js:422:26)
[... lines matching original stack trace ...]
at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
The "const shouldBeChunked = true;" line doesn't fix the problem.
Hey, there!
I had the same issue, but, somehow I commented out like 3 lines of code in Miniget, and now looks like it's working. I think this retry/reconnect thingy is failing behind the scenes.
const onRequestError = (err, statusCode) => {
// if (!retryRequest({ err, statusCode })) {
// stream.emit('error', err);
// }
};
Also having a problem with this.
I had the same error with some other streams using the package ytdl-core on a single voice channel. Now I'm using broadcasters and playing streams with ytdl-core-discord. Before I was able to catch the error by attaching the listener to the ytdl stream object.
Now I am adding an error listener onto the stream object attached to the broadcasters -the same one that is attached a working finish listener- and it isn't even catching. It just logs that there is an uncaught 416.
async function createNewStream(Broadcast, PlaylistName, track, play_next_track, debug_track) {
console.log("NOW PLAYING: ", PlaylistName)
console.log(track)
stream = await ytdl(track.url, request_options)
broadcast = Broadcast.play(stream, dispatcher_settings)
StreamData = {
track,
Broadcast,
PlaylistName
}
stream._StreamData = StreamData
stream._play_next_track = play_next_track
stream._debug_track = debug_track
Streams.set(PlaylistName, stream)
Streams.addFinishListener(stream)
Streams.addErrorListener(stream)
return StreamData;
}
Streams.addFinishListener = function (stream) {
stream.on('finish', () => {
stream._play_next_track(stream)
})
}
Streams.addErrorListener = function (stream) {
stream.on('error', () => {
stream._debug_track(stream)
})
}
events.js:292
throw er; // Unhandled 'error' event
^
Error: Status code: 416
at ClientRequest.<anonymous> (C:\Users\jayca\Documents\Code\MyNextDiscordBot\node_modules\miniget\dist\index.js:147:27)
at Object.onceWrapper (events.js:422:26)
at ClientRequest.emit (events.js:315:20)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:596:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
at TLSSocket.socketOnData (_http_client.js:469:22)
at TLSSocket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at TLSSocket.Readable.push (_stream_readable.js:212:10)
Emitted 'error' event on PassThrough instance at:
at errorOrDestroy (internal/streams/destroy.js:108:12)
at PassThrough.onerror (_stream_readable.js:752:7)
at PassThrough.emit (events.js:315:20)
at PassThrough.<anonymous> (C:\Users\jayca\Documents\Code\MyNextDiscordBot\node_modules\ytdl-core\lib\index.js:143:14)
at PassThrough.emit (events.js:315:20)
at ClientRequest.<anonymous> (C:\Users\jayca\Documents\Code\MyNextDiscordBot\node_modules\miniget\dist\index.js:152:28)
at Object.onceWrapper (events.js:422:26)
[... lines matching original stack trace ...]
at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
I just manually told the stream to emit an error and nothing happend at all.
edit: Yep, I switched from ytdl-core-discord back to ytdl-core and it emitted an error when it was supposed to.
same error
Error: Status code: 429
at ClientRequest.<anonymous> (/home/container/node_modules/ytdl-core/node_modules/miniget/dist/index.js:150:31)
at Object.onceWrapper (events.js:421:26)
at ClientRequest.emit (events.js:314:20)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:640:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
at TLSSocket.socketOnData (_http_client.js:509:22)
at TLSSocket.emit (events.js:314:20)
at addChunk (_stream_readable.js:303:12)
at readableAddChunk (_stream_readable.js:279:9)
at TLSSocket.Readable.push (_stream_readable.js:218:10)
I have the same error
Error: Status code: 416
at ClientRequest.<anonymous> (/home/mikael/www/aziris/node_modules/miniget/src/index.ts:180:19)
at Object.onceWrapper (events.js:422:26)
at ClientRequest.emit (events.js:315:20)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:596:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
at TLSSocket.socketOnData (_http_client.js:469:22)
at TLSSocket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at TLSSocket.Readable.push (_stream_readable.js:212:10)
Emitted 'error' event on PassThrough instance at:
at errorOrDestroy (internal/streams/destroy.js:108:12)
at PassThrough.onerror (_stream_readable.js:753:7)
at PassThrough.emit (events.js:315:20)
at PassThrough.<anonymous> (/home/mikael/www/aziris/node_modules/ytdl-core/lib/index.js:96:16)
at PassThrough.emit (events.js:327:22)
at ClientRequest.<anonymous> (/home/mikael/www/aziris/node_modules/miniget/src/index.ts:184:18)
at Object.onceWrapper (events.js:422:26)
[... lines matching original stack trace ...]
at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
I think everyone knows that there is an issue and that it affects many people. Should we create an issue at miniget or is this something ytdl-core needs to fix?
let's keep this open here for now until we figure out the cause
is there another lib that does the same as ytdl?
same issue
Error: Status code: 416
at ClientRequest.<anonymous> (D:\Personal Projects\ytdl-test\node_modules\miniget\dist\index.js:156:27)
at Object.onceWrapper (events.js:422:26)
at ClientRequest.emit (events.js:315:20)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:596:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
at TLSSocket.socketOnData (_http_client.js:469:22)
at TLSSocket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at TLSSocket.Readable.push (_stream_readable.js:212:10)
Emitted 'error' event on PassThrough instance at:
at PassThrough.<anonymous> (D:\Personal Projects\ytdl-test\node_modules\ytdl-core\lib\index.js:96:16)
at PassThrough.emit (events.js:315:20)
at ClientRequest.<anonymous> (D:\Personal Projects\ytdl-test\node_modules\miniget\dist\index.js:161:28)
at Object.onceWrapper (events.js:422:26)
[... lines matching original stack trace ...]
at addChunk (_stream_readable.js:295:12)
i got this error too.

I fixed this problem by using:
ytdl(url, { highWaterMark: 1 << 25 })
I hope this helps.
I fixed this problem by using:
ytdl(url, { highWaterMark: 1 << 25 })I hope this helps.
its not really a (good)fix as it makes resources(dl, ram, cpu) go brrrrr
edit: however for this issue, i will be trying to find the cause soon
Does this mean that the highwatermark is the final fix?
fixed on latest, not due to highWaterMark
fixed on latest, not due to
highWaterMark
Still having this issue. Would like to see a fix, but I'm using highwatermark for now.
Most helpful comment
I fixed this problem by using:
I hope this helps.