toomuchio / plex-nginx-reverseproxy

Configuration to serve Plex Media Center https://plex.tv using Nginx https://nginx.com
660 stars 94 forks source link

PS4 client not working #5

Closed toomuchio closed 7 years ago

toomuchio commented 7 years ago

On the Reddit post regarding this configuration I saw some people having issues with using the PS4 native client with this setup, I don't have a playstation so I can't debug it or even confirm it.

If somebody can confirm this and provide me with some access logs to debug it I'm sure I can fix it, probably just requires another user-agent check in the main location block.

hjone72 commented 7 years ago

I was under the impression that the issues with PS4 were SSL related.

http://forums.plex.tv/discussion/comment/1207590/#Comment_1207590

toomuchio commented 7 years ago

That topic is related to the PS3 no? Unless it's also a problem on the PS4, which could make sense if it's the same SDK. I'd need some access logs to be sure.

enz1ey commented 7 years ago

I've got a PS4 that won't play media with this setup. Things I've tried so far:

-Set option on PS4 to log to PMS -Setting PMS to always require secure connections -Playing media on iOS device and casting to PS4

No matter what, the media will act like it's trying to play and eventually time out with the "this item couldn't be started in time" error.

Here is the only relevant error in the PMS logs I've grabbed so far:

ui-ps4-ps4] [WebMAFManager] Unable to parse json {"command":"playerError","status":"fail","error" : "video_error","error_code" : -2140536830,"error_code_hexa" : "0x806a0002", "error_info" : "ERROR: sceAvPlayerStop(20ff00aa0, https://plex.MYDOMAIN.XYZ/video/:/transcode/universal/start.m3u8?hasMDE=1&path=http://127.0.0.1:32400/library/metadata/8958&mediaIndex=0&partIndex=0&protocol=hls&fastSeek=1&directPlay=0&directStream=0&subtitleSize=100&audioBoost=100&location=wan&session=ap19uyq0f6elgqd5se1t5r7r&subtitles=burn&Accept-Language=en&X-Plex-Session-Identifier=sedbgc20s0s4rs2lajpvuhpe&X-Plex-Client-Profile-Extra=add-limitation(scope=videoCodec&scopeName=h264&type=upperBound&name=video.level&value=41&replace=true)+add-transcode-target-audio-codec(type=videoProfile&context=streaming&protocol=hls&audioCodec=aac&replace=true)&X-Plex-Product=Plex TV&X-Plex-Version=2.13.1&X-Plex-Client-Identifier=d6zd7iapp9exsulspez69klt&X-Plex-Platform=PlayStation 4 App&X-Plex-Platform-Version=01.40&X-Plex-Device=Sony (PlayStation 4 01.40)&X-Ple} { "type": "[object Error]", "stack": "parse@[native code]\n_parseJSON@https://plex.tv/tv/ps4-140/js/main.0d300b262c1c2581c818.js:662:299\nonAccessFunction@https://plex.tv/tv/ps4-140/js/main.0d300b262c1c2581c818.js:662:446\n[native code]\nglobal code@https://plex.tv/web/tv/ps4-140#!/noop/visited:1:15", "name": "SyntaxError", "message": "JSON Parse error: Unterminated string" }

toomuchio commented 7 years ago

@enz1ey I was looking for access logs from Nginx if possible.

However try and disable the http > https redirect and add listen 80; to the main block. I've heard the PS4 app doesn't support https. That could be our problem.

enz1ey commented 7 years ago

@toomuchio I commented out the "return 301 https://$host$request_uri;" line and made sure the first block had

listen 80;
listen [::]:80;

But that didn't work. I also updated to the newest PMS version (1.4.3.3433) and noticed it fixed the incorrect status of remote access, so now it says fully accessible outside your network. PS4 still times out when attempting playback.

Here is the output of my PMS log with anything containing "ps4" when attempting playback. Your nginx.conf doesn't have any lines to output logging, so what would you suggest I add to the .conf to get you the information you need? (EDIT nevermind, I found the default logs)

Do you just want my entire access.log?

enz1ey commented 7 years ago

Alright so I got it working. Steps I took:

EDIT

It appears that after opening 32400, PMS somehow reset itself to use that port rather than 443. Changing the remote access port back to 443 breaks PS4 playback.

toomuchio commented 7 years ago

@enz1ey Turns out you can just disable remote access, and turn on Nginx and it should work... Can you try that? It could just be the PS4 app has to communicate over 32400.... Which means we can't do anything about it really because if you open 32400 it breaks Nginx most of the time.

savahu commented 7 years ago

If I'm not mistaken, the Plex Cloud instances are not reachable on port 32400 but on port 80. Maybe you can thus report it as a bug in the Plex Cloud forum, as I think the PS4 client isn't able to play from a Plex Cloud server either.

toomuchio commented 7 years ago

@savahu Interesting, I'm quite sure the case is just that PS4 clients are hard-coded to always go over 32400, I just don't have a PS4 to confirm. If you do test it and perhaps you can report the bug.

I really need to borrow one or something...

toomuchio commented 7 years ago

I've just had somebody able to play via PS4 noticed on PlexPy seeing them tomorrow will confirm and close this issue. It seems to have been a plex client issue (not able to connect to servers over non-standard ports) the whole time anyway.

enz1ey commented 7 years ago

So was there an update to the PS4 client? I’ve noticed the same issue with some Smart TV clients as well. I haven’t been using my proxy for Plex lately just to avoid these issues, but if they’re starting to support proxies through non-standard ports, I’ll re-enable it.

toomuchio commented 7 years ago

Yeah confirmed to be working, if you look at the changelog there's a recent comment about having fixed playback with Plex Cloud which operates over port 443 and 80 as well.

As for the SmartTV issue I've never encountered that I've got friends playing on a range of TVs without issue.

Going to close this one off now, update your clients you should be fine! Yay.

enz1ey commented 7 years ago

Yeah, I just deleted and reinstalled the Plex app on my PS4 and it still times out playing media, stating "the video did not start playing in time."

I even re-did my conf with the latest one in this repo, obviously changing the necessary paths. I can play in a browser window and a packet trace confirms I'm streaming over the proxy, but the PS4 still fails.

toomuchio commented 7 years ago

I've got no idea, are you using Plex Pass maybe the update isn't in the public stream yet? That's all I can think of.

It defiantly works for me, I have no idea how. It just started working one day.

Here's the PlexPy for one of my users who only has a PS4, I'll try get some Nginx logs maybe there's something there that can help. https://i.imgur.com/ErBgIEK.png

toomuchio commented 7 years ago

Actually, are you allowing http as well as https? I think it started working around the time I pushed that + the plex client update.

pgera commented 7 years ago

This is mostly a bug in PS4's client. It sort of works if you enable port 80, and disable HSTS and other forms of automatic http->https redirects. However, it doesn't work with cloudflare (even if you disable those things on cloudflare). PS4 is able to see the server, and get the metadata, but it won't actually play anything.

toomuchio commented 7 years ago

Report it to the Plex devs, if you need PS4 support you'll have to disable CF nothing I can really do to help fix this. Out of my control, sorry folks :(

misuchiru03 commented 6 years ago

Here with the late comments. Unfortunately, according to other forums I have read and traffic I have analysed, it seems as though the PS4 app may either be hardcoded to use port 32400 (so the server needs to use it), and/or the PS4 client cannot use HTTPS.

I have my nginx-reverse-proxy setup to use HTTPS on port 443 and HTTP on port 32400, allowed 32400 from remote IPs in UFW, along with Remote Access Enabled on the plex server, and a hole punched in the firewall from 32400 to 32400 on my server, which is honestly the one thing I didn't want to do... open another port. Nothing else worked. But this does. Now I can have the web-surfing done to 443, and the PS4 clients connect to 32400 whenever they use plex.

Change the above settings in Plex and your router/gateway/firewalls and add listen 32400 http2; to the beginning of your block. Test that, tweak as necessary.

toomuchio commented 6 years ago

I don't think PS4 can do https, so if you enable http like the config currently has it works fine, I have a PS4 Pro and have no issues.

misuchiru03 commented 6 years ago

Interesting. I am working on getting mine setup so my family can use theirs (from outside my own network), and if I remove access to 32400 from my firewall, they lose their plex connection, even allowing 80 and 443; which is what leads me to think it's also hardcoded. Now if you are on the same network, it shouldn't matter because internally the server could accept any /24 IP address to port 32400, so the PS4 would work internally. You would then have to port forward otherwise.