benediktschmitt / py-ts3

A Python 3 API for the TeamSpeak 3 server query and file transfer interface.
http://py-ts3.readthedocs.io
Other
157 stars 31 forks source link

What to do to stop the ClientQuery from disconnecting after a while #101

Open ckocyigit opened 3 years ago

ckocyigit commented 3 years ago

Hello Guys,

Iam using this library to connect to the Clientquery locally and Iam waiting for events in an endless loop.

Unfortunetaly though when using ts3conn.send_keepalive() Iam getting the error that the method "version" is not available so my guess would be that this command is only usable within a serverquery.

I tried to keep the connection alive by sending a "whoami" command repeatingly. Without luck so far.

pfandipfandautomat commented 3 years ago

Just send a keepalive atleast every 5 minutes I think, and catch the "error". Look at the example below

while True:
                        ts3conn.send_keepalive()
                        try:
                                event = ts3conn.wait_for_event(timeout=60)
                        except:
                                pass
                        else:
                             print(event[0])