diff options
author | mathieui <mathieui@mathieui.net> | 2013-06-11 00:03:48 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2013-06-11 00:03:48 +0200 |
commit | 2b4c06b6f81f46e9f712882877fdd261aae84065 (patch) | |
tree | 812f285b1b0fd638f19032a00040f60ce12a006c | |
parent | 97d3690aea8926f50eed2d5d0194114228c1e3ef (diff) | |
download | poezio-2b4c06b6f81f46e9f712882877fdd261aae84065.tar.gz poezio-2b4c06b6f81f46e9f712882877fdd261aae84065.tar.bz2 poezio-2b4c06b6f81f46e9f712882877fdd261aae84065.tar.xz poezio-2b4c06b6f81f46e9f712882877fdd261aae84065.zip |
Fix #2315 (send pings to the server every minute to check the connection)
add two new options:
connection_timeout_delay and connection_check_interval
-rw-r--r-- | data/default_config.cfg | 6 | ||||
-rw-r--r-- | doc/source/configuration.rst | 17 | ||||
-rw-r--r-- | src/connection.py | 7 |
3 files changed, 30 insertions, 0 deletions
diff --git a/data/default_config.cfg b/data/default_config.cfg index f7879c8c..9e93900f 100644 --- a/data/default_config.cfg +++ b/data/default_config.cfg @@ -33,6 +33,12 @@ ca_cert_path = # defaults to false because it should not be necessary auto_reconnect = false +# The time between the ping sent to the server to check if the connection is alive +connection_check_interval = 60 + +# The timeout value of those pings +connection_timeout_delay = 10 + # the resource you will use # If it's empty, your resource will be chosen (most likely randomly) by the server # It is not recommended to use a resource that is easy to guess, because it can lead diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index 4fa92900..5bdec95e 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -111,6 +111,23 @@ section of this documentation. The fingerprint of the SSL certificate as a hexadecimal string, you should not touch it, except if know what you are doing. + connection_check_interval + + **Default value:** ``60`` + + A ping is sent to the server every N seconds, N being the value of that option. + Change this to a low value if you want to know quickly when you are disconnected, + and to a very high value if bandwidth matters so much that you can’t afford + 100 bytes/minute (seriously?). + + connection_timeout_delay + + **Default value:** ``10`` + + The timeout delay of the ping referenced above, 10 should really be fine, but + if your network is really unstable, it can be set higher or lower, depending + of your preference. + custom_host **Default value:** ``[empty]`` diff --git a/src/connection.py b/src/connection.py index 91b6c1b9..0db7acad 100644 --- a/src/connection.py +++ b/src/connection.py @@ -72,6 +72,13 @@ class Connection(sleekxmpp.ClientXMPP): self.register_plugin('xep_0085') self.register_plugin('xep_0115') self.register_plugin('xep_0191') + ping_interval = config.get('connection_check_interval', 60) + if ping_interval <= 0: + ping_interval = 60 + timeout_delay = config.get('connection_timeout_delay', 10) + if timeout_delay <= 0: + timeout_delay = 10 + self.register_plugin('xep_0199', pconfig={'keepalive': True, 'interval': ping_interval, 'timeout': timeout_delay}) if config.get('enable_user_tune', 'true') != 'false': self.register_plugin('xep_0118') |