When I capture the network traffic and dump the server response, it’s GZIPPED, but not in unicode format. Is there a way to get that function to save the raw response it’s receiving so I can look into this further?
Edit:
System: Linux x86_64
Plex Server: 1.0.3.2461
I’ve included the extracted gzipped response from a PCAP file if anyone is interested in looking at the data. It passes this JSON lint test: http://jsonlint.com/
@sander1 said:
What happens when you leave out the encoding='utf-8' part?
In the code I originally posted above, look in the second try block and you’ll see I do just that. It doesn’t help (The log shows two calls to download content from the url – both have the same exception).
to grab the raw data and output it to the channel log file to see if/what goes wrong with the request.
The pcap I have already has this raw data (Doesn’t get any raw-er than that, right?). What I was more interested in was the “raw” data that JSON.ObjectFromURL is choking on. At some point it’s throwing the unicode exception – one would think there would be a way for it to spit out more info than this – like a line # in the response it is trying to process, or a complete copy of the response that it is trying to process so that this can be investigated further.
In other words, I already know the data is not in Unicode format (see response.gz in my original post) – yet this function erroneously thinks unicode exists. Why?
Okay, here’s Plex’s code that does the unicode stuff (networking.py, lines 242-251):
def __str__(self):
self.load()
if self._encoding:
if self._errors:
result = str(unicode(self._data, self._encoding, self._errors))
else:
result = str(unicode(self._data, self._encoding))
else:
result = self._data
return result
What should be happening is that it checks for self_encoding, see’s that it’s not defined or set to false, and then return self_.data. This should happen in the second call in the code I posted in my first post in this thread, because I haven’t set the encoding parameter. It’s still unclear why I’m seeing that second Unicode exception when it shouldn’t be decoding unicode.
to grab the raw data and output it to the channel log file to see if/what goes wrong with the request.
The pcap I have already has this raw data (Doesn’t get any raw-er than that, right?).
What did the Log(data) do within Plex, did it give an error? If not then the content can be converted into a json object and may fix the immediate issue. Note, you will probably need to include the headers field as-well because of authentication.
I have yet to try that, due the the authentication header issue you mentioned. I can tell you that the data looks normal when I step debug up to the:
if self._encoding:
code in networking.py, however, due to Plex discovering that the channel is unresponsive, I can’t step past this point – I think either because another exception is being thrown that my IDE isn’t handling, or because Plex has terminated the channel (and thus my debug session). Any chance you know how to adjust the timeout period (or disable it completely) for plex channels? I asked this question here already (https://forums.plex.tv/discussion/227907/remote-debugging-plex-plugins-how-to-disable-timeouts#latest) but it only got three views, and zero responses.
@SnakeByter said:
Any chance you know how to adjust the timeout period (or disable it completely) for plex channels?
Not that I know of. Awhile back PMS did have a server setting to increase a channels timeout value, but I’ve not seen that setting in a long time, as-well-as it never worked for me anyways. I have found that the Plex Android client has a very long timeout set for channels, so when debugging I use the Android client. Another user asked about how developers debug channels here. You may find some useful information for your debugging there as-well.