Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts.send_keepalive issues #77

Closed
whookie opened this issue Nov 4, 2018 · 11 comments
Closed

ts.send_keepalive issues #77

whookie opened this issue Nov 4, 2018 · 11 comments

Comments

@whookie
Copy link

whookie commented Nov 4, 2018

Hey,
I am having trouble with the keepalive method.
Somehow my connection terminates after a short time.
I am using an event timeout of 240 seconds and I am sending a keepalive ( ts.send_keepalive() ) when the TS3TimeoutError gets caught.

Any ideas why this may be happening?

EDIT:
I have also tried not sending a keepalive but actually querying data, but it still closes the connection.
Could it be anything with the server? Or can you see any reason why this is happening?

@whookie
Copy link
Author

whookie commented Nov 4, 2018

The traceback:

File "AdminBot.py", line 52, in <module>
    event = ts.wait_for_event(timeout=int(cfg["ts3"]["timeout"]))[0]
  File "/etc/anaconda/lib/python3.6/site-packages/ts3/query.py", line 350, in wait_for_event
    self._recv(timeout=remaining_time)
  File "/etc/anaconda/lib/python3.6/site-packages/ts3/query.py", line 283, in _recv
    data = self._telnet_conn.read_until(b"\n\r", timeout=timeout)
  File "/etc/anaconda/lib/python3.6/telnetlib.py", line 327, in read_until
    return self.read_very_lazy()
  File "/etc/anaconda/lib/python3.6/telnetlib.py", line 403, in read_very_lazy
    raise EOFError('telnet connection closed')
EOFError: telnet connection closed

@AdorablePotato
Copy link
Collaborator

I'm a bit late here, but does this error still occur? The TS3 changelog mentions a change in the anti-flood error protection.

I don't think that it's a problem with the "idle" time, since you also tried to query data.

@whookie
Copy link
Author

whookie commented Feb 19, 2019

Yes it still happens...
It's weird, because I have the host servers IP whitelisted and I raised the flood protection into amounts that could never be reached by my bots within a week...

Traceback (most recent call last):
  File "AdminBot.py", line 52, in <module>
    event = ts.wait_for_event(timeout=int(cfg["ts3"]["timeout"]))[0]
  File "/root/anaconda3/lib/python3.7/site-packages/ts3/query.py", line 350, in wait_for_event
    self._recv(timeout=remaining_time)
  File "/root/anaconda3/lib/python3.7/site-packages/ts3/query.py", line 283, in _recv
    data = self._telnet_conn.read_until(b"\n\r", timeout=timeout)
  File "/root/anaconda3/lib/python3.7/telnetlib.py", line 327, in read_until
    return self.read_very_lazy()
  File "/root/anaconda3/lib/python3.7/telnetlib.py", line 403, in read_very_lazy
    raise EOFError('telnet connection closed')
EOFError: telnet connection closed

I will try to get familiar with your new API, maybe the problem doesnt exist there.
If it does, I guess it must be an issue with TS. (I should also probably switch to SSH, maybe I will when I switch API...)

@whookie
Copy link
Author

whookie commented Feb 19, 2019

After porting to V2 I found that the bot does not randomly time out anymore, but instead I am getting this error:

Dont worry about the ts32, I just renamed the module so I could have the APIv1 and APIv2 running at the same time.

The error occured after about 15 minues of running, with an event timeout of 300 seconds.
Seems similar to the error in the v1, as both just close the connection. At least v2 survived longer...

Traceback (most recent call last):
  File "AdminBot.py", line 53, in <module>
    event = ts.wait_for_event(timeout=int(cfg["ts3"]["timeout"]))[0]
  File "/root/anaconda3/lib/python3.7/site-packages/ts32/query.py", line 596, in wait_for_event
    self._recv(timeout=timeout())
  File "/root/anaconda3/lib/python3.7/site-packages/ts32/query.py", line 537, in _recv
    data = self._transport.read_line(timeout=timeout())
  File "/root/anaconda3/lib/python3.7/site-packages/ts32/query.py", line 278, in read_line
    self._channel.settimeout(timeout())
  File "/root/anaconda3/lib/python3.7/site-packages/ts32/query.py", line 152, in remaining
    raise TS3TimeoutError()
ts32.query.TS3TimeoutError: Could not receive data from the server within the timeout.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "AdminBot.py", line 224, in <module>
    ts.send_keepalive()
  File "/root/anaconda3/lib/python3.7/site-packages/ts32/query.py", line 632, in send_keepalive
    self._transport.send_line(b" ")
  File "/root/anaconda3/lib/python3.7/site-packages/ts32/query.py", line 290, in send_line
    self._channel.send(data + b"\n\r")
  File "/root/anaconda3/lib/python3.7/site-packages/paramiko/channel.py", line 801, in send
    return self._send(s, m)
  File "/root/anaconda3/lib/python3.7/site-packages/paramiko/channel.py", line 1180, in _send
    raise socket.error("Socket is closed")

@whookie
Copy link
Author

whookie commented Mar 16, 2019

I have also tried not sending a keepalive but actually querying data, but it still closes the connection.

@AdorablePotato
Copy link
Collaborator

I run the very simple hello_bot example for multiple hours without problems on a fresh ts3 server (and the latest changes proposed by you and Helyux in #84). I can't reproduce it. Can you provide a small script, that reproduces the bug on default ts3 server settings?

@whookie
Copy link
Author

whookie commented Mar 25, 2019

I will try.
I will do one more test today on a differemt server on a different OS, but i'll see if that fixes it.

@whookie
Copy link
Author

whookie commented Mar 26, 2019

I have tried it on TS version 3.7.0 on Windows Server 2019 and it is still running without issues.

Maybe it is due to the upgrade to server version 3.7.0, but I dont know.

I will check the original server again, if it doesnt work, it might be something with the server.

(Assuming its just on my server, any idea how the bot could timeout like that? All required ports are open and properly forwarded.)

@jn4kr
Copy link

jn4kr commented Mar 31, 2019

My server is also running 3.7.0 but on Linux. I had the same issue.
For me it worked to reduce timeout to 30 and replace ts.send_keepalive with ts.whoami.

@whookie
Copy link
Author

whookie commented Apr 1, 2019

The keepalive method is fixed (See last update) but I can try the 30 sec timeout, thanks.

(Mine also runs on debian)

@whookie
Copy link
Author

whookie commented Apr 1, 2019

Huh, you're right.
The script has been running for about 4 hours now and still no timeout. Weird issue but im glad I know the fix now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants