Lavalink
Lavalink copied to clipboard
Lavalink doesn`t play audio
Description
I've created a discord music bot with lavalink but im having issues when i'm trying to play audio. When i try to list tracks it perfectly lists them but when i try to select one to play, it doesn`t play it just nothing happens.
Version info
I'm using lavalink interface written by Devoxin (version 3.1.7) and the latest version of lavalink.jar
Output of java -version
:
java 17.0.1 2021-10-19 LTS
Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)
Lavalink Logs:
Version: 608d24ddb2b7b63d5b4aa23151e8dfa924de5392-SNAPSHOT
Build: 1347
Build time: 26.05.2022 14:29:26 UTC
Branch walkyst-koe-fork
Commit: 608d24d
Commit time: 27.04.2022 18:20:57 UTC
JVM: 17.0.1
Lavaplayer 1.3.98-devoxin
2022-08-05 23:08:07.921 INFO 19044 --- [ main] lavalink.server.Launcher : No active profile set, falling back to default profiles: default
2022-08-05 23:08:08.319 WARN 19044 --- [ main] io.undertow.websockets.jsr : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used
2022-08-05 23:08:08.338 INFO 19044 --- [ main] io.undertow.servlet : Initializing Spring embedded WebApplicationContext
2022-08-05 23:08:08.338 INFO 19044 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 414 ms
2022-08-05 23:08:08.400 WARN 19044 --- [ main] l.server.config.SentryConfiguration : Turning off sentry
2022-08-05 23:08:08.623 INFO 19044 --- [ main] c.s.d.l.tools.GarbageCollectionMonitor : GC monitoring enabled, reporting results every 2 minutes.
2022-08-05 23:08:08.782 INFO 19044 --- [ main] lavalink.server.config.KoeConfiguration : OS: Windows 10, Arch: amd64
2022-08-05 23:08:08.783 WARN 19044 --- [ main] lavalink.server.config.KoeConfiguration : This system and architecture appears to not support native audio sending! GC pauses may cause your bot to stutter during playback.
2022-08-05 23:08:08.873 INFO 19044 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2022-08-05 23:08:08.980 INFO 19044 --- [ main] org.xnio : XNIO version 3.3.8.Final
2022-08-05 23:08:08.989 INFO 19044 --- [ main] org.xnio.nio : XNIO NIO Implementation Version 3.3.8.Final
2022-08-05 23:08:09.033 INFO 19044 --- [ main] o.s.b.w.e.u.UndertowServletWebServer : Undertow started on port(s) 4444 (http) with context path ''
2022-08-05 23:08:09.034 INFO 19044 --- [ main] lavalink.server.Launcher : Started Launcher in 1.154 seconds (JVM running for 2.668)
2022-08-05 23:08:33.184 INFO 19044 --- [ XNIO-1 task-1] io.undertow.servlet : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-08-05 23:08:33.185 INFO 19044 --- [ XNIO-1 task-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2022-08-05 23:08:33.189 INFO 19044 --- [ XNIO-1 task-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 4 ms
2022-08-05 23:08:33.204 INFO 19044 --- [ XNIO-1 task-1] l.server.io.HandshakeInterceptorImpl : Incoming connection from /[0:0:0:0:0:0:0:1]:58706
2022-08-05 23:08:33.248 INFO 19044 --- [ XNIO-1 task-1] lavalink.server.io.SocketServer : Connection successfully established from Lavalink.py
2022-08-05 23:08:33.260 INFO 19044 --- [ XNIO-1 I/O-3] lavalink.server.io.SocketServer : {"op": "configureResuming", "key": "music-node", "timeout": 60}
2022-08-05 23:08:47.485 INFO 19044 --- [ XNIO-1 I/O-3] lavalink.server.io.SocketServer : {"op": "voiceUpdate", "guildId": "688120304429694985", "sessionId": "012d7c0b06720aa6959ed54b7a404a2d", "event": {"token": "99b980d2b044f313", "guild_id": "688120304429694985", "endpoint": "rotterdam5214.discord.media:443"}}
2022-08-05 23:09:00.655 INFO 19044 --- [ XNIO-1 task-2] l.server.player.AudioLoaderRestHandler : Got request to load for identifier "ytsearch:Daughter No Care"
2022-08-05 23:09:01.386 INFO 19044 --- [ader-2-thread-1] lavalink.server.player.AudioLoader : Loaded playlist Search results for: Daughter No Care
2022-08-05 23:09:03.450 INFO 19044 --- [ XNIO-1 I/O-3] lavalink.server.io.SocketServer : {"op": "play", "guildId": "688120304429694985", "track": "QAAAdAIAEkRhdWdodGVyIC0gTm8gQ2FyZQAIRGF1Z2h0ZXIAAAAAAAKnsAALRlpDWkc1cHdRR2sAAQAraHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1GWkNaRzVwd1FHawAHeW91dHViZQAAAAAAAAAA", "startTime": 0, "endTime": 0, "noReplace": false}
And i'd like to share my code (in case you need it):
@commands.command(name="play")
async def play(self,ctx, * ,query):
try:
player = self.bot.music.player_manager.get(ctx.guild.id)
query = f"ytsearch:{query}"
results = await player.node.get_tracks(query)
tracks = results['tracks'][0:10]
i = 0
query_result = ''
for track in tracks:
i += 1
query_result = query_result + f'{i}) {track["info"]["title"]} - {track["info"]["uri"]}\n'
embed = Embed()
embed.description = query_result
await ctx.channel.send(embed=embed)
def check(m):
return m.author.id == ctx.author.id
response = await self.bot.wait_for('message', check=check)
track = tracks[int(response.content)-1]
player.add(requester=ctx.author.id,track=track)
if not player.is_playing:
await player.play()
except Exception as err:
print(err)
Can't see anything immediately wrong, however I would advise you attach some event listeners in your code, to listen for Track events. There's a possibility the track might be getting stuck, or encountering an exception.
Also, I noticed that endTime
is being sent with a value of zero. Not sure if this is a contributing factor, but to rule this out as an issue I would suggest changing await player.play()
to await player.play(end_time=None)
Also update your Lavalink build. 1.3.98-devoxin
-- yours is about 3 months out of date and I haven't maintained my Lavaplayer fork for a while yet. Grab 3.5-rc2 here.
I have created a lavalink server on replit instead of creating a one on my computer, run exactly the same code and it worked, it played the music i requested. But when i create a server on my computer it gets the request but doesn't play anything.
Here is the Lavalink logs(I updated it to version 3.5-rc2):
2022-08-06 13:51:52.327 INFO 6800 --- [ XNIO-1 task-1] lavalink.server.io.SocketServer : Connection successfully established from WaveLink 2022-08-06 13:51:52.337 INFO 6800 --- [ XNIO-1 I/O-8] lavalink.server.io.SocketServer : {"op": "configureResuming", "key": "a2b9b6cbb67bd7f9", "timeout": 60} 2022-08-06 13:52:04.883 INFO 6800 --- [ XNIO-1 task-1] l.server.player.AudioLoaderRestHandler : Got request to load for identifier "ytsearch:infraction cyber attac" 2022-08-06 13:52:05.703 INFO 6800 --- [ader-2-thread-1] lavalink.server.player.AudioLoader : Loaded playlist Search results for: infraction cyber attac 2022-08-06 13:52:05.720 INFO 6800 --- [ XNIO-1 I/O-8] lavalink.server.io.SocketServer : {"op": "play", "guildId": "688120304429694985", "track": "QAAAyQIAUEN5YmVycHVuayAyMDc3IGJ5IEluZnJhY3Rpb24gW05vIENvcHlyaWdodCBNdXNpY10gW 0ZyZWUgRG93bmxvYWRdIC8gQ3liZXIgQXR0YWNrAB9JbmZyYWN0aW9uIC0gTm8gQ29weXJpZ2h0IE11c2ljAAAAAAADMGgAC0FOTTF0VUJTWFFvAAEAK2h0dHBzOi8vd3d3LnlvdXR1YmUuY29tL3dhdGNoP3Y9QU5NMXRVQlNYUW8AB3lvdXR1YmUAAAAAAAAAAA==", "noReplace": false, "startTime": "0"} 2022-08-06 13:52:05.727 INFO 6800 --- [ XNIO-1 task-1] l.server.player.AudioLoaderRestHandler : GET /decodetrack 2022-08-06 13:52:05.727 WARN 6800 --- [back-1-thread-1] c.s.d.l.s.y.YoutubeAccessTokenTracker : YouTube auth tokens can't be retrieved because email and password is not set in YoutubeAudioSourceManager, age restricted videos will t hrow exceptions. 2022-08-06 13:52:06.320 INFO 6800 --- [ XNIO-1 I/O-8] lavalink.server.io.SocketServer : {"op": "voiceUpdate", "guildId": "688120304429694985", "sessionId": "e0328f2dea6d2940fc66997e88a9cb30", "event": {"token": "612a87e3e56 9df08", "guild_id": "688120304429694985", "endpoint": "rotterdam204.discord.media:443"}} 2022-08-06 13:55:35.612 INFO 6800 --- [ XNIO-1 task-1] l.server.player.AudioLoaderRestHandler : GET /decodetrack
@Devoxin I started the server on a linux virtual machine and started the bot on windows and the problem solved. You were right the track was getting stuck because of i'm starting server and the bot on the same machine. Had the same issue a while ago on a messaging app project. Thank you and sorry for taking your time for a simple problem like that.
same issue here, but with discord.js
Also my bot same issue not hearing any sounds this happend some guilds
Without logs we can only guess
What I noticed in OP's logs is "endTime": "0",
This might be the problem here
Looking closer in lavalinks code this looks fine actually
https://github.com/freyacodes/Lavalink/blob/bc9dcb2e3d12dda34cf12455601e4916eace4dfb/LavalinkServer/src/main/java/lavalink/server/io/WebSocketHandler.kt#L94
Nevertheless saying same is just useless and doesn't provide any info for us
OP replied their issue was a case of the track getting stuck. I'm going to assume it's a similar case for anyone else tagging on to this issue, but as already stated nothing can be done without logs. I'm going to go ahead and close this issue.
Should anyone want to follow up on this for an identical issue, please join the Discord server (preferred) or create a new issue to better help us keep track of issues.