games647 / FastLogin

Checks if a minecraft player has a valid paid account. If so, they can skip offline authentication automatically. (premium auto login)
https://www.spigotmc.org/resources/fastlogin.14153
MIT License
492 stars 120 forks source link

"Can't serialize unregistered packet" with ViaVersion and BungeeCord #1166

Closed Maxi451 closed 3 months ago

Maxi451 commented 5 months ago

What happened?

Trying to log in with a 1.20.4 premium vanilla client to a 1.12.2 PaperSpigot server causes to be disconnected with error "Internal Exception: io.netty.handler.codec.EncoderException: java.io.IOException: Can't serialize unregistered packet"

What did you expect?

I expected the 1.20.2+ premium client to be sent to the "hub" server without any issue

Steps to reproduce

Server setup:

Latest version BungeeCord (git:BungeeCord-Bootstrap:1.20-R0.3-SNAPSHOT:7606d44:1801) with the following plugins:

"login" server: PaperSpigot 1.12.2 with the following plugins:

"hub" server: PaperSpigot 1.12.2 with the following plugins:

Clients below 1.20.2 don't seem to experience any issue Steps:

If I remove FastLogin these errors disappear This error seems to appear when a 1.20.2+ player switches server to an older version, and seems to be some sort of malformed json (maybe 1.20.2+ players have issues with jsons starting with square brackets). Also, a friend of mine with the same client experiences this issue a lot less

Plugin list

No response

Configuration file

https://pastebin.com/ygXqyZDi

Server log

Bungee:

23:48:19 [INFO] [/-] <-> InitialHandler has pinged 23:48:20 [INFO] [TheSniper99,/-] <-> InitialHandler has connected 23:48:20 [INFO] [FastLogin] Incoming login request for TheSniper99 from /- 23:48:20 [INFO] [FastLogin] Handling player TheSniper99 23:48:20 [INFO] [FastLogin] Requesting premium login for registered player: TheSniper99 23:48:20 [INFO] [TheSniper99] <-> ServerConnector [login] has connected 23:48:21 [INFO] [TheSniper99] <-> ServerConnector [hub] has connected 23:48:21 [INFO] [TheSniper99] <-> DownstreamBridge <-> [login] has disconnected 23:48:22 [INFO] [TheSniper99] -> UpstreamBridge has disconnected 23:48:22 [INFO] [TheSniper99] <-> DownstreamBridge <-> [hub] has disconnected

Login:

[23:48:20 INFO]: UUID of player TheSniper99 is 7ae4946c-10a4-47ff-b173-2cb4a19c87f8 [23:48:20 INFO]: TheSniper99[/-] logged in with entity id 5 at ([world]0.5, 100.0, 0.5) [23:48:20 INFO]: [AuthMe] TheSniper99 logged in - [23:48:21 INFO]: [FastLogin] Player info LOGIN command for TheSniper99 from proxy [23:48:21 INFO]: [FastLogin] Delaying force login until join event fired?: false [23:48:21 INFO]: [FastLogin] Logging player TheSniper99 in [23:48:21 WARN]: [FastLogin] Player CraftPlayer{name=TheSniper99} is already authenticated. Cancelling force login. [23:48:21 INFO]: TheSniper99 lost connection: Disconnected

Hub:

[23:48:21 INFO]: UUID of player TheSniper99 is 7ae4946c-10a4-47ff-b173-2cb4a19c87f8 [23:48:21 INFO]: TheSniper99[/-] logged in with entity id 3 at ([hub]0.5, 160.0, 0.5) [23:48:22 INFO]: [FastLogin] No on-going login session for player: CraftPlayer{name=TheSniper99} with ID -. [23:48:22 INFO]: [FastLogin] Setups using Minecraft proxies will start delayed when the command from the proxy is received [23:48:22 INFO]: TheSniper99 lost connection: Disconnected [23:48:22 INFO]: TheSniper99 left the game

Plugin version

1.12-SNAPSHOT-a65a5f3

Platform

BungeeCord

Relevance

games647 commented 5 months ago

That's interesting, because in proxy environments FastLogin doesn't do any packet manipulations like in Spigot. Could you try to reproduce it without Via?

Maxi451 commented 5 months ago

How may I join a 1.12.2 server without viaversion with a 1.20.4 client?

games647 commented 5 months ago

Sorry, my bad; too many version numbers. However, FastLogin still doesn't do many modifications with BungeeCord. Therefore it could be related solely to be the onlinemode.

Could you try it without FastLogin, but with onlinemode enabled? A local copy might be necessary to prevent UUID changes conversations depending on your plugins. Then also the full exception for Can't serialize unregistered packet from the client logs could be useful, so we could check which packet ID is the issue here. Nevertheless, your descriptions seems to indicate a missing translation by Via* for newer clients.

Maxi451 commented 5 months ago

I tried with onlinemode and logged in successfully, so somehow something's actually interfering with FastLogin. Sadly there isn't much in the client log, just this line: [18:52:23] [Render thread/WARN]: Client disconnected with reason: Internal Exception: io.netty.handler.codec.EncoderException: java.io.IOException: Can't serialize unregistered packet it's almost like the server disconnected the client with a Disconnect packet instead of simply the client crashing. Nothing new in the server's logs

games647 commented 5 months ago

[18:52:23] [Render thread/WARN]: Client disconnected with reason: Internal Exception: io.netty.handler.codec.EncoderException: java.io.IOException: Can't serialize unregistered packet

The EncoderException indicates that the packet sender terminated the connection, because it couldn't package the data. In this case it could be both BungeeCord (re-packing) or Spigot if ViaVersion didn't modified the sending process correctly.

Is the log about the second case from the first post or the third with exception message? We could also try to deactivate AuthMe's session logins to prevent conflicts with the Already authenticated error.

Furthermore, AuthMe also sends packets, but this feature is only active if ProtocolLib is enabled. Is ProtocolLib installed and do you know if there any other plugins that perform network packet manipulations?

Regarding local testing: Correct me if I'm wrong, but to reproduce this only ViaVersion from Via-* set is necessary. So connecting to an older server with a newer client.

Sorry for so many questions.

Maxi451 commented 5 months ago

So, after many tries I found what is wrong: there's an option in the authme's config.yml file, settings.sessions.enabled, which if set to true will cause 1.20.2+ clients to disconnect in the environment I specified above. Setting it to false will resolve this issue. If I remove fastlogin this issue disappears, so I guess there's something going on between authme and fastlogin on this. It solved the "already authenticated" error too. Anyway, thank you for your time, I will just set it to false

games647 commented 5 months ago

That sounds great, thanks for letting me know. That seems to indicate a race condition in AuthMe code base, like multiple authentication requests at once.