ProtocolLib

3M Downloads

PacketListening to KEEP_ALIVE packet and PONG packet not working in 1.20.2

Waterman1001 opened this issue ยท 10 comments

commented
  • This issue is not solved in a development build

Describe the bug

I try to listen to PacketType.Play.Client.KEEP_ALIVE packets using a PacketAdapter, but it seems to not work or fire in 1.20.2.
I am trying based on broadcasting a message for testing purposes.
First, I checked with Paper 1.20.1, which works greatly! It properly sends the broadcast in chat.
Then, I checked with Paper 1.20.2, and it does not work anymore.
I am using the latest Development Build for 1.20.2 (Build 699), also as a dependency in my plugin as well as in my server.

I am using the following code:

ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
        protocolManager.addPacketListener(
                new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.KEEP_ALIVE) {
                    @Override
                    public void onPacketReceiving(PacketEvent event) {
                        Bukkit.broadcastMessage("Hi");
                    }
                }
        );

The same thing holds for the PacketType.Play.Client.PONG packet listening.
I am sending a custom PING packet, which does properly send, because I checked by printing the packet in console:

PacketContainer packet = pm.createPacket(PacketType.Play.Server.PING);
pm.sendServerPacket(p, packet);

However, the listener for PONG packet is not firing.

Finally, I also tried to change the listener to PacketType.Play.Server.CHAT and then it actually does work!
So it is not a misconfiguration / registration of my listener either.

Expected behavior

I expected a broadcast saying 'Hi' in the server every once in a while when KEEP ALIVE or PONG packet is being received, just like is happening in 1.20.1.

I did completely restart (so not reload) the server everytime for testing.

Version Info
https://pastebin.com/PhZqV8ba

Additional context
I would really appreciate it if someone could thoroughly look at this issue ๐Ÿ˜Š
Thank you so much for your help and hard work already!

commented

Update: Seems to work again using your build! Thanks!!

commented

Can you try with this version https://github.com/derklaro/ProtocolLib/suites/17153635831/artifacts/980026562 and check if the issue is still there?

Also just want to point out that the PING and PONG packet types exists (and the associated packets), but those are not send by the server. You probably want to listen to KEEP_ALIVE (from and to client).

commented

Thank you! I will check this version ๐Ÿ˜„
Also, I am aware that the server does not send those, so I let the server send a Ping packet via Protocollib by building it myself with a specific ID. Then, I wanted to listen to the Pong packet, but it was not received in the latest version anymore. This way, I was calculating how long it took until a client responded and measured the timeinmillis difference to find out about their Ping.
I will check this new build and come back to you, thank you so much!

commented

@derklaro Pasqual, since you updated Protocollib to 1.20.2 and seem to understand how things work (haha, I really have no clue sorry ๐Ÿ˜…), would you perhaps have any idea on how to resolve this issue?
I am sorry for tagging you! I'm just hoping someone is willing to try and look into this issue. ๐Ÿ˜Š
You seem to be the person/expert to try and ask, and I thought, it's worth a shot right? ;)

commented

Yea I saw this issue, but I had no time yet to look into this problem. Will come back to this asap

commented

Ah, thank you a lot for the quick reply! It would be highly appreciated ๐Ÿ˜Š

commented

Can you try to listen to the packet type in a different protocol phase and see if the packet listener still triggers in that case in PLAY? I might know the issue already ๐Ÿ˜„

So can you try to listen to PacketType.Configuration/PacketType.Login instead of PacketType.Play.Server.KEEP_ALIVE and see if your debug message is printed?

commented

I just tried, and yes! Listening to PacketType.Configuration.Client.KEEP_ALIVE does work, and also it keeps printing my debug message during PLAY.
Wow! ๐Ÿ˜„

commented

Nice, will take a look into fixing the issue later then ๐Ÿ‘

commented

Yes, thank you for your quick replies :)
Have a nice week!