Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-268727

Server disconnects the client when sending a keepalive packet while transitioning out of configuration phase

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 24w14a
    • 24w07a
    • None
    • Plausible
    • Networking
    • Important
    • Platform

      Hello, there is a tricky race condition in the latest snapshot, due to the server-side handling of `ServerboundFinishConfigurationPacket`. The packet is terminal, which causes the connection to become unbound immediately when it is received. It is then queued for processing on the main thread, which will eventually setup the outbound GAME protocol. In the meanwhile, it can happen that a keep alive packet is sent to the client, causing an immediate disconnection due to

      Exception caught in connection
      io.netty.handler.codec.EncoderException: Pipeline has no outbound protocol configured, can't process packet net.minecraft.network.protocol.common.ClientboundKeepAlivePacket@611a8815 

      For a more step-by-step explanation of the issue:

      • server receives ServerboundFinishConfigurationPacket on the netty thread and immediately disables its outbound protocol
      • netty thread calls handleConfigurationFinished, which enqueues itself for processing on the main thread
      • if unlucky: the main thread sends a ClientboundKeepAlivePacket
      • then the main executor would normally process handleConfigurationFinished and configure the protocol, but it's too late - the packet is already sent

      The issue can be reproduced by adding the following code at the end of JoinWorldTask#start:

      try {
          Thread.sleep(15000);
      } catch (InterruptedException e) {
          throw new RuntimeException(e);
      } 

      I have created a 24w07a Fabric mod that does exactly this, you can find it at https://github.com/Technici4n/MC-268727-repro.

            timurn [Mojang] Timur Nazarov
            Technici4n Technici4n
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: