PlexConnect RPM for Linux (RedHat/CentOS)

I just made this dumb mistake myself:

Modify /etc/dnsmasq.d/plexconnect.conf, and change x.x.x.x to your servers IP address

Don't use 127.0.0.1 for x.x.x.x. I was reinstalling the client, rebooted and it stopped working. It should be the something like 192.168.1.6, for example.

Now I get this error when I start the service:

python[2936]: detected unhandled Python exception in '/var/lib/plexconnect/PlexConnect_daemon.py'

From command line it boots fine. What did I mess up this time? Time for more checking around.

Seems to be some kind of permission issue with the PID file. Could this be? I made (mkdir) and changed the owner (chown) of the /var/run/plexconnect directory. Did a stop/start and the exception error disappears and I can connect the AppleTV. At reboot the folders disappear, however, and I have to start over.

Seems to be some kind of permission issue with the PID file. Could this be? I made (mkdir) and changed the owner (chown) of the /var/run/plexconnect directory. Did a stop/start and the exception error disappears and I can connect the AppleTV. At reboot the folders disappear, however, and I have to start over.

Ok, it seems RedHat/CentOS 7 turned /var/run (i.e., /run) into a tmpfs.  I've added support for this by generating a configuration file for /etc/tmpfiles.d, which will create the plexconnect run directory on boot.  If you pull down the latest release from github and rebuild, it should solve this issue.

Keep me posted.  Thanks!

Great! I'll try it when I get home.

An alternative sollution would be, to add mkdir to the init script: http://askubuntu.com/questions/303120/how-folders-created-in-var-run-on-each-reboot (for Ubuntu).

To summarize: since the plexconnect daemon is run as non-root (default: plexconnect) and the daemon makes the PIDfile, there is a permission issue for creating the PIDfile. Correct?

Seems like /var/run contains sensitive stuff (what I googled on the Internet).

When I red further in the link, I saw this:

start on runlevel [2345] 
stop on runlevel [!2345] 
expect daemon 

pre-start script
mkdir -p -m0755 /var/run/mysqld
chown mysql:mysql /var/run/mysqld
end script

exec /etc/init.d/mysql start
pre-stop exec /etc/init.d/mysql stop

No idea of this would work for Centos and it's a different kind of script (Upstart), but can use:

mkdir -p -m0755 /var/run/plexconnect
chown plexconnect:plexconnect /var/run/plexconnect

Great! I'll try it when I get home.

An alternative sollution would be, to add mkdir to the init script: http://askubuntu.com/questions/303120/how-folders-created-in-var-run-on-each-reboot (for Ubuntu).

To summarize: since the plexconnect daemon is run as non-root (default: plexconnect) and the daemon makes the PIDfile, there is a permission issue for creating the PIDfile. Correct?

Seems like /var/run contains sensitive stuff (what I googled on the Internet).

Since RedHat/CentOS are going the way of systemd I wanted to implement the solution correctly, rather than hacking it with a mkdir in the init script.

Again, let me know how it goes! :)

I reinstalled and it works fine. Problem solved.

Something else...

Around (re)boot these directories are created in root's home (/root): plexconnect and plexconnect/tmp.

Are these part of the installation? And are they safe to delete? I'm curious about the role.

Nevermind, I think it has something to do with compiling your own rpm. Every new compile seems to end up into this folder. :huh:

hey guys,


im new on centos7 (come from ubuntu) and must say it starts at boot like a charm (on ubuntu i had much trouble =().


only just one problem i have with plexconnect running on centos7: my appletv doesnt connect.


The last line in the log is that the http is started on 8080. i dont see any dns request in the log.


in /var/lib/plexconnect/Settings.cfg i changed the ip_pms to 192.168.178.30 and trailers.apple.com to www.icloud.com to use the imovie app on my appletv

all x.x.x.x in /etc/dnsmasq.d/plexconnect.conf are changed to 192.168.178.30 (which is my centos server)

and i replace the certificates with my own (which worked on windows, ubuntu, debian and macos)


is there more to change? Maybe /etc/sysconfig/plexconnect? Is there anything to configure in SELINUX or in the Firewall?


P. S. if i replace the /var/lib/plexconnect/ folder with the release from iBaa i get a DNS request in the log but my appletv cant connect to.


Greets

>>The last line in the log is that the http is started on 8080. i dont see any dns request in the log.

ATV calls for :80... unless you have any port forwarding defined (which you didn't mention...), it can't work.

Well, there are a few things that can go wrong in Centos. One common problem for me, is SElinux. To test if SElinux is causing problems, you can try this:

setenforce 0

and check with:

sestatus

Which should confirm "permissive". At next reboot it will revert to enforcing. It is intended to troubleshoot.

If it works after this, you probably need to modify a se setting for Apache webserver (if you followed instructions above).

Also, firewalld needs to open a few ports, like 80, 8080 and the DNS port.

yes i get it :D a few minutes after my post i recognized that the firewall is blocking everything... thx ;)

greets

ps selinux is disabled on my centos... its confusing...  and i disabled it

Yep, it would be nice if SELinux would be more transparent. With my Centos install all the blocking happened in the background and the audit logs (/var/log/audit) are a pain to read. Luckily there's audit2allow (and other tools) and grep.

Hi everyone, has this stopped working for you guys as well?

I'm getting this when trying to run PlexConnect.py manually (even as root, to confirm it's not a permissions issue):

[root@plex-server plexconnect]# ./PlexConnect.py

19:07:05 PlexConnect: ***
19:07:05 PlexConnect: PlexConnect
19:07:05 PlexConnect: Press CTRL-C to shut down.
19:07:05 PlexConnect: ***
19:07:05 PlexConnect: started: 19:07:05
19:07:05 PlexConnect: Version: 0.4-dev
19:07:05 PlexConnect: Python: 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]
19:07:05 PlexConnect: Host OS: linux2
19:07:05 PlexConnect: PILBackgrounds: Is PIL installed? False
19:07:05 PlexConnect: IP_self (from settings): 10.9.1.25
Traceback (most recent call last):
  File "./PlexConnect.py", line 188, in
    running = startup()
  File "./PlexConnect.py", line 89, in startup
    proxy.start(initProxy)
TypeError: start() takes exactly 1 argument (2 given)
[root@plex-server plexconnect]#

This is an issue with the version of Python you are using. 2.6.x does not support the same number of arguments for the proxy.start compared to 2.7.x

I finally had a chance to rebuild my Plex server but running into issue where I cannot add the Certificate to the ATV3 using "http://trailers.apple.com/trailers.cer".  Although, if I use "http://10.9.1.25/trailers.cer" I can add the Certificate but cannot open the Trailers app successfully.  Plex itself is working just fine and can be accessed via browser or by Plex applications.

Plex version

0.9.11.7.803-87d0708

Here's my PlexConnect.log file:

14:33:03 PlexConnect: started: 14:33:03

14:33:03 PlexConnect: Version: 0.5-dev
14:33:03 PlexConnect: Python: 2.7.9 (default, Dec 12 2014, 10:25:04)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)]
14:33:03 PlexConnect: Host OS: linux2
14:33:03 PlexConnect: PILBackgrounds: Is PIL installed? False
14:33:03 Settings: getsetting enable_plexconnect_autodetect=False
14:33:03 Settings: getsetting ip_plexconnect=127.0.0.1
14:33:03 PlexConnect: IP_self (from settings): 127.0.0.1
14:33:03 Settings: getsetting hosttointercept=trailers.apple.com
14:33:03 ATVSettings: init class CATVSettings
14:33:03 ATVSettings: load settings
14:33:03 Settings: getsetting enable_dnsserver=False
14:33:03 WebServer: started: 14:33:03
14:33:03 Settings: getsetting port_webserver=8080
14:33:03 WebServer: ***
14:33:03 WebServer: WebServer: Serving HTTP on 127.0.0.1 port 8080.
14:33:03 WebServer: ***
14:33:03 Settings: getsetting enable_webserver_ssl=False
15:27:22 WebServer: http request header:
Host: 10.9.1.25^M
Accept-Encoding: gzip, deflate^M
User-Agent: AppleTV/7.0 iOS/8.0 AppleTV/7.0 model/AppleTV3,2 build/12A365b (3; dt:12)^M
Accept-Language: en^M
Accept: */*^M
X-Forwarded-For: 10.9.1.78^M
X-Forwarded-Host: 10.9.1.25^M
X-Forwarded-Server: trailers.apple.com^M
Connection: Keep-Alive^M
 
15:27:22 WebServer: http request path:
/trailers.cer
15:27:22 Localize: aTVLanguage: en
15:27:22 WebServer: pms address:
 
15:27:22 WebServer: cleaned path:
/trailers.cer
15:27:22 WebServer: PlexConnect options:
{'aTVScreenResolution': '720', 'aTVFirmwareVersion': '5.1', 'aTVLanguage': 'en', 'aTVAddress': '10.9.1.78'}
15:27:22 WebServer: additional arguments:
 
15:27:22 WebServer: serving *.cer: /trailers.cer
15:27:22 Settings: getsetting certfile=/etc/pki/plexconnect/trailers.pem
15:27:22 Settings: getsetting certfile=/etc/pki/plexconnect/trailers.pem
15:28:03 WebServer: http request header:
Host: trailers.apple.com^M
Accept: */*^M
Accept-Encoding: gzip, deflate^M
Accept-Language: en^M
Cookie: xp_ci=3z44smKgzEt7z4THz90szhBFRo7sX; s_vi=[CS]v1|2997933685012147-60000131E0056EC2[CE]^M

Here's my Settings.cfg file

[PlexConnect]

enable_plexgdm = True
ip_pms = 10.9.1.25
port_pms = 32400
enable_dnsserver = False
port_dnsserver = 53
ip_dnsmaster = 8.8.8.8
prevent_atv_update = False
enable_plexconnect_autodetect = False
ip_plexconnect = 127.0.0.1
hosttointercept = trailers.apple.com
port_webserver = 8080
enable_webserver_ssl = False
port_ssl = 443
certfile = /etc/pki/plexconnect/trailers.pem
loglevel = High
logpath = /var/log/plexconnect

Here's my plexconnect.conf file:

NameVirtualHost *:80

NameVirtualHost *:443
 
    ServerName trailers.apple.com
    ServerAlias secure.marketwatch.com
    ProxyRequests Off
    ProxyPreserveHost On
    BrowserMatch "^(iTunes-)?AppleTV" appletv
 
    ErrorLog logs/plexconnect-error_log
    CustomLog logs/plexconnect-access_log combined
 
   
        Order deny,allow
        Deny from all
        Allow from env=appletv
   
 
    ProxyPass / http://127.0.0.1:8080/ nocanon
    ProxyPassReverse / http://127.0.0.1:8080/
 
    ServerName trailers.apple.com
    ServerAlias secure.marketwatch.com
    ProxyRequests Off
    ProxyPreserveHost On
    BrowserMatch "^(iTunes-)?AppleTV" appletv
 
    SSLEngine on
    SSLProxyEngine On
    SSLProtocol all -SSLv2
    SSLCertificateFile /etc/pki/plexconnect/trailers.cer
    SSLCertificateKeyFile /etc/pki/plexconnect/trailers.key
 
    ErrorLog logs/plexconnect-error_log
    CustomLog logs/plexconnect-access_log combined
 
   
        Order deny,allow
        Deny from all
        Allow from env=appletv
   
 
    ProxyPass / http://127.0.0.1:8080/ nocanon
    ProxyPassReverse / http://127.0.0.1:8080/

Here's my IPTables:

*filter

:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 32400 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 32410 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 32412 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 32414 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 1900 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

Thank you for any assistance.

Where is the DNS redirect done?