运行 Netty 和 tomcat 在同一端口上,但在单个服务器中的 ip 不同(Netty 在本地主机上打开)
Run Netty and tomcat on same port but different ip in a single server (Netty opens at localhost)
有一个有 2 个 IP 地址的服务器(假设 1.1.1.a 和 1.1.1.b)
尝试配置使用 netty 的 jar,以便它在 443 端口创建 WebSocket。该服务器还托管一个使用 443 的 tomcat。
现在尝试将 netty 配置为 1.1.1.a:443 和 tomcat 到 1.1.1.b:443.
ServerBootstrap b = new ServerBootstrap();
b.option(ChannelOption.SO_BACKLOG, 1024);
b.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.localAddress(new InetSocketAddress("1.1.1.a", 443))
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(new HTTPInitializer());
channel = b.bind(443).sync().channel();
但是,netty 仍然试图从 0.0.0.0:443 开始,导致绑定异常。
是否可以以这种方式配置?如果是,应该怎么办?
当然...只需使用bind(new InetSocketAddress("1.1.1.a",443)
有一个有 2 个 IP 地址的服务器(假设 1.1.1.a 和 1.1.1.b) 尝试配置使用 netty 的 jar,以便它在 443 端口创建 WebSocket。该服务器还托管一个使用 443 的 tomcat。 现在尝试将 netty 配置为 1.1.1.a:443 和 tomcat 到 1.1.1.b:443.
ServerBootstrap b = new ServerBootstrap();
b.option(ChannelOption.SO_BACKLOG, 1024);
b.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.localAddress(new InetSocketAddress("1.1.1.a", 443))
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(new HTTPInitializer());
channel = b.bind(443).sync().channel();
但是,netty 仍然试图从 0.0.0.0:443 开始,导致绑定异常。 是否可以以这种方式配置?如果是,应该怎么办?
当然...只需使用bind(new InetSocketAddress("1.1.1.a",443)