Skip to content

Commit

Permalink
RSocketDslTests: Resolve server port eagerly
Browse files Browse the repository at this point in the history
Looks like there is some connection race condition in Netty on Linux,
so we may not be started on server side fully when we try to select a
port from the OS

* Move local port resolution and, therefore, RSocket server start into
the earlier phase before creating a client
  • Loading branch information
artembilan committed Jun 27, 2019
1 parent 7795496 commit 0675fdf
Showing 1 changed file with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,9 @@
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;

import io.netty.buffer.PooledByteBufAllocator;
import io.netty.util.NetUtil;
import io.rsocket.frame.decoder.PayloadDecoder;
import io.rsocket.transport.netty.client.TcpClientTransport;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.netty.tcp.InetSocketAddressUtil;
import reactor.netty.tcp.TcpClient;

/**
* @author Artem Bilan
Expand Down Expand Up @@ -87,18 +83,10 @@ public ServerRSocketConnector serverRSocketConnector() {
return serverRSocketConnector;
}


@Bean
public ClientRSocketConnector clientRSocketConnector(ServerRSocketConnector serverRSocketConnector) {
ClientRSocketConnector clientRSocketConnector =
new ClientRSocketConnector(
TcpClientTransport.create(
TcpClient.create()
.addressSupplier(() ->
InetSocketAddressUtil.createUnresolved(
NetUtil.LOCALHOST.getHostAddress(),
serverRSocketConnector.getBoundPort().block()))
));
int port = serverRSocketConnector.getBoundPort().block();
ClientRSocketConnector clientRSocketConnector = new ClientRSocketConnector("localhost", port);
clientRSocketConnector.setFactoryConfigurer((factory) -> factory.frameDecoder(PayloadDecoder.ZERO_COPY));
clientRSocketConnector.setRSocketStrategies(rsocketStrategies());
clientRSocketConnector.setAutoStartup(false);
Expand Down

0 comments on commit 0675fdf

Please sign in to comment.