0
我试图在Spigot服务器上启动外部Netty服务器。如何在Spigot服务器上启动外部Netty服务器
我试过的唯一的事情是我在开始时就启动它,但问题是用户无法加入并且服务器超时。
这是Netty客户端的代码,它应该连接到运行良好的Netty服务器。
EventLoopGroup eventLoopGroup = EPOLL ? new EpollEventLoopGroup() : new NioEventLoopGroup();
try {
Bootstrap bootstrap = new Bootstrap()
.group(eventLoopGroup)
.option(ChannelOption.TCP_NODELAY, true)
.option(ChannelOption.SO_KEEPALIVE, true)
.channel(EPOLL ? EpollSocketChannel.class : NioSocketChannel.class)
.handler(new ChannelInitializer<Channel>() {
protected void initChannel(Channel channel) throws Exception {
preparePipeline(channel);
}
});
ChannelFuture f = bootstrap.connect(
ReplaySpigotServer.getConnection().configuration.getString("server-host"),
ReplaySpigotServer.getConnection().configuration.getInt("server-port"))
.sync();
f.channel().closeFuture().sync();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
eventLoopGroup.shutdownGracefully();