node-ytdl-core
node-ytdl-core copied to clipboard
R [Error]: connect EACCES (my Internet IP):443 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16)
Include the following if your issue is a bug
-
If you're getting a specific error message, include the full stack trace R [Error]: connect EACCES (my Internet IP):443 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16) { resource: T { playStream: OggDemuxer { _readableState: [ReadableState], _events: [Object: null prototype], _eventsCount: 5, _maxListeners: undefined, _writableState: [WritableState], allowHalfOpen: true, _remainder: null, _head: null, _bitstream: null, [Symbol(kCapture)]: false, [Symbol(kCallback)]: [Function: bound onwrite] }, edges: [ [Object], [Object] ], metadata: null, volume: undefined, encoder: undefined, audioPlayer: B { _events: [Object: null prototype], _eventsCount: 2, _maxListeners: undefined, _state: [Object], subscribers: [Array], behaviors: [Object], debug: [Function (anonymous)], [Symbol(kCapture)]: false }, playbackDuration: 132760, started: true, silencePaddingFrames: 5, silenceRemaining: -1 } }
-
If you're getting unexpected behavior without an error message
- What should happen?
- no error
- What happens instead?
- error occured, might cause terminal closed sometimes
-
Include any relevant code around ytdl-core. You don't have to upload your entire program, small snippets are fine.
music_func.js
-
`async next_song(client, args) {
if (client.queue.length) { const next_song_url = client.queue.shift(); const data = await ytdl.getBasicInfo(next_song_url); let video_sec = data.videoDetails.lengthSeconds % 60; let video_sec_str = video_sec.toString().padStart(2, '0'); //console.log(data.videoDetails.title); //console.log(data.videoDetails.lengthSeconds); //console.log(data.videoDetails.thumbnails[3].url); //console.log(data); const output_embed = new MessageEmbed() .setColor('#7C183D') .setTitle(data.videoDetails.title) .setURL(next_song_url) .setAuthor({ name: 'Nowplaying' }) //.setDescription('Nowplaying') .setThumbnail(data.videoDetails.thumbnails[3].url) .addField('Uploader', data.videoDetails.author.name.toString()) .addField('Time', (data.videoDetails.lengthSeconds - video_sec) / 60 + ":" + video_sec_str) //.setImage('attachment://disgust.png') .setTimestamp() //.setFooter('Some footer text here', 'https://i.imgur.com/wSTFkRM.png'); client.last_at_channel.send({ embeds: [output_embed] }).then(msg => { setTimeout(() => msg.delete(), data.videoDetails.lengthSeconds * 1000) }) .catch( /*Your Error handling if the Message isn't returned, sent, etc.*/ );; console.log(next_song_url); client.audio_stream = ytdl(next_song_url, { filter: 'audioonly', liveBuffer: 5000, highWaterMark: 1024, dlChunkSize: 65536 }); client.audio_resauce = createAudioResource(client.audio_stream, { inputType: StreamType.Arbitrary }); client.audio_player.play(client.audio_resauce); if (client.isloop === true) { client.queue.push(next_song_url); } client.audio_resauce.playStream.on('error', error => { console.error('Error:', error.message); }); } else { console.log("queue is empty") }
},`
index.js
- error message is from here I guess
//resauce error handle client.audio_player.on('error', error => { console.error(error); });
full codes here
-
https://github.com/DanielBUBU/PD_maid
-
If this error happens only on some videos, include a link or links to videos.
-
no specific rule to reproduce this, playbackDuration has different values when error occoured
-
I brought this to test in different places (workplace, house, VM in another place) got same error with different IP
I use XAMPP too, Apache https server might use port 443,this might be the problem if the app use the same port, but most of time XAMPP is closed I haven't set port forwarding on my router, so port 443 can't be accessed from Internet
ytdl-core is only doing outgoing requests so it should never bind to restricted ports like 443 in your error... are you sure, this is a ytdl-core error? 'cause i don't think so...
ytdl-core is only doing outgoing requests so it should never bind to restricted ports like 443 in your error... are you sure, this is a ytdl-core error? 'cause i don't think so...
Well, I did some trace to the error, it can be traced to audio resource layer. As far as I know, ytdl doesn't have exception event yet, so my trace stoped here.
Here is part of the code I added to trace and the log
-
music_func.js
client.audio_stream = ytdl(next_song_url, { filter: 'audioonly', liveBuffer: 5000, highWaterMark: 1024, dlChunkSize: 65536 }); client.audio_resauce = createAudioResource(client.audio_stream, { inputType: StreamType.Arbitrary }); client.audio_resauce.playStream.on('error', error => { console.log('ar_err'); console.error('Error:', error.message, 'with track', client.audio_resauce.metadata); });
-
index.js
client.audio_player.on('error', error => { console.log('ap_err'); console.error(error); });
-
console log
ar_err Error: connect EACCES (My Internet IP):443 with track null ap_err R [Error]: connect EACCES .........
You can see that audio resource triggered the error event and past it to audio player cause another error event be triggered
I will send a request to discordjs official later, so we can know where is the cause of the problem
🤔 try playing some files from disk
still don't see how any of the ytdl-core code could proce an cannot EACCES :443
error
🤔 try playing some files from disk still don't see how any of the ytdl-core code could proce an
cannot EACCES :443
error
I'll try that. It might take some time to add this function into my bot
I found that the error might cause by "unstable Internet" or "old version npm packages" Still testing, but I wrote codes to handle the error almost perfectly using fluent-ffmpeg
//player,resource error handle
this.player.on('error', error => async function() {
this.handling_vc_err = true;
console.log("AP_err");
console.error(error);
await this.clear_status();
await this.init_player(true);
await this.join_channel();
await this.play_YT_url(this.queue[this.nowplaying], error.resource.playbackDuration);
console.log("AP_err_handled");
this.handling_vc_err = false;
});
this.audio_stream = ytdl(url, {
filter: 'audioonly',
//liveBuffer: 5000,
//highWaterMark: 1024,
dlChunkSize: 65536,
quality: 'highestaudio',
//begin: begin_t,
requestOptions: {
headers: {
cookie: YT_COOKIE,
// Optional. If not given, ytdl-core will try to find it.
// You can find this by going to a video's watch page, viewing the source,
// and searching for "ID_TOKEN".
// 'x-youtube-identity-token': 1324,
},
},
});
this.ffmpeg_audio_stream = await fluentFfmpeg({ source: this.audio_stream }).toFormat('wav').setStartTime(Math.ceil(begin_t / 1000)) // set the song start time
this.audio_resauce = await createAudioResource(this.ffmpeg_audio_stream, { inputType: StreamType.Arbitrary });
this.player.play(this.audio_resauce);
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I played some local files, never encounter this problem Now I handle the error by resetting everything
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.