use of reactor.netty.Connection in project reactor-netty by reactor.
the class BlockingConnectionTest method testTimeoutOnStop.
@Test
void testTimeoutOnStop() {
Connection c = new TestClientTransport(Mono.just(NEVER_STOP_CONTEXT)).connectNow();
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> c.disposeNow(Duration.ofMillis(100))).withMessage("Socket couldn't be stopped within 100ms");
}
use of reactor.netty.Connection in project reactor-netty by reactor.
the class ReactorNettyLoggingHandler method channelString.
private String channelString(Channel channel) {
String channelStr;
StringBuilder result;
Connection connection = Connection.from(channel);
if (connection instanceof ChannelOperationsId) {
channelStr = ((ChannelOperationsId) connection).asLongText();
if (channelStr.charAt(0) != TRACE_ID_PREFIX) {
result = new StringBuilder(1 + channelStr.length() + 1).append(CHANNEL_ID_PREFIX).append(channelStr).append(CHANNEL_ID_SUFFIX);
} else {
result = new StringBuilder(channelStr);
}
} else {
channelStr = channel.toString();
if (channelStr.charAt(0) == CHANNEL_ID_PREFIX) {
channelStr = channelStr.substring(ORIGINAL_CHANNEL_ID_PREFIX_LENGTH);
result = new StringBuilder(1 + channelStr.length()).append(CHANNEL_ID_PREFIX).append(channelStr);
} else {
int ind = channelStr.indexOf(ORIGINAL_CHANNEL_ID_PREFIX);
result = new StringBuilder(1 + (channelStr.length() - ORIGINAL_CHANNEL_ID_PREFIX_LENGTH)).append(channelStr.substring(0, ind)).append(CHANNEL_ID_PREFIX).append(channelStr.substring(ind + ORIGINAL_CHANNEL_ID_PREFIX_LENGTH));
}
}
return result.toString();
}
use of reactor.netty.Connection in project reactor-netty by reactor.
the class TcpClientTests method tcpClientHandlesLineFeedDataElasticPool.
@Test
void tcpClientHandlesLineFeedDataElasticPool() throws InterruptedException {
Consumer<? super Connection> channelInit = c -> c.addHandler("codec", new LineBasedFrameDecoder(8 * 1024));
tcpClientHandlesLineFeedData(TcpClient.create(ConnectionProvider.create("tcpClientHandlesLineFeedDataElasticPool", Integer.MAX_VALUE)).host("localhost").port(echoServerPort).doOnConnected(channelInit));
}
use of reactor.netty.Connection in project reactor-netty by reactor.
the class TcpClientTests method tcpClientHandlesLineFeedDataFixedPool.
@Test
void tcpClientHandlesLineFeedDataFixedPool() throws InterruptedException {
Consumer<? super Connection> channelInit = c -> c.addHandler("codec", new LineBasedFrameDecoder(8 * 1024));
ConnectionProvider p = ConnectionProvider.newConnection();
tcpClientHandlesLineFeedData(TcpClient.create(p).host("localhost").port(echoServerPort).doOnConnected(channelInit));
}
use of reactor.netty.Connection in project reactor-netty by reactor.
the class TcpClientTests method testReconnectWhenDisconnected.
@Test
void testReconnectWhenDisconnected() throws Exception {
DisposableServer server = TcpServer.create().port(0).wiretap(true).handle((req, res) -> res.sendString(Mono.just("test"))).bindNow();
final CountDownLatch latch = new CountDownLatch(1);
TcpClient client = TcpClient.create().port(echoServerPort).option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 100).handle((in, out) -> out.withConnection(Connection::dispose)).wiretap(true);
connect(client, true, latch);
assertThat(latch.await(30, TimeUnit.SECONDS)).as("latch await").isTrue();
server.disposeNow();
}
Aggregations