conqp / rcon

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

Exception in thread Thread-X/ValueError: 8 is not a valid Type #34

Open nickplj12 opened 4 months ago

nickplj12 commented 4 months ago

Me and a friend made a Python program made for Team Fortress 2 that lets people generate AI responses from chat by reading your console.log file. The program works fine for him but on my computer it outputs this error. We think it may have something to do with multithreading? Will give specs if needed..

Here is the output it gave me:

C:\Users\nickp\OneDrive\Desktop\code\tf2gpt>py app/app.py
Virtual Audio Cable found. vb commands enabled!
Exception in thread Thread-2 (run_rcon_try_thread):
Exception in thread Thread-3 (run_rcon_ping_thread):
Exception in thread Traceback (most recent call last):
Thread-1 (run_rcon_thread)  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
Traceback (most recent call last):
:
  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
Traceback (most recent call last):
  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
 * Serving Flask app 'app'
 * Debug mode: off
    self.run()
    self.run()    self.run()
  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1010, in run

  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)

  File "C:\Users\nickp\OneDrive\Desktop\code\tf2gpt\app\app.py", line 342, in run_rcon_ping_thread
  File "C:\Users\nickp\OneDrive\Desktop\code\tf2gpt\app\app.py", line 322, in run_rcon_try_thread
    self._target(*self._args, **self._kwargs)
        with Client(SELF_ADDRESS, SELF_PORT, passwd=config.data["password"]) as try_client:
  File "C:\Users\nickp\OneDrive\Desktop\code\tf2gpt\app\app.py", line 290, in run_rcon_thread
with Client(SELF_ADDRESS, SELF_PORT, passwd=config.data["password"]) as ping_client:
  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\client.py", line 34, in __enter__
  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\client.py", line 34, in __enter__
    with Client(SELF_ADDRESS, SELF_PORT, passwd=config.data["password"]) as client:
  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\client.py", line 34, in __enter__
        self.connect(login=True)
self.connect(login=True)
  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\client.py", line 58, in connect
  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\client.py", line 58, in connect
    self.connect(login=True)
    self.login(self.passwd)  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\client.py", line 58, in connect
    self.login(self.passwd)
    self.login(self.passwd)  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\source\client.py", line 59, in login

  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\source\client.py", line 59, in login
  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\source\client.py", line 59, in login
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5000
Press CTRL+C to quit
    while (response := self.read()).type != Type.SERVERDATA_AUTH_RESPONSE:
        while (response := self.read()).type != Type.SERVERDATA_AUTH_RESPONSE:  while (response := self.read()).type != Type.SERVERDATA_AUTH_RESPONSE:

                                               ^^ ^ ^^^^^^ ^ ^ ^ ^ ^^
^^ ^^  ^^ ^    File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\source\client.py", line 41, in read

    File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\source\client.py", line 41, in read
    response = Packet.read(file) ^
^^ ^    response = Packet.read(file)^
^ ^^    ^ ^ ^
    File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\source\client.py", line 41, in read
                 ^^ ^ ^ ^^^^^^^^^^^^^^^^^^^^^response = Packet.read(file)^^^^
^^^
 ^^    File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\source\proto.py", line 156, in read

          ^^^^^^^^^^^^^^^^^
  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\source\proto.py", line 156, in read
  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\source\proto.py", line 156, in read
    type_ = Type.read(file, prefix="  ")
    type_ = Type.read(file, prefix="  ")
        type_ = Type.read(file, prefix="  ")
         ^    ^^ ^^ ^ ^^  ^^   ^   ^ ^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\source\proto.py", line 79, in read

    ^^return cls(value)  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\source\proto.py", line 79, in read

    File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\site-packages\rcon\source\proto.py", line 79, in read
        return cls(value)
     return cls(value)
              ^  ^ ^ ^^  ^^^^ ^ ^ ^
^^    File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\enum.py", line 757, in __call__
^^^^^^
 ^^^^^  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\enum.py", line 757, in __call__
^^^^^
  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\enum.py", line 757, in __call__
    return cls.__new__(cls, value)
    return cls.__new__(cls, value)
          return cls.__new__(cls, value)    ^^^^^^^
^^^^ ^^^^^^^^^^^^ ^ ^ ^ ^ ^^^^^ ^ ^ ^ ^ ^^^^^^^^^^^^^
^^^  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\enum.py", line 1171, in __new__
^^^    raise ve_exc^^

^^  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\enum.py", line 1171, in __new__
ValueError: 8 is not a valid Type
^^    raise ve_exc^^^^^^
^ValueError: ^
8 is not a valid Type
  File "C:\Users\nickp\AppData\Local\Programs\Python\Python312\Lib\enum.py", line 1171, in __new__
    raise ve_exc
ValueError: 8 is not a valid Type
conqp commented 1 month ago

Maybe this is related to https://github.com/conqp/rcon/issues/35

I'd need a raw dump of the server's response to investigate further.

Also note, that indeed, the RCON client is not thread-safe. If you want to use the same client from within different threads, you must implement a locking mechanism.