Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection closed when connecting to Galaxite #244

Open
alvin0319 opened this issue Jul 13, 2024 · 0 comments
Open

Connection closed when connecting to Galaxite #244

alvin0319 opened this issue Jul 13, 2024 · 0 comments

Comments

@alvin0319
Copy link
Contributor

I'm not sure if it's raknet side problem, but I'll be posting here since I'm not sure. Please transfer issue if it isn't belong to here.

[10:33:20.073] [nioEventLoopGroup-3-1/INFO ] - Received packet NetworkSettingsPacket
[10:33:20.075] [nioEventLoopGroup-3-1/INFO ] - Compression algorithm picked: ZLIB
[10:33:20.191] [nioEventLoopGroup-3-1/INFO ] - Sent login packet
[10:33:20.841] [nioEventLoopGroup-3-1/WARN ] - Tried to close peer, but channel is open!
java.lang.Throwable: null
	at org.cloudburstmc.protocol.bedrock.BedrockPeer.onClose(BedrockPeer.java:190)
	at org.cloudburstmc.protocol.bedrock.BedrockPeer.channelInactive(BedrockPeer.java:250)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:305)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1405)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:301)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281)
	at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:901)
	at org.cloudburstmc.netty.handler.codec.raknet.ProxyInboundRouter.channelInactive(ProxyInboundRouter.java:56)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:305)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274)
	at org.cloudburstmc.netty.handler.codec.raknet.common.DisconnectNotificationHandler.channelRead0(DisconnectNotificationHandler.java:54)
	at org.cloudburstmc.netty.handler.codec.raknet.common.DisconnectNotificationHandler.channelRead0(DisconnectNotificationHandler.java:29)
	at org.cloudburstmc.netty.handler.codec.raknet.AdvancedChannelInboundHandler.channelRead(AdvancedChannelInboundHandler.java:45)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at org.cloudburstmc.netty.handler.codec.raknet.AdvancedChannelInboundHandler.channelRead(AdvancedChannelInboundHandler.java:48)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at org.cloudburstmc.netty.handler.codec.raknet.AdvancedChannelInboundHandler.channelRead(AdvancedChannelInboundHandler.java:48)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at org.cloudburstmc.netty.handler.codec.raknet.common.RakSessionCodec.onOrderedReceived(RakSessionCodec.java:353)
	at org.cloudburstmc.netty.handler.codec.raknet.common.RakSessionCodec.checkForOrdered(RakSessionCodec.java:334)
	at org.cloudburstmc.netty.handler.codec.raknet.common.RakSessionCodec.handleDatagram(RakSessionCodec.java:327)
	at org.cloudburstmc.netty.handler.codec.raknet.common.RakSessionCodec.channelRead(RakSessionCodec.java:218)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:102)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
	at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at org.cloudburstmc.netty.handler.codec.raknet.AdvancedChannelInboundHandler.channelRead(AdvancedChannelInboundHandler.java:48)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at org.cloudburstmc.netty.handler.codec.raknet.client.RakClientProxyRouteHandler.channelRead(RakClientProxyRouteHandler.java:50)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.nio.AbstractNioMessageChannel$NioMessageUnsafe.read(AbstractNioMessageChannel.java:97)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:1583)
[10:33:30.852] [nioEventLoopGroup-3-1/INFO ] - Disconnected from play.galaxite.net/51.89.235.138:19132: disconnect.timeout
[10:33:30.852] [nioEventLoopGroup-3-1/INFO ] - Disconnected: disconnect.timeout

After sending LoginPacket, my client seems unable to decode packets sent by Galaxite. This is only problem with Galaxite, not with other servers.

Here is how I connect to a server:

fun main() {
    account = AuthUtil.getAuthenticatedAccount(true)
    val logger = LoggerFactory.getLogger("main")
    newClient(InetSocketAddress("play.galaxite.net", 19132)) { client ->
        client.disconnectHandler = { reason ->
            logger.info("Disconnected: $reason")
        }
    }
}

fun newClient(
    address: InetSocketAddress,
    codec: BedrockCodec = DEFAULT_CODEC,
    handler: (BedrockClient) -> Unit
) {
    Bootstrap()
        .channelFactory(RakChannelFactory.client(NioDatagramChannel::class.java))
        .group(NioEventLoopGroup())
        .option(RakChannelOption.RAK_PROTOCOL_VERSION, codec.raknetProtocolVersion)
        .option(RakChannelOption.RAK_ORDERING_CHANNELS, 1)
        .option(RakChannelOption.RAK_SESSION_TIMEOUT, 1000 * 10L) // 10 sec
        .option(RakChannelOption.RAK_CONNECT_TIMEOUT, 1000 * 10L) // 10 sec
        .handler(object : BedrockClientInitializer() {
            override fun createSession0(peer: BedrockPeer, subClientId: Int): BedrockClientSession {
                return BedrockClientSession1(peer, subClientId)
            }

            override fun initSession(session: BedrockClientSession) {
                session.codec = codec
                session.peer.codecHelper.encodingSettings = EncodingSettings.UNLIMITED
                val client = BedrockClient(
                    address,
                    codec,
                    session
                )
                session.packetHandler = SessionPacketHandler(account, client, session)
                handler(client)
            }
        })
        .connect(address)
        .syncUninterruptibly()
}

If you need any code, let me know. I'll be happy providing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant