Skip to content

Instantly share code, notes, and snippets.

@nfarina
Created October 16, 2013 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfarina/7013420 to your computer and use it in GitHub Desktop.
Save nfarina/7013420 to your computer and use it in GitHub Desktop.
Code to reproduce an issue where Vert.x's `HttpClient.connectWebSocket()` hangs indefinitely and never calls the exception handler, if the connection is terminated during WebSocket connection negotiation.
HttpClient httpClient = vertx.createHttpClient();
httpClient.setHost("localhost");
httpClient.setPort(8888);
httpClient.setConnectTimeout(1000); // 1 second
httpClient.exceptionHandler(new Handler<Throwable>() {
@Override
public void handle(Throwable event) {
System.out.println("Failed!"); // never called
}
});
httpClient.connectWebsocket("/", new Handler<WebSocket>() {
@Override
public void handle(WebSocket event) {
System.out.println("Connected!"); // never called
}
});
HttpServer httpServer = vertx.createHttpServer();
httpServer.websocketHandler(new Handler<ServerWebSocket>() {
@Override
public void handle(ServerWebSocket socket) {
System.out.println("Closing hard!");
System.exit(1);
}
});
httpServer.listen(8888);
12:26:01.637129 IP localhost.62857 > localhost.ddi-tcp-1: Flags [S], seq 2249193108, win 65535, options [mss 16344,nop,wscale 4,nop,nop,TS val 354866058 ecr 0,sackOK,eol], length 0
0x0000: 4500 0040 bf1a 4000 4006 0000 7f00 0001 E..@..@.@.......
0x0010: 7f00 0001 f589 22b8 860f f694 0000 0000 ......".........
0x0020: b002 ffff fe34 0000 0204 3fd8 0103 0304 .....4....?.....
0x0030: 0101 080a 1526 d38a 0000 0000 0402 0000 .....&..........
12:26:01.637224 IP localhost.ddi-tcp-1 > localhost.62857: Flags [S.], seq 2481691748, ack 2249193109, win 65535, options [mss 16344,nop,wscale 4,nop,nop,TS val 354866059 ecr 354866058,sackOK,eol], length 0
0x0000: 4500 0040 009f 4000 4006 0000 7f00 0001 E..@..@.@.......
0x0010: 7f00 0001 22b8 f589 93eb 9c64 860f f695 ...."......d....
0x0020: b012 ffff fe34 0000 0204 3fd8 0103 0304 .....4....?.....
0x0030: 0101 080a 1526 d38b 1526 d38a 0402 0000 .....&...&......
12:26:01.637237 IP localhost.62857 > localhost.ddi-tcp-1: Flags [.], ack 1, win 9186, options [nop,nop,TS val 354866059 ecr 354866059], length 0
0x0000: 4500 0034 5052 4000 4006 0000 7f00 0001 E..4PR@.@.......
0x0010: 7f00 0001 f589 22b8 860f f695 93eb 9c65 ......"........e
0x0020: 8010 23e2 fe28 0000 0101 080a 1526 d38b ..#..(.......&..
0x0030: 1526 d38b .&..
12:26:01.637253 IP localhost.ddi-tcp-1 > localhost.62857: Flags [.], ack 1, win 9186, options [nop,nop,TS val 354866059 ecr 354866059], length 0
0x0000: 4500 0034 def4 4000 4006 0000 7f00 0001 E..4..@.@.......
0x0010: 7f00 0001 22b8 f589 93eb 9c65 860f f695 ...."......e....
0x0020: 8010 23e2 fe28 0000 0101 080a 1526 d38b ..#..(.......&..
0x0030: 1526 d38b .&..
12:26:01.709500 IP localhost.62857 > localhost.ddi-tcp-1: Flags [P.], seq 1:199, ack 1, win 9186, options [nop,nop,TS val 354866120 ecr 354866059], length 198
0x0000: 4500 00fa 08db 4000 4006 0000 7f00 0001 E.....@.@.......
0x0010: 7f00 0001 f589 22b8 860f f695 93eb 9c65 ......"........e
0x0020: 8018 23e2 feee 0000 0101 080a 1526 d3c8 ..#..........&..
0x0030: 1526 d38b 4745 5420 2f20 4854 5450 2f31 .&..GET./.HTTP/1
0x0040: 2e31 0d0a 5570 6772 6164 653a 2077 6562 .1..Upgrade:.web
0x0050: 736f 636b 6574 0d0a 436f 6e6e 6563 7469 socket..Connecti
0x0060: 6f6e 3a20 5570 6772 6164 650d 0a53 6563 on:.Upgrade..Sec
0x0070: 2d57 6562 536f 636b 6574 2d4b 6579 3a20 -WebSocket-Key:.
0x0080: 434d 4c48 5872 7349 4448 6462 6d52 6a61 CMLHXrsIDHdbmRja
0x0090: 4867 4755 3077 3d3d 0d0a 486f 7374 3a20 HgGU0w==..Host:.
0x00a0: 6c6f 6361 6c68 6f73 743a 3838 3838 0d0a localhost:8888..
0x00b0: 5365 632d 5765 6253 6f63 6b65 742d 4f72 Sec-WebSocket-Or
0x00c0: 6967 696e 3a20 6874 7470 3a2f 2f6c 6f63 igin:.http://loc
0x00d0: 616c 686f 7374 3a38 3838 380d 0a53 6563 alhost:8888..Sec
0x00e0: 2d57 6562 536f 636b 6574 2d56 6572 7369 -WebSocket-Versi
0x00f0: 6f6e 3a20 3133 0d0a 0d0a on:.13....
12:26:01.709521 IP localhost.ddi-tcp-1 > localhost.62857: Flags [.], ack 199, win 9174, options [nop,nop,TS val 354866120 ecr 354866120], length 0
0x0000: 4500 0034 91b1 4000 4006 0000 7f00 0001 E..4..@.@.......
0x0010: 7f00 0001 22b8 f589 93eb 9c65 860f f75b ...."......e...[
0x0020: 8010 23d6 fe28 0000 0101 080a 1526 d3c8 ..#..(.......&..
0x0030: 1526 d3c8 .&..
12:26:32.098343 IP localhost.ddi-tcp-1 > localhost.62857: Flags [F.], seq 1, ack 199, win 9174, options [nop,nop,TS val 354896377 ecr 354866120], length 0
0x0000: 4500 0034 9dcf 4000 4006 0000 7f00 0001 E..4..@.@.......
0x0010: 7f00 0001 22b8 f589 93eb 9c65 860f f75b ...."......e...[
0x0020: 8011 23d6 fe28 0000 0101 080a 1527 49f9 ..#..(.......'I.
0x0030: 1526 d3c8 .&..
12:26:32.098395 IP localhost.62857 > localhost.ddi-tcp-1: Flags [.], ack 2, win 9186, options [nop,nop,TS val 354896377 ecr 354896377], length 0
0x0000: 4500 0034 6ff5 4000 4006 0000 7f00 0001 E..4o.@.@.......
0x0010: 7f00 0001 f589 22b8 860f f75b 93eb 9c66 ......"....[...f
0x0020: 8010 23e2 fe28 0000 0101 080a 1527 49f9 ..#..(.......'I.
0x0030: 1527 49f9 .'I.
12:26:32.098407 IP localhost.ddi-tcp-1 > localhost.62857: Flags [.], ack 199, win 9174, options [nop,nop,TS val 354896377 ecr 354896377], length 0
0x0000: 4500 0034 f024 4000 4006 0000 7f00 0001 E..4.$@.@.......
0x0010: 7f00 0001 22b8 f589 93eb 9c66 860f f75b ...."......f...[
0x0020: 8010 23d6 fe28 0000 0101 080a 1527 49f9 ..#..(.......'I.
0x0030: 1527 49f9 .'I.
12:26:32.100281 IP localhost.62857 > localhost.ddi-tcp-1: Flags [F.], seq 199, ack 2, win 9186, options [nop,nop,TS val 354896378 ecr 354896377], length 0
0x0000: 4500 0034 5920 4000 4006 0000 7f00 0001 E..4Y.@.@.......
0x0010: 7f00 0001 f589 22b8 860f f75b 93eb 9c66 ......"....[...f
0x0020: 8011 23e2 fe28 0000 0101 080a 1527 49fa ..#..(.......'I.
0x0030: 1527 49f9 .'I.
12:26:32.100318 IP localhost.ddi-tcp-1 > localhost.62857: Flags [.], ack 200, win 9174, options [nop,nop,TS val 354896378 ecr 354896378], length 0
0x0000: 4500 0034 1161 4000 4006 0000 7f00 0001 E..4.a@.@.......
0x0010: 7f00 0001 22b8 f589 93eb 9c66 860f f75c ...."......f...\
0x0020: 8010 23d6 fe28 0000 0101 080a 1527 49fa ..#..(.......'I.
0x0030: 1527 49fa .'I.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment