Limmek / MStats-for-rust

Logs player statistics and other server stuff to MySql
https://buymeacoffee.com/Limmek
5 stars 3 forks source link

charUnknownHigh errors with shit nicknames [like this - 𝔏𝔲𝔰𝔱𝔫𝔬𝔤 ] #21

Closed Mo45 closed 10 months ago

Mo45 commented 1 year ago
MySql handle raised an exception (ArgumentOutOfRangeException: Valid values are between 55296 and 56319, inclusive.
Parameter name: charUnknownHigh)
  at MySql.Data.MySqlClient.MySqlCommand.EndExecuteNonQuery (System.IAsyncResult asyncResult) [0x00022] in <8d7380b3d3cf4bd8be324c584f371b44>:0 
  at (wrapper remoting-invoke-with-check) MySql.Data.MySqlClient.MySqlCommand.EndExecuteNonQuery(System.IAsyncResult)
  at Oxide.Core.MySql.Libraries.MySql+MySqlQuery.Handle () [0x000f2] in <021a1dba6a754e42a6cc7771fdfee190>:0
Limmek commented 12 months ago

in the config file mstats.json change Charset from utf8 to utf8mb4. recreate database tables. if you dont want to lose any data you have to run a sql query to update the tables with a sql tool or how you now access your db.

Mo45 commented 12 months ago

Hello. Manually changed character set to utf8mb4 and collation to utf8mb4_unicode_ci for each table and for whole database. Changed utf8 to utf8mb4 in mstats.json, reloaded plugin.

Same error.

Limmek commented 12 months ago

Hmm i need to dig further into this. I can recreate the issue with the latest plugin source but if i change from utf8 to utf8mb4 the issue disappear and the data is inserted as is should.

🄽🄴🅈 has joined the server.

MySql handle raised an exception (MySqlException: Incorrect string value: '\xF0\x9F\x84\xBD\xF0\x9F...' for column 'player_name' at row 1) at MySql.Data.MySqlClient.MySqlCommand.EndExecuteNonQuery (System.IAsyncResult asyncResult) [0x00022] in <8d7380b3d3cf4bd8be324c584f371b44>:0 at (wrapper remoting-invoke-with-check) MySql.Data.MySqlClient.MySqlCommand.EndExecuteNonQuery(System.IAsyncResult) at Oxide.Core.MySql.Libraries.MySql+MySqlQuery.Handle () [0x000f2] in <021a1dba6a754e42a6cc7771fdfee190>:0

This is the query i used to get query's for all tables (Database name = s10_mstats). SELECT CONCAT('alter table ', table_name, ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;') FROM information_schema.tables WHERE table_schema='s10_mstats' AND table_collation != 'utf8mb4_unicode_ci' GROUP BY table_name;

And this is the output that i executed after.

ALTER TABLE admin_log CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE player_authorize_list CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE player_bullets_fired CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE player_chat_command CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE player_connect_log CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE player_crafted_item CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE player_death CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE player_destroy_building CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE player_kill CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE player_kill_animal CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE player_place_building CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE player_place_deployable CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE player_resource_gather CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE player_stats CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE server_log_airdrop CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE server_log_bradleyapc CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE server_log_cargoship CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE server_log_ch47 CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE server_log_chat CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE server_log_chat_team CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE server_log_console CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE server_log_patrolhelicopter CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Here is a image from SQLyog how it looks inside the table with a player who has a star in their name.

Limmek commented 12 months ago

Just out of curiosity what is your localization? You might want to use something other than utf8mb4 since i have used it for the EU standard.

Mo45 commented 12 months ago

Just out of curiosity what is your localization? You might want to use something other than utf8mb4 since i have used it for the EU standard.

I've develop some stats for Ukrainian Rust servers. And have some troubles with Cyrillic in chat logs and steam Usernames. But actually main problem are in special charsm not Cyrillic =)

Just used your query, and actually it show that i've already changed character set for all tables exept unused.

upd.

Maybe problem in character_set_server & collation_server settings.

Limmek commented 12 months ago

Yeah try to change the tables to.

I am using this docker image: mysql/mysql-server:8.0 and this is my output with command SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%'; image