Fix to Plex Companion response not conform to HTTP standards

content length is wrong, causing thread to lock for several seconds
This commit is contained in:
tomkat83 2016-02-10 13:02:58 +01:00
parent 97b8083562
commit 531dba40bf
2 changed files with 9 additions and 4 deletions

View file

@ -185,11 +185,12 @@ class DownloadUtils():
header = plx.getXArgsDeviceInfo(options=options) header = plx.getXArgsDeviceInfo(options=options)
return header return header
def downloadUrl(self, url, postBody=None, type="GET", parameters=None, authenticate=True, headerOptions={}): def downloadUrl(self, url, postBody=None, type="GET", parameters=None, authenticate=True, headerOptions={}, timeout=None):
# self.logMsg("=== ENTER downloadUrl ===", 2) # self.logMsg("=== ENTER downloadUrl ===", 2)
timeout = self.timeout if timeout is None:
timeout = self.timeout
default_link = "" default_link = ""
try: try:
@ -365,7 +366,7 @@ class DownloadUtils():
except requests.exceptions.ConnectTimeout as e: except requests.exceptions.ConnectTimeout as e:
self.logMsg("Server timeout at: %s" % url, 0) self.logMsg("Server timeout at: %s" % url, 0)
self.logMsg(e, 1) # self.logMsg(e, 1)
except requests.exceptions.HTTPError as e: except requests.exceptions.HTTPError as e:

View file

@ -243,10 +243,14 @@ class Subscriber:
url = self.protocol + '://' + self.host + ':' + self.port \ url = self.protocol + '://' + self.host + ':' + self.port \
+ "/:/timeline" + "/:/timeline"
# Choose an extremely low timeout due to Plex players response not
# being conform to HTTP standards (content length is wrong). Otherwise,
# This thread gets blocked for a couple of seconds
response = self.download.downloadUrl( response = self.download.downloadUrl(
url, url,
postBody=msg, postBody=msg,
type="POSTXML") type="POSTXML",
timeout=0.001)
# if not requests.post(self.host, self.port, "/:/timeline", msg, getPlexHeaders(), self.protocol): # if not requests.post(self.host, self.port, "/:/timeline", msg, getPlexHeaders(), self.protocol):
# subMgr.removeSubscriber(self.uuid) # subMgr.removeSubscriber(self.uuid)
if response in [False, None, 401]: if response in [False, None, 401]: