Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ synchronized void toWebSocket(
WebSocketHandshakeInboundHandler handshakeInboundHandler = new WebSocketHandshakeInboundHandler(handshaker, upgrade);
p.addBefore("handler", "handshakeCompleter", handshakeInboundHandler);
upgrade.addListener((GenericFutureListener<io.netty.util.concurrent.Future<HttpHeaders>>) future -> {
if (timer > 0L) {
if (timer > -1L) {
vertx.cancelTimer(timer);
}
if (future.isSuccess()) {
Expand Down
28 changes: 27 additions & 1 deletion vertx-core/src/test/java/io/vertx/tests/http/WebSocketTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,7 @@ public List<Throwable> getReceivedExceptions() {
}

@Test
public void testHandshakeTimeout() throws Exception {
public void testHandshakeTimeoutFires() throws Exception {
NetServer server = vertx.createNetServer()
.connectHandler(so -> {

Expand All @@ -1746,6 +1746,32 @@ public void testHandshakeTimeout() throws Exception {
}
}

@Test
public void testHandshakeTimeoutDoesNotFire() throws Exception {
server = vertx.createHttpServer()
.webSocketHandler(ws -> {

});
server
.listen(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST)
.await();
client = vertx.createWebSocketClient(new WebSocketClientOptions().setConnectTimeout(1000));
WebSocketConnectOptions options = new WebSocketConnectOptions()
.setPort(DEFAULT_HTTP_PORT)
.setHost(DEFAULT_HTTP_HOST)
.setURI("/")
.setTimeout(1000);
client.connect(options).onComplete(onSuccess(ws -> {
AtomicBoolean closed = new AtomicBoolean();
ws.closeHandler(v -> closed.set(true));
vertx.setTimer(1100, id -> {
assertFalse(closed.get());
testComplete();
});
}));
await();
}

private void connectUntilWebSocketReject(WebSocketClient client, int count, Handler<AsyncResult<Void>> doneHandler) {
vertx.runOnContext(v -> {
client.connect(DEFAULT_HTTP_PORT, HttpTestBase.DEFAULT_HTTP_HOST, "/some/path").onComplete(ar -> {
Expand Down
Loading