fix: Actually set halfClosed in half closed sample (#30404)

This commit is contained in:
Johan Andrén 2021-07-19 12:22:18 +02:00 committed by GitHub
parent d2345ef920
commit 79cff55685
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -14,6 +14,8 @@ import akka.stream.testkit.TestSubscriber;
import akka.util.ByteString;
import java.time.Duration;
import java.util.Collections;
import java.util.Optional;
import java.util.concurrent.CompletionStage;
public class FromSinkAndSource {
@ -31,7 +33,15 @@ public class FromSinkAndSource {
Flow<ByteString, ByteString, NotUsed> serverFlow = Flow.fromSinkAndSource(sink, source);
Source<Tcp.IncomingConnection, CompletionStage<Tcp.ServerBinding>> connectionStream =
Tcp.get(system).bind("127.0.0.1", 9999);
Tcp.get(system)
.bind(
"127.0.0.1", // interface
9999, // port
100, // backlog
Collections.emptyList(), // socket options
true, // Important: half close enabled
Optional.empty() // idle timeout
);
connectionStream.runForeach(
incomingConnection -> incomingConnection.handleWith(serverFlow, system), system);

View file

@ -34,7 +34,7 @@ object FromSinkAndSource {
val serverFlow = Flow.fromSinkAndSource(sink, source)
Tcp().bind("127.0.0.1", 9999).runForeach { incomingConnection =>
Tcp().bind("127.0.0.1", 9999, halfClose = true).runForeach { incomingConnection =>
incomingConnection.handleWith(serverFlow)
}
// #halfClosedTcpServer