diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html
index dc27c31c..09c95c0e 100644
--- a/data/interfaces/default/settings.html
+++ b/data/interfaces/default/settings.html
@@ -1092,9 +1092,19 @@
-->
+
diff --git a/plexpy/__init__.py b/plexpy/__init__.py
index f6b170bc..a0767371 100644
--- a/plexpy/__init__.py
+++ b/plexpy/__init__.py
@@ -493,7 +493,7 @@ def initialize_scheduler():
# Schedule job to reconnect server
schedule_job(activity_pinger.connect_server, 'Check for server response',
- hours=0, minutes=0, seconds=60, args=(False,))
+ hours=0, minutes=0, seconds=30, args=(False,))
schedule_job(web_socket.send_ping, 'Websocket ping',
hours=0, minutes=0, seconds=0)
diff --git a/plexpy/activity_handler.py b/plexpy/activity_handler.py
index fcfe45dd..c6103a94 100644
--- a/plexpy/activity_handler.py
+++ b/plexpy/activity_handler.py
@@ -522,10 +522,10 @@ class ReachabilityHandler(object):
pref = pms_connect.get_server_pref(pref='PublishServerOnPlexOnlineKey')
return helpers.bool_true(pref)
- def on_down(self, server_response):
+ def on_extdown(self, server_response):
plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_extdown', 'remote_access_info': server_response})
- def on_up(self, server_response):
+ def on_extup(self, server_response):
plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_extup', 'remote_access_info': server_response})
def process(self):
@@ -552,9 +552,9 @@ class ReachabilityHandler(object):
plexpy.PLEX_REMOTE_ACCESS_UP = False
if not ACTIVITY_SCHED.get_job('on_extdown'):
- logger.debug("Tautulli ReachabilityHandler :: Schedule remote access down callback in %d seconds.",
+ logger.debug("Tautulli ReachabilityHandler :: Scheduling remote access down callback in %d seconds.",
plexpy.CONFIG.NOTIFY_REMOTE_ACCESS_THRESHOLD)
- schedule_callback('on_extdown', func=self.on_down, args=[server_response],
+ schedule_callback('on_extdown', func=self.on_extdown, args=[server_response],
seconds=plexpy.CONFIG.NOTIFY_REMOTE_ACCESS_THRESHOLD)
elif plexpy.PLEX_REMOTE_ACCESS_UP is False and not server_response['reason']:
@@ -566,7 +566,7 @@ class ReachabilityHandler(object):
logger.debug("Tautulli ReachabilityHandler :: Cancelling scheduled remote access down callback.")
schedule_callback('on_extdown', remove_job=True)
else:
- self.on_up(server_response)
+ self.on_extup(server_response)
elif plexpy.PLEX_REMOTE_ACCESS_UP is None:
plexpy.PLEX_REMOTE_ACCESS_UP = self.is_reachable()
diff --git a/plexpy/config.py b/plexpy/config.py
index dad11a41..7a4d6b64 100644
--- a/plexpy/config.py
+++ b/plexpy/config.py
@@ -171,6 +171,7 @@ _CONFIG_DEFINITIONS = {
'NOTIFY_CONCURRENT_BY_IP': (int, 'Monitoring', 0),
'NOTIFY_CONCURRENT_THRESHOLD': (int, 'Monitoring', 2),
'NOTIFY_NEW_DEVICE_INITIAL_ONLY': (int, 'Monitoring', 1),
+ 'NOTIFY_SERVER_CONNECTION_THRESHOLD': (int, 'Monitoring', 60),
'PLEXPY_AUTO_UPDATE': (int, 'General', 0),
'REFRESH_LIBRARIES_INTERVAL': (int, 'Monitoring', 12),
'REFRESH_LIBRARIES_ON_STARTUP': (int, 'Monitoring', 1),
diff --git a/plexpy/web_socket.py b/plexpy/web_socket.py
index 58ad2db4..8ac13171 100644
--- a/plexpy/web_socket.py
+++ b/plexpy/web_socket.py
@@ -71,9 +71,14 @@ def on_connect():
if not plexpy.PLEX_SERVER_UP:
logger.info("Tautulli WebSocket :: The Plex Media Server is back up.")
- plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_intup'})
plexpy.PLEX_SERVER_UP = True
+ if activity_handler.ACTIVITY_SCHED.get_job('on_intdown'):
+ logger.debug("Tautulli WebSocket :: Cancelling scheduled Plex server down callback.")
+ activity_handler.schedule_callback('on_intdown', remove_job=True)
+ else:
+ on_intup()
+
plexpy.initialize_scheduler()
if plexpy.CONFIG.WEBSOCKET_MONITOR_PING_PONG:
send_ping()
@@ -85,13 +90,25 @@ def on_disconnect():
if plexpy.PLEX_SERVER_UP:
logger.info("Tautulli WebSocket :: Unable to get a response from the server, Plex server is down.")
- plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_intdown'})
plexpy.PLEX_SERVER_UP = False
+ logger.debug("Tautulli WebSocket :: Scheduling Plex server down callback in %d seconds.",
+ plexpy.CONFIG.NOTIFY_SERVER_CONNECTION_THRESHOLD)
+ activity_handler.schedule_callback('on_intdown', func=on_intdown,
+ seconds=plexpy.CONFIG.NOTIFY_SERVER_CONNECTION_THRESHOLD)
+
activity_processor.ActivityProcessor().set_temp_stopped()
plexpy.initialize_scheduler()
+def on_intdown():
+ plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_intdown'})
+
+
+def on_intup():
+ plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_intup'})
+
+
def reconnect():
close()
logger.info("Tautulli WebSocket :: Reconnecting websocket...")
diff --git a/plexpy/webserve.py b/plexpy/webserve.py
index f00461d6..d62f9f61 100644
--- a/plexpy/webserve.py
+++ b/plexpy/webserve.py
@@ -3167,6 +3167,7 @@ class WebInterface(object):
"notify_concurrent_threshold": plexpy.CONFIG.NOTIFY_CONCURRENT_THRESHOLD,
"notify_continued_session_threshold": plexpy.CONFIG.NOTIFY_CONTINUED_SESSION_THRESHOLD,
"notify_new_device_initial_only": checked(plexpy.CONFIG.NOTIFY_NEW_DEVICE_INITIAL_ONLY),
+ "notify_server_connection_threshold": plexpy.CONFIG.NOTIFY_SERVER_CONNECTION_THRESHOLD,
"home_sections": json.dumps(plexpy.CONFIG.HOME_SECTIONS),
"home_stats_cards": json.dumps(plexpy.CONFIG.HOME_STATS_CARDS),
"home_library_cards": json.dumps(plexpy.CONFIG.HOME_LIBRARY_CARDS),