summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/default_config.cfg6
-rw-r--r--doc/source/configuration.rst17
-rw-r--r--src/connection.py7
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')