-
-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
Describe the bug
The bot connects to the voice channel, but does not play music.
System.TimeoutException: The player could not be retrieved within the specified time.
To Reproduce
Steps to reproduce the behavior:
- Retrive player
await _audioService.Players.RetrieveAsync
- Wait around 5 sec
- See error in logs
Expected behavior
Non-empty player?
Screenshots
Code
public async ValueTask<QueuedLavalinkPlayer?> GetPlayerAsync(
ulong guildId,
ulong channelId,
bool connectToVoiceChannel = true,
ImmutableArray<IPlayerPrecondition> preconditions = default)
{
var channelBehavior = connectToVoiceChannel
? PlayerChannelBehavior.Join
: PlayerChannelBehavior.None;
PlayerRetrieveOptions retrieveOptions = new(
ChannelBehavior: channelBehavior,
Preconditions: preconditions,
VoiceStateBehavior: MemberVoiceStateBehavior.RequireSame
);
var playerOptions = new QueuedLavalinkPlayerOptions
{
InitialVolume = (float)0.1
};
var result = await _audioService.Players.RetrieveAsync(
guildId,
channelId,
PlayerFactory.Queued,
Options.Create(playerOptions),
retrieveOptions: retrieveOptions
).ConfigureAwait(false);
if (!result.IsSuccess)
{
var errorMessage = result.Status switch
{
PlayerRetrieveStatus.UserNotInVoiceChannel => "You are not connected to a voice channel.",
PlayerRetrieveStatus.BotNotConnected => "The bot is currently not connected.",
_ => "Unknown error.",
};
Console.WriteLine($"Error: {errorMessage}");
return null;
}
return result.Player;
}
System.TimeoutException: The player could not be retrieved within the specified time. There are a few possibilities why this might occur:
- You are currently operating on the gateway thread which can cause a deadlock since no further gateway messages can be processed.
- In case you are using Discord.Net, a common solution would be to enable RunMode.Async which dispatches commands on a separate task which allows
further gateway messages to be processed while the player is being created
- The client lost connection to the Lavalink server.
- You are missing the guild voice states intent which is required to retrieve the voice state of the bot (and possibly other users).
- Your bot does not have the necessary permissions to join the voice channel.
at Lavalink4NET.Players.PlayerManager.GetPlayerInternalAsync(ILavalinkPlayerHandle playerHandle, CancellationToken cancellationToken) in /home/runner/work/Lavalink4NET/Lavalink4NET/src/Lavalink4NET/Players/PlayerManager.cs:line 392
at Lavalink4NET.Players.PlayerManager.JoinAsync[TPlayer,TOptions](UInt64 guildId, UInt64 voiceChannelId, PlayerFactory`2 playerFactory, IOptions`1 options, CancellationToken cancellationToken) in /home/runner/work/Lavalink4NET/Lavalink4NET/src/Lavalink4NET/Players/PlayerManager.cs:line 148
at Lavalink4NET.Players.PlayerManager.RetrieveAsync[TPlayer,TOptions](UInt64 guildId, Nullable`1 memberVoiceChannel, PlayerFactory`2 playerFactory, IOptions`1 options, PlayerRetrieveOptions retrieveOptions, CancellationToken cancellationToken) in /home/runner/work/Lavalink4NET/Lavalink4NET/src/Lavalink4NET/Players/PlayerManager.cs:line 299
at ***REDACTED***.GetPlayerAsync(UInt64 guildId, UInt64 channelId, Boolean connectToVoiceChannel, ImmutableArray`1 preconditions) in ***REDACTED***
2025-01-09T02:54:12.060Z DEBUG 1 --- [ XNIO-1 task-9] h.i.c.PoolingHttpClientConnectionManager : Connection [id: 4][route: {s}->https://youtubei.googleapis.com:443] can be kept alive indefinitely
2025-01-09T02:54:12.060602536Z 2025-01-09T02:54:12.060Z DEBUG 1 --- [ XNIO-1 task-9] h.i.c.DefaultManagedHttpClientConnection : http-outgoing-4: set socket timeout to 0
2025-01-09T02:54:12.060677756Z 2025-01-09T02:54:12.060Z DEBUG 1 --- [ XNIO-1 task-9] h.i.c.PoolingHttpClientConnectionManager : Connection released: [id: 4][route: {s}->https://youtubei.googleapis.com:443][total available: 2; route allocated: 1 of 1500; total allocated: 2 of 3000]
2025-01-09T02:54:12.075066101Z 2025-01-09T02:54:12.074Z DEBUG 1 --- [ XNIO-1 task-9] c.s.d.l.p.DefaultAudioPlayerManager : Loaded a track with identifier https://www.youtube.com/watch?v=dQw4w9WgXcQ using YoutubeAudioSourceManager.
2025-01-09T02:54:12.075173029Z 2025-01-09T02:54:12.075Z INFO 1 --- [ XNIO-1 task-9] lavalink.server.player.AudioLoader : Loaded track Rick Astley - Never Gonna Give You Up (Official Music Video)
2025-01-09T02:54:12.087294375Z 2025-01-09T02:54:12.087Z DEBUG 1 --- [ XNIO-1 task-9] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Using 'application/json', given [*/*] and supported [application/json, application/*+json]
2025-01-09T02:54:12.088193450Z 2025-01-09T02:54:12.088Z DEBUG 1 --- [ XNIO-1 task-9] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Writing [TrackLoaded(loadType=TRACK, data=Track(encoded=QAAA1QMAPFJpY2sgQXN0bGV5IC0gTmV2ZXIgR29ubmEgR2l2ZSBZb (truncated)...]
2025-01-09T02:54:12.088901158Z 2025-01-09T02:54:12.088Z DEBUG 1 --- [ XNIO-1 task-9] o.s.web.servlet.DispatcherServlet : Completed 200 OK
2025-01-09T02:54:12.089041820Z 2025-01-09T02:54:12.088Z INFO 1 --- [ XNIO-1 task-9] l.server.io.RequestLoggingFilter : GET /v4/loadtracks?identifier=https%3a%2f%2fwww.youtube.com%2fwatch%3fv%3ddQw4w9WgXcQ, client=172.19.0.1
2025-01-09T02:54:13.335902780Z 2025-01-09T02:54:13.335Z DEBUG 1 --- [ XNIO-1 task-9] io.undertow.request.security : Attempting to authenticate /v4/sessions/nedl9673e1em2pqe/players/904469547053121567, authentication required: false
2025-01-09T02:54:13.335936653Z 2025-01-09T02:54:13.335Z DEBUG 1 --- [ XNIO-1 task-9] io.undertow.request.security : Authentication outcome was NOT_ATTEMPTED with method io.undertow.security.impl.CachedAuthenticatedSessionMechanism@515b47ee for /v4/sessions/nedl9673e1em2pqe/players/904469547053121567
2025-01-09T02:54:13.336323927Z 2025-01-09T02:54:13.336Z DEBUG 1 --- [ XNIO-1 task-9] io.undertow.request.security : Authentication result was ATTEMPTED for /v4/sessions/nedl9673e1em2pqe/players/904469547053121567
2025-01-09T02:54:13.336591840Z 2025-01-09T02:54:13.336Z DEBUG 1 --- [ XNIO-1 task-9] o.s.web.servlet.DispatcherServlet : PATCH "/v4/sessions/nedl9673e1em2pqe/players/904469547053121567", parameters={}
2025-01-09T02:54:13.336942726Z 2025-01-09T02:54:13.336Z DEBUG 1 --- [ XNIO-1 task-9] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to lavalink.server.player.PlayerRestHandler#patchPlayer(PlayerUpdate, String, long, boolean)
2025-01-09T02:54:13.337637234Z 2025-01-09T02:54:13.337Z DEBUG 1 --- [ XNIO-1 task-9] m.m.a.RequestResponseBodyMethodProcessor : Read "application/json;charset=utf-8" to [PlayerUpdate(encodedTrack=OMITTED, identifier=OMITTED, track=OMITTED, position=OMITTED, endTime=OMIT (truncated)...]
2025-01-09T02:54:13.338115931Z 2025-01-09T02:54:13.338Z DEBUG 1 --- [ XNIO-1 task-9] m.k.koe.internal.MediaConnectionImpl : Disconnecting...
2025-01-09T02:54:13.338787461Z 2025-01-09T02:54:13.338Z DEBUG 1 --- [ XNIO-1 task-9] m.k.k.g.AbstractMediaGatewayConnection : Connecting to wss://finland10090.discord.media:443/?v=4, attempt 0/3
2025-01-09T02:54:13.420270151Z 2025-01-09T02:54:13.420Z DEBUG 1 --- [tLoopGroup-2-15] i.n.h.c.h.w.WebSocketClientHandshaker13 : WebSocket version 13 client handshake key: aMrmC9roNDW5E+0rBGOa+Q==, expected response: /vwv75OREZOP8Sy8EYK8kmiK830=
2025-01-09T02:54:14.716760086Z 2025-01-09T02:54:14.716Z DEBUG 1 --- [ager-3-thread-1] c.s.d.l.tools.GarbageCollectionMonitor : GC results for the last 2 minutes: [Bucket 0 = 9] [Bucket 20 = 0] [Bucket 50 = 0] [Bucket 200 = 0] [Bucket 500 = 0] [Bucket 2000 = 0]
2025-01-09T02:54:15.964855922Z 2025-01-09T02:54:15.964Z DEBUG 1 --- [pool-4-thread-1] oshi.util.FileUtil : Reading file /proc/stat
2025-01-09T02:54:15.965447343Z 2025-01-09T02:54:15.965Z DEBUG 1 --- [pool-4-thread-1] oshi.util.FileUtil : Reading file /proc/1/io
2025-01-09T02:54:15.965514531Z 2025-01-09T02:54:15.965Z DEBUG 1 --- [pool-4-thread-1] oshi.util.FileUtil : Reading file /proc/1/io
2025-01-09T02:54:15.965738304Z 2025-01-09T02:54:15.965Z DEBUG 1 --- [pool-4-thread-1] oshi.util.FileUtil : Reading file /proc/1/status
2025-01-09T02:54:15.965793899Z 2025-01-09T02:54:15.965Z DEBUG 1 --- [pool-4-thread-1] oshi.util.FileUtil : Reading file /proc/1/status
2025-01-09T02:54:15.966035831Z 2025-01-09T02:54:15.965Z DEBUG 1 --- [pool-4-thread-1] oshi.util.FileUtil : Reading file /proc/1/stat
2025-01-09T02:54:15.966062650Z 2025-01-09T02:54:15.966Z DEBUG 1 --- [pool-4-thread-1] oshi.util.FileUtil : Reading file /proc/1/stat
2025-01-09T02:54:23.428876397Z 2025-01-09T02:54:23.428Z DEBUG 1 --- [tLoopGroup-2-15] m.k.k.g.AbstractMediaGatewayConnection : Connecting to wss://finland10090.discord.media:443/?v=4, attempt 0/3
2025-01-09T02:54:23.466660321Z 2025-01-09T02:54:23.466Z DEBUG 1 --- [tLoopGroup-2-16] i.n.h.c.h.w.WebSocketClientHandshaker13 : WebSocket version 13 client handshake key: xEEw8djKsatBoGRwBcm+Tg==, expected response: aDliwqlll/RsmEhDkpbwtOQzxX4=
2025-01-09T02:54:26.453362041Z 2025-01-09T02:54:26.453Z DEBUG 1 --- [ XNIO-1 I/O-7] io.undertow.websockets.core.request : UT025003: Decoding WebSocket Frame with opCode 10
2025-01-09T02:54:42.551488049Z 2025-01-09T02:54:42.551Z DEBUG 1 --- [pool-3-thread-1] oshi.util.FileUtil : Reading file /proc/stat
2025-01-09T02:54:42.551916949Z 2025-01-09T02:54:42.551Z DEBUG 1 --- [pool-3-thread-1] oshi.util.FileUtil : Reading file /proc/1/io
2025-01-09T02:54:42.551939298Z 2025-01-09T02:54:42.551Z DEBUG 1 --- [pool-3-thread-1] oshi.util.FileUtil : Reading file /proc/1/io
2025-01-09T02:54:42.552106639Z 2025-01-09T02:54:42.552Z DEBUG 1 --- [pool-3-thread-1] oshi.util.FileUtil : Reading file /proc/1/status
2025-01-09T02:54:42.552122982Z 2025-01-09T02:54:42.552Z DEBUG 1 --- [pool-3-thread-1] oshi.util.FileUtil : Reading file /proc/1/status
2025-01-09T02:54:42.552272514Z 2025-01-09T02:54:42.552Z DEBUG 1 --- [pool-3-thread-1] oshi.util.FileUtil : Reading file /proc/1/stat
2025-01-09T02:54:42.552290254Z 2025-01-09T02:54:42.552Z DEBUG 1 --- [pool-3-thread-1] oshi.util.FileUtil : Reading file /proc/1/stat
2025-01-09T02:54:56.449027645Z 2025-01-09T02:54:56.448Z DEBUG 1 --- [pool-6-thread-1] oshi.util.FileUtil : Reading file /proc/stat
2025-01-09T02:54:56.449584634Z 2025-01-09T02:54:56.449Z DEBUG 1 --- [pool-6-thread-1] oshi.util.FileUtil : Reading file /proc/1/io
2025-01-09T02:54:56.449609498Z 2025-01-09T02:54:56.449Z DEBUG 1 --- [pool-6-thread-1] oshi.util.FileUtil : Reading file /proc/1/io
2025-01-09T02:54:56.449846960Z 2025-01-09T02:54:56.449Z DEBUG 1 --- [pool-6-thread-1] oshi.util.FileUtil : Reading file /proc/1/status
2025-01-09T02:54:56.449873780Z 2025-01-09T02:54:56.449Z DEBUG 1 --- [pool-6-thread-1] oshi.util.FileUtil : Reading file /proc/1/status
2025-01-09T02:54:56.450055718Z 2025-01-09T02:54:56.450Z DEBUG 1 --- [pool-6-thread-1] oshi.util.FileUtil : Reading file /proc/1/stat
2025-01-09T02:54:56.450075483Z 2025-01-09T02:54:56.450Z DEBUG 1 --- [pool-6-thread-1] oshi.util.FileUtil : Reading file /proc/1/stat
2025-01-09T02:54:56.450632612Z 2025-01-09T02:54:56.450Z TRACE 1 --- [ XNIO-1 I/O-7] lavalink.server.io.SocketContext : Sent {"op":"stats","frameStats":null,"players":1,"playingPlayers":0,"uptime":1845455,"memory":{"free":50809760,"used":158905440,"allocated":209715200,"reservable":2147483648},"cpu":{"cores":12,"systemLoad":0.12074360390207989,"lavalinkLoad":1.1992133160646617E-4}}
2025-01-09T02:54:56.452574707Z 2025-01-09T02:54:56.452Z DEBUG 1 --- [ XNIO-1 I/O-7] io.undertow.websockets.core.request : UT025003: Decoding WebSocket Frame with opCode 10
If applicable, add screenshots to help explain your problem.
(please complete the following information):
- Lavalink4NET Version - 4.0.25
- Exception thrown? (consider enabling logging)
- DSharpPlus 4.5.0
Additional context
Probably similar to #191
Metadata
Metadata
Assignees
Labels
No labels