Skip to content

Commit b05f362

Browse files
committed
Test Quic connection max idle timeout
1 parent 0bfb3ce commit b05f362

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
@@ -117,7 +117,7 @@ protected QuicCodecBuilder<?> initQuicCodecBuilder(ContextInternal context, SslC
117117
codecBuilder.initialMaxStreamDataUnidirectional(transportOptions.getInitialMaxStreamDataUnidirectional());
118118
codecBuilder.activeMigration(transportOptions.getActiveMigration());
119119
if (transportOptions.getMaxIdleTimeout() != null) {
120-
codecBuilder.maxIdleTimeout(transportOptions.getMaxIdleTimeout().get(ChronoUnit.MILLIS), TimeUnit.MILLISECONDS);
120+
codecBuilder.maxIdleTimeout(transportOptions.getMaxIdleTimeout().toMillis(), TimeUnit.MILLISECONDS);
121121
}
122122
if (transportOptions.isEnableDatagrams()) {
123123
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
@@ -471,26 +471,24 @@ public void testReceiveDatagram() throws Exception {
471471
}
472472
}
473473

474-
@Ignore("Needs to add channel handler that drop packets")
475474
@Test
476475
public void testMaxIdleTimeout() throws Exception {
477476
QuicServerOptions options = serverOptions();
478-
options.getTransportOptions().setMaxIdleTimeout(Duration.ofMillis(100));
477+
options.getTransportOptions().setMaxIdleTimeout(Duration.ofMillis(1000));
479478
QuicServer server = QuicServer.create(vertx, options);
480479
server.handler(conn -> {
481-
System.out.println("connected");
482480
long now = System.currentTimeMillis();
483481
conn.closeHandler(v -> {
484-
System.out.println("closed " + (System.currentTimeMillis() - now));
482+
assertTrue(System.currentTimeMillis() - now >= 1000);
483+
assertTrue(System.currentTimeMillis() - now < 2000);
484+
testComplete();
485485
});
486486
});
487487
server.bind(SocketAddress.inetSocketAddress(9999, "localhost")).await();
488488
QuicTestClient client = new QuicTestClient(new NioEventLoopGroup(1));
489489
try {
490490
client = new QuicTestClient(new NioEventLoopGroup(1));
491491
QuicTestClient.Connection connection = client.connect(new InetSocketAddress(NetUtil.LOCALHOST4, 9999));
492-
QuicTestClient.Stream stream = connection.newStream();
493-
stream.create();
494492
await();
495493
} finally {
496494
client.close();

0 commit comments

Comments
 (0)