mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-27 01:57:33 +00:00
Fixed Sonarr v3 SignalR feed not connecting when mono is used to run Sonarr. #1985
This commit is contained in:
parent
b8b916dc30
commit
a26b86cb95
2 changed files with 11 additions and 5 deletions
|
@ -11,6 +11,7 @@ from requests.exceptions import ConnectionError
|
|||
from signalrcore.hub_connection_builder import HubConnectionBuilder
|
||||
from collections import deque
|
||||
from time import sleep
|
||||
from websocket._exceptions import WebSocketBadStatusException
|
||||
|
||||
from constants import headers
|
||||
from app.event_handler import event_stream
|
||||
|
@ -66,11 +67,15 @@ class SonarrSignalrClientLegacy:
|
|||
"permissions on that directory and restart Sonarr. Also, if you're a Docker image "
|
||||
"user, you should make sure you properly defined PUID/PGID environment variables. "
|
||||
"Otherwise, please contact Sonarr support.")
|
||||
except WebSocketBadStatusException:
|
||||
logging.debug("BAZARR cannot connect to Sonarr SignalR feed using websocket. We'll fall back to "
|
||||
"SSE.")
|
||||
self.configure(force_sse=True)
|
||||
self.restart()
|
||||
else:
|
||||
self.connected = True
|
||||
event_stream(type='badges')
|
||||
logging.info('BAZARR SignalR client for Sonarr is connected and waiting for events.')
|
||||
finally:
|
||||
if not args.dev:
|
||||
scheduler.add_job(update_series, kwargs={'send_event': True}, max_instances=1)
|
||||
scheduler.add_job(sync_episodes, kwargs={'send_event': True}, max_instances=1)
|
||||
|
@ -97,9 +102,9 @@ class SonarrSignalrClientLegacy:
|
|||
logging.error('BAZARR connection to Sonarr SignalR feed has been lost.')
|
||||
self.restart()
|
||||
|
||||
def configure(self):
|
||||
def configure(self, force_sse=False):
|
||||
self.apikey_sonarr = settings.sonarr.apikey
|
||||
self.connection = Connection(url_sonarr() + "/signalr", self.session)
|
||||
self.connection = Connection(url_sonarr() + "/signalr", self.session, force_sse=force_sse)
|
||||
self.connection.qs = {'apikey': self.apikey_sonarr}
|
||||
sonarr_hub = self.connection.register_hub('') # Sonarr doesn't use named hub
|
||||
|
||||
|
|
|
@ -4,12 +4,13 @@ from threading import Thread
|
|||
from signalr.events import EventHook
|
||||
from signalr.hubs import Hub
|
||||
from signalr.transports import AutoTransport
|
||||
from signalr.transports._sse_transport import ServerSentEventsTransport
|
||||
|
||||
|
||||
class Connection:
|
||||
protocol_version = '1.5'
|
||||
|
||||
def __init__(self, url, session):
|
||||
def __init__(self, url, session, force_sse=False):
|
||||
self.url = url
|
||||
self.__hubs = {}
|
||||
self.qs = {}
|
||||
|
@ -23,7 +24,7 @@ class Connection:
|
|||
self.stopping = EventHook()
|
||||
self.exception = EventHook()
|
||||
self.is_open = False
|
||||
self.__transport = AutoTransport(session, self)
|
||||
self.__transport = ServerSentEventsTransport(session, self) if force_sse else AutoTransport(session, self)
|
||||
self.__listener_thread = None
|
||||
self.started = False
|
||||
|
||||
|
|
Loading…
Reference in a new issue