conqp / rcon

Python RCON client library
GNU General Public License v3.0
83 stars 15 forks source link

Rcon Error read length must be non-negative or -1 #10

Closed LeonNRL closed 2 years ago

LeonNRL commented 2 years ago

hey I have the following problem I wanted to write a simple script with which I can run things in rcon. I took the example templates and adapted them as I need them. I used this code to test if it works at all:

from rcon.source import Client

with Client('127.0.0.1', 30120, passwd='mysecretpassword') as client: response = client.run('kill', '2')

print(response)

and unfortunately I get this error:

Traceback (most recent call last): File "/home/os/os.py", line 4, in with Client('127.0.0.1', 30120, passwd='SECRET') as client: File "/usr/local/lib/python3.10/site-packages/rcon/client.py", line 31, in enter self.connect(login=True) File "/usr/local/lib/python3.10/site-packages/rcon/client.py", line 55, in connect self.login(self.passwd) File "/usr/local/lib/python3.10/site-packages/rcon/source/client.py", line 31, in login response = self. communicate(request) File "/usr/local/lib/python3.10/site-packages/rcon/source/client.py", line 21, in communicate return self.read() File "/usr/local/lib/python3.10/site-packages/rcon/source/client.py", line 26, in read return Packet.read(file) File "/usr/local/lib/python3.10/site-packages/rcon/source/proto.py", line 117, in read payload = file.read(size - 10) ValueError: read length must be non-negative or -1 Traceback (most recent call last):

I hope you can help me

have a nice evening

conqp commented 2 years ago

This appears to be an issue with the RCON server you contact, since it obviously does not return to you the correct packet size. Which RCON Server are you contacting?

LeonNRL commented 2 years ago

I'm trying to contact this server: 146.19.191.193:30120

that's why a FiveM server is running where RCON is activated

conqp commented 2 years ago

Some googling revealed, that FiveM uses the Quake3 RCON protocol, not the Source RCON protocol. I currently have no interest in implementing Quake3 RCON. I suggest you try another library such as https://github.com/bacher09/xrcon.