Sch8ill / mcclient-lib

A lightweight Minecraft client for querying the status data of a Minecraft server
MIT License
17 stars 2 forks source link

Run error #20

Closed xzfg-n15421 closed 2 weeks ago

xzfg-n15421 commented 1 month ago

Traceback (most recent call last): File "c:\Users\Administrator\Desktop\feature-cpp\1.py", line 5, in res = slp_client.get_status() ^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\mcclient\slp.py", line 17, in get_status
res = self._status_request() ^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\mcclient\slp.py", line 29, in _status_request res_dict = json.loads(res_str) ^^^^^^^^^^^^^^^^^^^ File "c:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\json__init__.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py", line 340, in decode raise JSONDecodeError("Extra data", s, end) json.decoder.JSONDecodeError: Extra data: line 1 column 10 (char 9)

Sch8ill commented 1 month ago

@xzfg-n15421 It seems that the mcclient-lib is having trouble parsing the JSON response from the SLP request. This issue occurs when the JSON response is not in the expected format. There could be several reasons for this:

Server Version: The server might be running a version that's incompatible with the client library. Could you provide details on the server version you're using?

Inconsistent Occurrence: If this error doesn't happen consistently, it could be due to intermittent issues like packet loss or an unstable network connection.

Response Format: If the server's response includes unexpected or extra data, it can cause the JSON parser to fail. This might be due to server-side modifications or a bug.

Could you share more details on the server setup and whether this error occurs every time you run the code?

xzfg-n15421 commented 3 weeks ago

The following is from machine translation. I tried to output res_str, and found that there was an incorrect character (possibly 0×00, not verified) before the json string. Finally, I changed ´res_data = res[2:]´ to ´res_data = res[3:]´.(all from slp.py) It is worth noting that this problem may only exist on the remote server, or it can only be triggered on the forge server, and my local paper server can recognize it normally.

xzfg-n15421 commented 3 weeks ago

I didn't read wiki.vg document yet,MAYBE forge return TOO many data?

Sch8ill commented 3 weeks ago

@xzfg-n15421 It seems like the current implementation can't handle responses that large. I'm currently working on a fix for that though. A new fixed version should be release within the next few days.

Sch8ill commented 2 weeks ago

@xzfg-n15421 I just released version 1.2.0, which includes a new packet decoding class to address your issue. This should resolve the problem with handling large responses. Thank you for your patience, and feel free to test the new release!