use of reactor.netty.Connection in project reactor-netty by reactor.
the class Application method main.
public static void main(String[] args) {
ConnectionProvider provider = ConnectionProvider.builder("fixed").maxConnections(50).metrics(// <1>
true).build();
Connection connection = TcpClient.create(provider).host("example.com").port(80).connectNow();
connection.onDispose().block();
}
use of reactor.netty.Connection in project reactor-netty by reactor.
the class Application method main.
public static void main(String[] args) {
Connection connection = TcpClient.create().host("example.com").port(80).resolver(// <1>
DefaultAddressResolverGroup.INSTANCE).connectNow();
connection.onDispose().block();
}
use of reactor.netty.Connection in project reactor-netty by reactor.
the class Application method main.
public static void main(String[] args) {
Connection connection = TcpClient.create().host("example.com").port(80).handle(// <1>
(inbound, outbound) -> outbound.sendString(Mono.just("hello"))).connectNow();
connection.onDispose().block();
}
use of reactor.netty.Connection in project reactor-netty by reactor.
the class HttpServerTests method doTestDecodingFailureLastHttpContent.
private void doTestDecodingFailureLastHttpContent(String message, String... expectations) throws Exception {
TcpClient tcpClient = TcpClient.create().port(disposableServer.port()).wiretap(true);
Connection connection = tcpClient.connectNow();
CountDownLatch latch = new CountDownLatch(1);
connection.channel().closeFuture().addListener(f -> latch.countDown());
AtomicReference<String> result = new AtomicReference<>();
connection.inbound().receive().asString().doOnNext(result::set).subscribe();
connection.outbound().sendString(Mono.just(message)).then().subscribe();
assertThat(latch.await(30, TimeUnit.SECONDS)).isTrue();
assertThat(result.get()).contains(expectations);
assertThat(connection.channel().isActive()).isFalse();
}
use of reactor.netty.Connection in project reactor-netty by reactor.
the class HttpServerTests method doTest.
private void doTest(int port, String message) throws Exception {
TcpClient tcpClient = TcpClient.create().port(port).wiretap(true);
Connection connection = tcpClient.connectNow();
CountDownLatch latch = new CountDownLatch(2);
connection.channel().closeFuture().addListener(f -> latch.countDown());
AtomicReference<String> result = new AtomicReference<>();
connection.inbound().receive().asString().doOnNext(s -> {
result.set(s);
latch.countDown();
}).subscribe();
connection.outbound().sendString(Mono.just(message)).then().subscribe();
assertThat(latch.await(30, TimeUnit.SECONDS)).isTrue();
assertThat(result.get()).contains("test", "connection: close");
assertThat(connection.channel().isActive()).isFalse();
}
Aggregations