feat: add PLEX_MANUAL_PORT env var for manual Remote Access port mapping - #171
Open
jonfen wants to merge 1 commit into
Open
feat: add PLEX_MANUAL_PORT env var for manual Remote Access port mapping#171jonfen wants to merge 1 commit into
jonfen wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PLEX_MANUAL_PORTenvironment variable that setsManualPortMappingMode=1andManualPortMappingPort=<value>inPreferences.xml, equivalent to enabling Remote Access > Manually specify public port in the server settings.40-plex-first-rundirectly alongside the existingADVERTISE_IP/ALLOWED_NETWORKShandling, using the samesetPrefhelper and the same first-run semantics.(Note: this repository has issues disabled, so the problem report below is included here rather than as a linked issue.)
Problem
When Plex Media Server runs behind a router/firewall that does not offer UPnP/NAT-PMP (most business-grade firewalls, and effectively any Bridge-networking deployment, where the README notes the server is "essentially behind two routers"), automatic port mapping can never succeed. Unless the user manually enables Settings > Remote Access > Manually specify public port in the web UI, the server never publishes a direct WAN connection to plex.tv — even when a correct port-forward for 32400 is already in place and working.
The failure mode is silent and easy to misdiagnose: remote clients can complete their small candidate-test connections against the forwarded port, but the candidate list plex.tv serves them contains no direct WAN URI, so every remote stream falls back to the bandwidth-limited relay (~2 Mbps). Users see "speed issues" while their firewall shows the forwarded port open and passing traffic.
Confirmed on
plexinc/pms-docker:latest(PMS 1.43.3): with a static DNAT for 32400 in place,/myplex/accountshowedmappingState="mapped"butpublicPort="0", and the plex.tv resources list had only LAN, custom, and relay candidates. SettingManualPortMappingMode=1+ManualPortMappingPort=32400immediately produced thehttps://<wan-ip-dashes>.<hash>.plex.direct:32400candidate and remote clients switched fromrelayed="1"torelayed="0".Today the only fix is a manual, non-declarative GUI step that is lost if
Preferences.xmlis rebuilt. The container already mapsADVERTISE_IPandALLOWED_NETWORKSontoPreferences.xml, and this image is the deployment shape where automatic mapping is most likely to be impossible, so this belongs alongside them.Test plan
/myplex/accountfrompublicPort="0"topublicPort="32400", added the directplex.direct:32400WAN candidate to the plex.tv resources list, and remote clients switched fromrelayed="1"torelayed="0".-e PLEX_MANUAL_PORT=32400writes both attributes to a cleanPreferences.xml.