Skip to content

Commit 86755ae

Browse files
committed
Test Quic connection max idle timeout
1 parent 4a8cdd7 commit 86755ae

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

vertx-core/src/main/java/io/vertx/core/net/impl/quic/QuicEndpointImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ protected QuicCodecBuilder<?> initQuicCodecBuilder(ContextInternal context, SslC
153153
codecBuilder.initialMaxStreamDataUnidirectional(transportOptions.getInitialMaxStreamDataUnidirectional());
154154
codecBuilder.activeMigration(transportOptions.getActiveMigration());
155155
if (transportOptions.getMaxIdleTimeout() != null) {
156-
codecBuilder.maxIdleTimeout(transportOptions.getMaxIdleTimeout().get(ChronoUnit.MILLIS), TimeUnit.MILLISECONDS);
156+
codecBuilder.maxIdleTimeout(transportOptions.getMaxIdleTimeout().toMillis(), TimeUnit.MILLISECONDS);
157157
}
158158
if (transportOptions.isEnableDatagrams()) {
159159
codecBuilder.datagram(transportOptions.getDatagramReceiveQueueLength(), transportOptions.getDatagramSendQueueLength());

vertx-core/src/test/java/io/vertx/tests/net/quic/QuicServerTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -469,26 +469,24 @@ public void testReceiveDatagram() throws Exception {
469469
}
470470
}
471471

472-
@Ignore("Needs to add channel handler that drop packets")
473472
@Test
474473
public void testMaxIdleTimeout() throws Exception {
475474
QuicServerOptions options = serverOptions();
476-
options.getTransportOptions().setMaxIdleTimeout(Duration.ofMillis(100));
475+
options.getTransportOptions().setMaxIdleTimeout(Duration.ofMillis(1000));
477476
QuicServer server = QuicServer.create(vertx, options);
478477
server.handler(conn -> {
479-
System.out.println("connected");
480478
long now = System.currentTimeMillis();
481479
conn.closeHandler(v -> {
482-
System.out.println("closed " + (System.currentTimeMillis() - now));
480+
assertTrue(System.currentTimeMillis() - now >= 1000);
481+
assertTrue(System.currentTimeMillis() - now < 2000);
482+
testComplete();
483483
});
484484
});
485485
server.bind(SocketAddress.inetSocketAddress(9999, "localhost")).await();
486486
QuicTestClient client = new QuicTestClient(new NioEventLoopGroup(1));
487487
try {
488488
client = new QuicTestClient(new NioEventLoopGroup(1));
489489
QuicTestClient.Connection connection = client.connect(new InetSocketAddress(NetUtil.LOCALHOST4, 9999));
490-
QuicTestClient.Stream stream = connection.newStream();
491-
stream.create();
492490
await();
493491
} finally {
494492
client.close();

0 commit comments

Comments
 (0)