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();