diff --git a/LavalinkServer/application.yml.example b/LavalinkServer/application.yml.example index 3badfaf4..1b358110 100644 --- a/LavalinkServer/application.yml.example +++ b/LavalinkServer/application.yml.example @@ -64,6 +64,10 @@ lavalink: #proxyPort: 3128 # Proxy port, 3128 is the default for squidProxy #proxyUser: "" # Optional user for basic authentication fields, leave blank if you don't use basic auth #proxyPassword: "" # Password for basic authentication + timeouts: + connectTimeoutMs: 3000 + connectionRequestTimeoutMs: 3000 + socketTimeoutMs: 3000 metrics: prometheus: diff --git a/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.kt b/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.kt index 96571e68..733a86f6 100644 --- a/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.kt +++ b/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.kt @@ -14,6 +14,7 @@ import com.sedmelluq.discord.lavaplayer.source.soundcloud.* import com.sedmelluq.discord.lavaplayer.source.twitch.TwitchStreamAudioSourceManager import com.sedmelluq.discord.lavaplayer.source.vimeo.VimeoAudioSourceManager import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager +import com.sedmelluq.discord.lavaplayer.tools.io.HttpClientTools import com.sedmelluq.discord.lavaplayer.track.playback.NonAllocatingAudioFrameBuffer import com.sedmelluq.lava.extensions.youtuberotator.YoutubeIpRotatorSetup import com.sedmelluq.lava.extensions.youtuberotator.planner.* @@ -24,6 +25,8 @@ import org.apache.http.HttpHost import org.apache.http.auth.AuthScope import org.apache.http.auth.UsernamePasswordCredentials import org.apache.http.client.CredentialsProvider +import org.apache.http.client.config.CookieSpecs +import org.apache.http.client.config.RequestConfig import org.apache.http.impl.client.BasicCredentialsProvider import org.slf4j.LoggerFactory import org.springframework.context.annotation.Bean @@ -50,6 +53,26 @@ class AudioPlayerConfiguration { audioPlayerManagerConfigurations: Collection, mediaContainerProbes: Collection ): AudioPlayerManager { + serverConfig.timeouts?.let { + HttpClientTools.setDefaultRequestConfig( + RequestConfig.custom() + .setConnectTimeout(serverConfig.timeouts!!.connectTimeoutMs) + .setConnectionRequestTimeout(serverConfig.timeouts!!.connectionRequestTimeoutMs) + .setSocketTimeout(serverConfig.timeouts!!.socketTimeoutMs) + .setCookieSpec(CookieSpecs.STANDARD) + .build() + ) + + HttpClientTools.setNoCookiesRequestConfig( + RequestConfig.custom() + .setConnectTimeout(serverConfig.timeouts!!.connectTimeoutMs) + .setConnectionRequestTimeout(serverConfig.timeouts!!.connectionRequestTimeoutMs) + .setSocketTimeout(serverConfig.timeouts!!.socketTimeoutMs) + .setCookieSpec(CookieSpecs.IGNORE_COOKIES) + .build() + ) + } + val audioPlayerManager = DefaultAudioPlayerManager() if (serverConfig.isGcWarnings) { diff --git a/LavalinkServer/src/main/java/lavalink/server/config/ServerConfig.kt b/LavalinkServer/src/main/java/lavalink/server/config/ServerConfig.kt index da31f325..209c0f6a 100644 --- a/LavalinkServer/src/main/java/lavalink/server/config/ServerConfig.kt +++ b/LavalinkServer/src/main/java/lavalink/server/config/ServerConfig.kt @@ -46,4 +46,11 @@ class ServerConfig { var youtubeConfig: YoutubeConfig? = null var httpConfig: HttpConfig? = null var filters: Map = mapOf() + var timeouts: TimeoutsConfig? = null +} + +class TimeoutsConfig { + var connectTimeoutMs: Int = 3000 + var connectionRequestTimeoutMs: Int = 3000 + var socketTimeoutMs: Int = 3000 } diff --git a/build.gradle.kts b/build.gradle.kts index 1bb71a69..9ecfe5d8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,6 +26,7 @@ allprojects { mavenLocal() // useful for developing maven("https://m2.dv8tion.net/releases") maven("https://maven.lavalink.dev/releases") + maven("https://maven.lavalink.dev/snapshots") jcenter() maven("https://jitpack.io") // build projects directly from GitHub } diff --git a/settings.gradle.kts b/settings.gradle.kts index 14cbf4aa..c020d6c5 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -34,7 +34,7 @@ fun VersionCatalogBuilder.spring() { } fun VersionCatalogBuilder.voice() { - version("lavaplayer", "2.2.2") + version("lavaplayer", "a099a98b55e33c1694b2e2636ecd1c3a33769707-SNAPSHOT") version("koe", "2.0.3-rc2") library("lavaplayer", "dev.arbjerg", "lavaplayer").versionRef("lavaplayer")