Reactor Netty not throwing any exception on connect failed
09:49 23 Dec 2025

Following code is not throwing ConnectException when No server is listening on the port 4444. It just exits the JVM.

public static void main(String a[]) {
        try {
            byte[] bytes = HexFormat.of().parseHex("001c30383030220000000000000030303030303031323233313531363133");
            Mono connection = TcpClient.create()
                    .host("127.0.0.1")
                    .port(4444)
                    .connect()
                    .doOnError(throwable -> throwable.printStackTrace())
                    .doOnError(Throwable.class, throwable -> throwable.printStackTrace());
            
            Mono mono = connection.flatMap(con -> {
                Mono send = con.outbound().sendByteArray(Mono.just(bytes)).then();
                Mono receive = con.inbound().receive() 
                        .asByteArray()
                        .next()
                        .doOnTerminate(con::dispose);
                return send.then(receive);
            });
            
            mono.subscribe(b -> System.out.println(HexFormat.of().formatHex(b)));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

Dependency

        
            io.projectreactor.netty
            reactor-netty-core
            1.3.1
        
netty reactor-netty