Commit 2b4c06b6 authored by mathieui's avatar mathieui

Fix #2315 (send pings to the server every minute to check the connection)

add two new options:
connection_timeout_delay and connection_check_interval
parent 97d3690a
......@@ -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
......
......@@ -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]``
......
......@@ -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')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment