ytdl stop stream after few minute
- Dominant language
- JavaScript
- Stars
- 4.7k
- Forks
- 852
- PR merge metrics
- No merged PRs in 30d
Description
i am using ytdl to stream youtube video on my discord bot. after few minute ytdl stop streaming with error
```js
Error: aborted
at connResetException (node:internal/errors:691:14)
at TLSSocket.socketCloseListener (node:_http_client:407:19)
at TLSSocket.emit (node:events:406:35)
at node:net:672:12
at TCP.done (node:_tls_wrap:580:7) {
code: 'ECONNRESET'
}
```
I think the error is caused by my slow internet connection. so I try to run my bot on hosting [heroku]. but still got the same error
i am using ytdl v4.9.1, discordJs v13.1.0 and nodeJs v16.6.1
here the code i use to start streaming
```js
const option = {
filter: "audioonly",
highWaterMark: 1048576 / 4,
};
const stream = await ytdl(streamUrl, option);
```
and here the code i use to play stream in bot with discordJs v13.1.0 and discordJs/voice v0.6.0
```js
const player = createAudioPlayer();
const resource = createAudioResource(stream);
player.play(resource);
const connection = await joinVoiceChannel({ channelId: song.voiceChannel.id, guildId: song.voiceChannel.guild.id, adapterCreator: song.voiceChannel.guild.voiceAdapterCreator });
try {
await entersState(connection, VoiceConnectionStatus.Ready, 30_000);
connection.subscribe(player);
} catch (error) {
connection.destroy();
throw error;
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.