diff --git a/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/FafLobbyClient.kt b/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/FafLobbyClient.kt index dd8fd352..e30176f4 100644 --- a/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/FafLobbyClient.kt +++ b/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/FafLobbyClient.kt @@ -1,6 +1,9 @@ package com.faforever.commons.lobby import com.fasterxml.jackson.databind.ObjectMapper +import io.netty.handler.codec.LineBasedFrameDecoder +import io.netty.handler.codec.string.LineEncoder +import io.netty.handler.codec.string.LineSeparator import io.netty.resolver.DefaultAddressResolverGroup import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -14,9 +17,12 @@ import reactor.core.publisher.Sinks.EmitResult import reactor.core.scheduler.Schedulers import reactor.netty.Connection import reactor.netty.http.client.HttpClient +import reactor.netty.http.client.WebsocketClientSpec +import reactor.netty.tcp.TcpClient import reactor.util.retry.Retry import reactor.util.retry.Retry.RetrySignal import java.net.InetSocketAddress +import java.net.URI import java.time.Duration import java.util.function.Function @@ -72,7 +78,7 @@ class FafLobbyClient( is LoginSuccessResponse -> Mono.just(it.me) is LoginFailedResponse -> Mono.error(LoginException(it.text)) } - }.timeout(Duration.ofSeconds(30)) + }.timeout(Duration.ofSeconds(10)) .doOnError(LoginException::class.java) { kicked = true } .doFirst { prepareAuthenticateOnNextSession() @@ -111,6 +117,8 @@ class FafLobbyClient( .doOnConnected { val address = it.channel().remoteAddress() as InetSocketAddress LOG.info("Connected to {} on port {}", address.hostName, address.port) + it.addHandlerFirst(LineEncoder(LineSeparator.UNIX)) // TODO: This is not working. Raise a bug ticket! Workaround below + .addHandlerLast(LineBasedFrameDecoder(config.bufferSize)) connection = it connectionAcquiredSink.emitNext(true, retrySerialFailure) }.doOnDisconnected {