Java Code Examples for reactor.netty.http.server.HttpServer#tcpConfiguration()

The following examples show how to use reactor.netty.http.server.HttpServer#tcpConfiguration() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RSocketNettyReactiveWebServerFactory.java    From spring-boot-rsocket with Apache License 2.0 6 votes vote down vote up
private HttpServer createHttpServer() {
	HttpServer server = HttpServer.create();
	if (this.resourceFactory != null) {
		LoopResources resources = this.resourceFactory.getLoopResources();
		Assert.notNull(resources,
				"No LoopResources: is ReactorResourceFactory not initialized yet?");
		server = server.tcpConfiguration((tcpServer) -> tcpServer.runOn(resources)
				.addressSupplier(this::getListenAddress));
	}
	else {
		server = server.tcpConfiguration(
				(tcpServer) -> tcpServer.addressSupplier(this::getListenAddress));
	}
	if (getSsl() != null && getSsl().isEnabled()) {
		SslServerCustomizer sslServerCustomizer = new SslServerCustomizer(getSsl(),
				getHttp2(), getSslStoreProvider());
		server = sslServerCustomizer.apply(server);
	}
	if (getCompression() != null && getCompression().getEnabled()) {
		CompressionCustomizer compressionCustomizer = new CompressionCustomizer(
				getCompression());
		server = compressionCustomizer.apply(server);
	}
	server = server.protocol(listProtocols()).forwarded(this.useForwardHeaders);
	return applyCustomizers(server);
}
 
Example 2
Source File: SoulNettyWebServerFactory.java    From soul with Apache License 2.0 5 votes vote down vote up
@Override
public HttpServer apply(final HttpServer httpServer) {
    return httpServer
            .tcpConfiguration(tcpServer -> tcpServer
                    .runOn(LoopResources.create("soul-netty", 1, DEFAULT_IO_WORKER_COUNT, true), false)
                    .selectorOption(ChannelOption.SO_REUSEADDR, true)
                    .selectorOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
                    .option(ChannelOption.TCP_NODELAY, true)
                    .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT));
}
 
Example 3
Source File: CustomNettyWebServerFactory.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public HttpServer apply(HttpServer httpServer) {
    EventLoopGroup parentGroup = new NioEventLoopGroup();
    EventLoopGroup childGroup = new NioEventLoopGroup();
    return httpServer
            .tcpConfiguration(tcpServer -> tcpServer.bootstrap(
                    serverBootstrap -> serverBootstrap.group(parentGroup, childGroup).channel(NioServerSocketChannel.class)
            ));
}