Skip to content

Commit 7bff9d2

Browse files
committed
less idle timeouts for zombie clients
1 parent a647f7b commit 7bff9d2

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

client/testserver/src/main/scala/sttp/tapir/client/tests/HttpServer.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import org.slf4j.LoggerFactory
1717
import org.typelevel.ci.CIString
1818
import scodec.bits.ByteVector
1919

20+
import scala.concurrent.duration._
21+
2022
object HttpServer extends ResourceApp.Forever {
2123

2224
private val defaultPort = Port.fromInt(51823).get
@@ -232,6 +234,7 @@ class HttpServer(port: Port) {
232234
.default[IO]
233235
.withPort(port)
234236
.withHttpWebSocketApp(app)
237+
.withIdleTimeout(5.seconds)
235238
.build
236239
.evalTap(_ => IO(logger.info(s"Server on port $port started")))
237240
.onFinalize(IO(logger.info(s"Server on port $port stopped")))

server/http4s-server/src/test/scala/sttp/tapir/server/http4s/Http4sTestServerInterpreter.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Http4sTestServerInterpreter extends TestServerInterpreter[IO, Fs2Streams[I
3030
private val serverBuilder = EmberServerBuilder
3131
.default[IO]
3232
.withPort(anyAvailablePort)
33+
.withIdleTimeout(5.seconds)
3334
.withAdditionalSocketOptions(
3435
List(fs2.io.net.SocketOption.noDelay(true)) // https://github.com/http4s/http4s/issues/7668
3536
)

server/http4s-server/zio/src/test/scala/sttp/tapir/server/http4s/ztapir/ZHttp4sTestServerInterpreter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ object ZHttp4sTestServerInterpreter {
2929
class ZHttp4sTestServerInterpreter extends TestServerInterpreter[Task, ZioStreams with WebSockets, ServerOptions, Routes] {
3030

3131
private val anyAvailablePort = ip4s.Port.fromInt(0).get
32-
private val serverBuilder = EmberServerBuilder.default[Task].withPort(anyAvailablePort)
32+
private val serverBuilder = EmberServerBuilder.default[Task].withPort(anyAvailablePort).withIdleTimeout(5.seconds)
3333

3434
override def route(es: List[ZServerEndpoint[Any, ZioStreams with WebSockets]], interceptors: Interceptors): Routes = {
3535
val serverOptions: ServerOptions = interceptors(Http4sServerOptions.customiseInterceptors[Task]).options

0 commit comments

Comments
 (0)