Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlexOnlineToken #60

Closed
drymek opened this issue Sep 26, 2016 · 21 comments
Closed

PlexOnlineToken #60

drymek opened this issue Sep 26, 2016 · 21 comments

Comments

@drymek
Copy link

drymek commented Sep 26, 2016

I've successfully installed and run docker image, but always getting message:

plex    | #####################################################
plex    | #   Login via the webui at http://<ip>:32400/web    #
plex    | #   and restart the docker, because there was no    #
plex    | #      plex token found in the preference file      #
plex    | #####################################################

The web UI says (after login):
A server could not be found. Download and install Plex Media Server, and it will appear here. Where is my server?
and
Install your new server

Host OS:

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.1 LTS
Release:    16.04
Codename:   xenial

docker-compose.yml file:

version: '2'

services:
  plex:
    image: linuxserver/plex
    container_name: plex
    environment:
      - VERSION=latest
      - PUID=1000
      - PGID=1000
    volumes:
      - "../volumes/config:/config"
      - "../volumes/data:/data"
      - "../volumes/transcode:/transcode"
    ports:
      - "32400:32400"
      - "32400:32400/udp"
      - "32469:32469"
      - "32469:32469/udp"
      - "5353:5353/udp"
      - "1900:1900/udp"

run command:

docker-compose up

Docker output:

plex    | [s6-init] making user provided files available at /var/run/s6/etc...exited 0.
plex    | [s6-init] ensuring user provided files have correct perms...exited 0.
plex    | [fix-attrs.d] applying ownership & permissions fixes...
plex    | [fix-attrs.d] done.
plex    | [cont-init.d] executing container initialization scripts...
plex    | [cont-init.d] 10-adduser: executing...
plex    |
plex    | -------------------------------------
plex    |           _     _ _
plex    |          | |___| (_) ___
plex    |          | / __| | |/ _ \
plex    |          | \__ \ | | (_) |
plex    |          |_|___/ |_|\___/
plex    |                |_|
plex    |
plex    | Brought to you by linuxserver.io
plex    | We do accept donations at:
plex    | https://www.linuxserver.io/donations
plex    | -------------------------------------
plex    | GID/UID
plex    | -------------------------------------
plex    | User uid:    1000
plex    | User gid:    1000
plex    | -------------------------------------
plex    |
plex    | [cont-init.d] 10-adduser: exited 0.
plex    | [cont-init.d] 30-dbus: executing...
plex    | [cont-init.d] 30-dbus: exited 0.
plex    | [cont-init.d] 40-chown-files: executing...
plex    | [cont-init.d] 40-chown-files: exited 0.
plex    | [cont-init.d] 50-plex-update: executing...
plex    |
plex    |
plex    |
plex    | #####################################################
plex    | #   Login via the webui at http://<ip>:32400/web    #
plex    | #   and restart the docker, because there was no    #
plex    | #      plex token found in the preference file      #
plex    | #####################################################
plex    |
plex    |
plex    | [cont-init.d] 50-plex-update: exited 0.
plex    | [cont-init.d] done.
plex    | [services.d] starting services
plex    | Starting dbus-daemon
plex    | Starting Plex Media Server.
plex    | 6 3000 /config/Library/Application Support
plex    | 8192
plex    | [services.d] done.
plex    | Starting Avahi daemon
plex    | Found user 'avahi' (UID 106) and group 'avahi' (GID 107).
plex    | Successfully dropped root privileges.
plex    | avahi-daemon 0.6.32-rc starting up.
plex    | No service file found in /etc/avahi/services.
plex    | Joining mDNS multicast group on interface eth0.IPv6 with address fe80::42:acff:fe12:9.
plex    | New relevant interface eth0.IPv6 for mDNS.
plex    | Joining mDNS multicast group on interface eth0.IPv4 with address 172.18.0.9.
plex    | New relevant interface eth0.IPv4 for mDNS.
plex    | Network interface enumeration completed.
plex    | Registering new address record for fe80::42:acff:fe12:9 on eth0.*.
plex    | Registering new address record for 172.18.0.9 on eth0.IPv4.
plex    | Server startup complete. Host name is 3b60b1204411.local. Local service cookie is 2452984411.

config/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml (not sure what is secret, so I will remove them)

<?xml version="1.0" encoding="utf-8"?>
<Preferences OldestPreviousVersion="1.1.4.2757-24ffd60" MachineIdentifier="VALUE REMOVED" ProcessedMachineIdentifier="VALUE REMOVED" AnonymousMachineIdentifier="VALUE REMOVED" agentAutoEnabled.com.plexapp.agents.lastfm.Artists.com.plexapp.agents.vevo="1" MetricsEpoch="1" GracenoteUser="VALUE REMOVED"/>

I have plex account but don't have paid subscription. Restarting docker doesn't change anything. I've removed VERSION env, but the result (except the message) is the same - no plex server

If you need any other information just let me know - I will do my best to help.

@sparklyballs
Copy link
Contributor

Firstly i would try running the container as outlined in the README with standard docker commands (ie not using composer) and using net=host.

Need to use as standard a setup as possible before we can diagnose any potential issues.

@patsissons
Copy link

patsissons commented Oct 2, 2016

I can confirm this bug. Ran the creation commands nearly verbatim and same result, restart results in no upgrade and no PMS is available to connect.

docker create \
--name=plex \
--net=host \
-e VERSION=latest \
-e PUID=... -e PGID=... \
-e TZ=... \
-v plex_config:/config \
-v plex_transcode:/transcode \
--volume-driver=convoy-nfs
linuxserver/plex
10/2/2016 1:05:02 PM #####################################################
10/2/2016 1:05:02 PM #   Login via the webui at http://<ip>:32400/web    #
10/2/2016 1:05:02 PM #   and restart the docker, because there was no    #
10/2/2016 1:05:02 PM #      plex token found in the preference file      #
10/2/2016 1:05:02 PM #####################################################

I can confirm that the container is otherwise working and data is being persisted to the named volume (i.e. the Preferences.xml file exists, but sign of PlexOnlineToken).

UPDATE
For completeness, I just ran the same creation command but with local volumes to confirm that this had nothing to do with the storage abstraction layer. I observed the same results.

@sparklyballs
Copy link
Contributor

try refreshing your browser if plex says no server found.

@patsissons
Copy link

patsissons commented Oct 2, 2016

I have already done this. force refreshed, cleared cache, tried another browser and other devices. definitely not a caching issue.

I should remark that the issue is quite clearly that the Preferences.xml file is not getting populated with the PlexOnlineToken value, which causes the PLEX_TOKEN in the 50-plex-update startup script to be empty (see https://github.com/linuxserver/docker-plex/blob/master/root/etc/cont-init.d/50-plex-update#L73). What is unclear is why logging into Plex via the browser is not updating the Preferences.xml file.

@sparklyballs
Copy link
Contributor

i have in the last ten minutes or so, ran 5 pulls of the images from the hub into fresh config file locations with no failure to populate the preference file.
once i had no server found, a browser refresh found the server.

@patsissons
Copy link

let me spin up a new docker host and see what happens

@sparklyballs
Copy link
Contributor

time for one of the world famous sparklyballs videos.

https://www.youtube.com/watch?v=Z2k_A4lUPEs

@patsissons
Copy link

interesting.

The only thing that I can see that may affect the outcomes is that I am running this with docker-engine which runs containers under root, whereas it appears you are running your containers with your unelevated account. I'm not sure if that would have an effect on things, but otherwise I can run the exact same command as you verbatim and get the same result.

docker run -d --name=plex --net=host -e VERSION=latest -e PGID=1000 -e PUID=1000 -v /tmp/plex:/config linuxserver/plex

# docker ps -a | grep plex
250d1084dffb        linuxserver/plex                "/init"                  3 minutes ago       Up 3 minutes                                                             plex

# ls -lan /tmp/plex/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml
-rw------- 1 1000 1000 599 Oct  2 14:11 /tmp/plex/Library/Application Support/Plex Media Server/Preferences.xml

# cat /tmp/plex/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml
<?xml version="1.0" encoding="utf-8"?>
<Preferences OldestPreviousVersion="1.1.4.2757-24ffd60" MachineIdentifier="..." ProcessedMachineIdentifier="..." AnonymousMachineIdentifier="..." agentAutoE
nabled.com.plexapp.agents.lastfm.Artists.com.plexapp.agents.vevo="1" MetricsEpoch="1" GracenoteUser="..."/>

The web interface is not notifying me of an unclaimed media server on the network, this may be where things are breaking down...

@patsissons
Copy link

patsissons commented Oct 2, 2016

SOLVED!

I was using internal dns to load the web ui, this is where things were breaking down. As soon as i hit the site with the docker node's IP address it was detected as a new PMS host and perform the initial setup (which I assume is where the PlexOnlineToken comes from).

Once the initial setup was complete I was able to use the internal dns again without any issues.

postmortem: perhaps a README patch to clarify that you must do the initial setup via IP.


One extra piece of info, if you specify the hostname (in the compose file or via --hostname) with the hostname you intend to access the container from, plex will detect the PMS host properly.

@felixsteghofer
Copy link

felixsteghofer commented Oct 3, 2016

FYI
I also tried every possible configuration (including the pristine default one), no chance to get the token into the configuration. After some time I found that 404, plex is throwing for the following request:

https://plex.tv/api/home?X-Plex-Product=Plex%20Web&X-Plex-Version=2.8.1&...<some-ids-of-<you>...&X-Plex-Token=<your-plex-token>

I don't know the exact reason why plex blocks this and the german status code:
<Response code="404" status="Sie sind gerade kein Teil des Hauses"/>
is not really helpful either.

But just putting the token into your Preferences.xml works:
`

<Preferences .......
PlexOnlineToken= />`

I do not really know in which exact step this is failing and overall looks odd to me.
Maybe somebody can help?

edit:
english error message
<Response code="404" status="You are not currently part of a home"/>

@drymek
Copy link
Author

drymek commented Oct 6, 2016

@patsissons My issue is not connected to DNS. I'm using IP.
@felixsteghofer Where did you find that?

@patsissons
Copy link

@drymek The issue I had wasn't specifically related to DNS, but rather how Plex web is detecting the PMS. The issue is that it is not able to detect a new server running if the hostname or IP it is running on is different from the hostname or IP you access it from. If you are still not using host networking or DNS there isn't a way to get that token (AFAIK). Without DNS, you'll need to at least run Plex with host networking to get the server detected, this is because without host networking the server runs on the internal IPv4 address (usually a 10.x.x.x address) which you cannot access from your browser. Even if you map ports and do any required forwarding, it won't work because you hit the server from the wrong address (the docker host's IP address). With host networking, the container binds to the docker host address and therefore listens on it as well. Once you do the initial setup, just redeploy your container without host networking (if you are concerned about that part) and re-enable your port mappings and everything should work fine. If host networking is not possible or desired at all, then you have to tell the container to use a custom hostname, and then set up your local DNS to point the hostname to the docker host. This is what I ended up doing and did not need to use host networking.

@drymek
Copy link
Author

drymek commented Oct 6, 2016

host network works like a charm, but when I change it later to ports mapping, the server could not be discovered.

For others: the compose file with host networking is:

version: '2'

services:
  plex:
    image: linuxserver/plex
    container_name: plex
    environment:
      - VERSION=latest
      - PUID=1000
      - PGID=1000
    volumes:
      - "../volumes/config:/config"
      - "../volumes/data:/data"
      - "../volumes/transcode:/transcode"
    network_mode: "host"

UPDATE: PORTS MAPPING WORKS

@felixsteghofer
Copy link

@drymek
you can see the error in your browsers javascript developer console (or in the "network" tab of the developer tools)

@patsissons
interesting, I have the exact same setup, a custom hostname that is proxied to the plex container (and assigned to the plex container) but I couldn't get it to work this way. Always got the 404 described before

@drymek
Copy link
Author

drymek commented Oct 6, 2016

My mistake - switching back to ports mapping works as well.

@drymek
Copy link
Author

drymek commented Oct 6, 2016

@felixsteghofer Yes, there is:

vendors.a6e3046….js:287 GET https://plex.tv/api/home?X-Plex-Product=Plex%20Web&X-Plex-Version=2.8.1&X-P…ce-Screen-Resolution=1395x370%2C1440x900&X-Plex-Token=<token> 404 (Not Found)

@ns-cweber
Copy link

For posterity, I was having the same issue because I was pointing my browser at the server's name from my /etc/hosts file, which would hit the web server, but present the same "server could not be found" error message described above. When I entered the IP address of the server into my browser, everything worked just fine.

@nesrine19992
Copy link

I want to use Radius to authentificate the users plex
can you help me please ?

@CHBMB
Copy link
Member

CHBMB commented Mar 8, 2017

@nesrine19992 That's not supported by us, so don't think the linuxserver team is ignoring you but we can't help with this, however if some other person chimes in that's great though.

@nesrine19992
Copy link

thank you

@sooonmitch
Copy link

@drymek The issue I had wasn't specifically related to DNS, but rather how Plex web is detecting the PMS. The issue is that it is not able to detect a new server running if the hostname or IP it is running on is different from the hostname or IP you access it from. If you are still not using host networking or DNS there isn't a way to get that token (AFAIK). Without DNS, you'll need to at least run Plex with host networking to get the server detected, this is because without host networking the server runs on the internal IPv4 address (usually a 10.x.x.x address) which you cannot access from your browser. Even if you map ports and do any required forwarding, it won't work because you hit the server from the wrong address (the docker host's IP address). With host networking, the container binds to the docker host address and therefore listens on it as well. Once you do the initial setup, just redeploy your container without host networking (if you are concerned about that part) and re-enable your port mappings and everything should work fine. If host networking is not possible or desired at all, then you have to tell the container to use a custom hostname, and then set up your local DNS to point the hostname to the docker host. This is what I ended up doing and did not need to use host networking.

Is it possible that we can add this to the Readme? Ran into the same issue because I directly started changing my ports instead of starting in host mode. With a hour or so searching through the issues, I found this gem and it fixes it. This would be very handy to have documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants