palworldlol / palworld-exporter

Prometheus metrics exporter for Palword Server
https://palworld.lol
MIT License
17 stars 1 forks source link

Non-ascii player name causes RCON `showplayers` break #4

Closed sh-cho closed 9 months ago

sh-cho commented 9 months ago

Problem

In Source RCON protocol, packet body is defined as Null-terminated ASCII String. But we can set palworld player name as non-ascii characters(ex. Korean, Chinese, Cyrillic, ...) and this sets showplayers response packet body as non-ascii character, finally RCON client is failed or stuck.

Similar issues:

I think this should be mainly handled by RCON client.

But it looks like exporter's polling is somewhat problematic.

Screenshot 2024-02-04 at 9 13 18 PM

This is timeline of my server when non-ascii name user joined. After user joined, somehow player count is keep exported(which is outdated) and players info is not exported. (2~3 persons playing in the server at the time)

Suggestion

bostrt commented 9 months ago

Thanks for this report, this is great. I really want to disable polling and will look into that.

As for testing with non-ascii I will have to look into that some more. I'm not sure about support by various libraries either.

bostrt commented 9 months ago

It looks like non-ascii character support is a problem to be resolved in Palworld itself. https://github.com/gorcon/rcon-cli/issues/35

I will continue looking for workarounds in the meantime.

Do you know of any other tools/libraries (non-python) that work fine?

bostrt commented 9 months ago

I'm leaving this error here for reference. When a Player has a name using non-ascii, it results in this error:

2024-02-04:15:41:40.936 ERROR    [exporter.py:97] Received few bytes!

The best I can tell is, Palworld's RCON implementation is truncating the player names or ends of the string for some reason when they have non-ascii characters which results in the "Received [too] few bytes". The size of the ShowPlayers response must be calculated before they are sent across the wire.

sh-cho commented 9 months ago

Thanks for the check! I haven't tested any other rcon library, but even though some library can handle non-ascii chars, player id will be trimmed, so.. looks like it's best to wait palworld patch ...

bostrt commented 9 months ago

I still plan on disabling polling as requested in this issue. Should have that ready today or tomorrow.

bostrt commented 9 months ago

Polling/caching is no longer used as of v1.1.0 https://github.com/palworldlol/palworld-exporter/releases/tag/v1.1.0