Multiple RSocket Server on Different Ports within same application

Hi,

How can I start multiple RSocket Server on different ports on same application with different acceptors like below?

Below is to Route Service Calls:

RSocketFactory
.receive()
.frameDecoder(PayloadDecoder.ZERO_COPY)
.acceptor((setupPayload, reactiveSocket) -> Mono.just(serviceRouter))
.transport(TcpServerTransport.create(“127.0.0.1”, 12001))
.start().log()
.block()
.onClose().block();

Below for Registering Routes:

RSocketFactory
.receive()
.frameDecoder(PayloadDecoder.ZERO_COPY)
.acceptor((setupPayload, reactiveSocket) -> Mono.just(serviceRegistry))
.transport(TcpServerTransport.create(“localhost”, 11402))
.start().log()
.block()
.onClose().block();

Please let me know what I am doing wrong?

Regards
Karthik

Most likely the first server is blocking so the second server can’t start. You can try something like this:

Mono<Void> m1 = RSocketFactory
                        .receive()
                        .frameDecoder(PayloadDecoder.ZERO_COPY)
                        .acceptor((setupPayload, reactiveSocket) -> Mono.just(serviceRouter))
                        .transport(TcpServerTransport.create("127.0.0.1", 12001))
                        .start().log()
                        .block()
                        .onClose();
  
  
Mono<Void> m2 = RSocketFactory
                         .receive()
                         .frameDecoder(PayloadDecoder.ZERO_COPY)
                         .acceptor((setupPayload, reactiveSocket) -> Mono.just(serviceRegistry))
                         .transport(TcpServerTransport.create("localhost", 11402))
                         .start().log()
                         .block()
                         .onClose();

Flux.merge(m1, m2).blockLast();

Thank You @robertroeser, it worked.