metalfiiish / ts-gw2-verifyBot

A python bot that will sit in a Teamspeak3 channel and take commands. It's main purpose was to verify server players for Guild Wars 2 and automatically authenticate and give them the proper Group for permissions to speak/etc in Teamspeak.
MIT License
7 stars 7 forks source link

Connection Timing Out Regularly #10

Open ogrady opened 5 years ago

ogrady commented 5 years ago

I have now for a while tried to battle the timeouts on the bot.

BOT now idle, waiting for requests.
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ts3bot/.local/lib/python3.6/site-packages/ts3/query.py", line 528, in recv
    b"\n\r", timeout=poll_intervall)
  File "/usr/lib/python3.6/telnetlib.py", line 327, in read_until
    return self.read_very_lazy()
  File "/usr/lib/python3.6/telnetlib.py", line 403, in read_very_lazy
    raise EOFError('telnet connection closed')
EOFError: telnet connection closed

which unfortunately has this follow-up exception that prevents self-healing:

It appears the BOT has lost connection to teamspeak. Trying to restart connection in 30 seconds....
Connecting to Teamspeak server...
Loaded User Database...
BOT loaded into server (377) as botgart (33). Nickname 'Botgart'
Traceback (most recent call last):
  File "TS3Bot.py", line 378, in <module>
    ts3conn.clientupdate(client_nickname=BOT.nickname)
  File "/home/ts3bot/.local/lib/python3.6/site-packages/ts3/commands.py", line 1583, in clientupdate
    return self._return_proxy("clientupdate", cparams, uparams, options)
  File "/home/ts3bot/.local/lib/python3.6/site-packages/ts3/query.py", line 655, in _return_proxy
    self, command, common_parameters, unique_parameters, options)
  File "/home/ts3bot/.local/lib/python3.6/site-packages/ts3/query.py", line 632, in send
    return self.wait_for_resp(query_id, timeout)
  File "/home/ts3bot/.local/lib/python3.6/site-packages/ts3/query.py", line 461, in wait_for_resp
    raise TS3QueryError(resp)
ts3.query.TS3QueryError: error id 513: nickname is already in use

It happens with:

I have already tried changing the keepalive value in https://github.com/metalfiiish/ts-gw2-verifyBot/blob/master/TS3Bot.py#L364 to no avail.

I realise that this seems to be a problem with the underlying library, but I just wanted to check if there is perhaps a known solution to this.

ogrady commented 5 years ago

Note: I have also tried removing the version requirement from the ts3 package. The error still remains with the latest version ts3==1.0.11.

metalfiiish commented 5 years ago

Awesome details here. Reading what you have so far it almost sounds like the Bot tries to rejoin but is seeing its old session still timing out. Will try to check into it.

ogrady commented 5 years ago

I have poked around a little more and several users seem to have/ had problems with the used ts3 library, which seem to have gone away randomly. One user reports using ts3 v2 resolves his issues (https://github.com/benediktschmitt/py-ts3/issues/77#issuecomment-465211642). The interface has changed quite a bit between versions, but I will attempt to do a quick port to the new version and see if that resolves the timeouts.

ogrady commented 5 years ago

Good news is, with https://github.com/benediktschmitt/py-ts3/tree/v2 the bot doesn't seem to die. Bad news is, of course, since I had to touch basically every part of the bot, I have to do a whole lot of retesting. I will try to get that done asap and push the changes to my fork which I can pr to the main repository if you want.