Plex shortcut opens wrong address, gives "Bad Request"

Plex package allows users to manage and playback their media collections to local or remote desktop/mobile running Plex media client through Synology DiskStation
Forum rules
Please note the Disclaimer before modifying your Synology Product.
uemeulo
Trainee
Trainee
Posts: 12
Joined: Tue Sep 06, 2011 9:55 pm
Location: Italy

Plex shortcut opens wrong address, gives "Bad Request"

Postby uemeulo » Wed Nov 13, 2013 2:01 am

Recently I've installed Plex Media Server, version 0.9.7.28.33-f80a4a2 from official synology repo as a third-party package.

I'm using DSM 4.3-3810 on a DS1511+.

But clicking on the Plex shortcut, placed in 'Start menu', opens <mylocalip>:5001.

As a result, I see a '400 Bad Request' error page.

In any case, I have 'Enable HTTPS connection' and 'Automatically redirect HTTP connections to HTTPS', so that entering http://<mylocalip>:5000 or https://<mylocalip>:5001 open my DSM login page.

Port 32400 TCP has also been enabled on firewall and router.

As a result, entering http://<mylocalip>:32400/web/ opens http://<mylocalip>:32400/web/index.html#!/dashboard and everything works fine.

Even though I'm still a newbie, I'd like to know how could I change 'Plex Media Server' shortcut to open the right address?

Thanks for your help.
User avatar
dMajo
Knowledgeable
Knowledgeable
Posts: 353
Joined: Sun Aug 19, 2012 12:26 pm
Location: Italy
Contact:

Re: Plex shortcut opens wrong address, gives "Bad Request"

Postby dMajo » Thu Nov 14, 2013 7:59 pm

Have a look at this file: /var/packages/Plex Media Server/target/dsm_config/plex/plex.cgi

If you are using a bonded connection (link aggregation) there is some "quote" signs to add or remove, i don't remember now.
Here below is how it should be.

Code: Select all

#!/bin/sh
if ifconfig | grep -q bond0
then
IP_ADDR=`ifconfig bond0 | grep "inet addr" | awk '{print $2}' | awk -F: '{print $2}'`
else
IP_ADDR=`ifconfig eth0 | grep "inet addr" | awk '{print $2}' | awk -F: '{print $2}'`
fi
echo Location: http://${IP_ADDR}:32400/manage
echo ""
exit 0
  • APC SMT2200I+AP9631
  • Vigor2830Vn+: LoadBal 2xADSL(20M/1M.mcr512K,8IP)+1x4G/LTE
  • D-Link DGS1210-28P (CoreSW, PoE+)
    • 4x IntelliJack NJ2000G, 4x IntelliJack NJ220
    • 2x Netgear GS108T
    • 2x VigorAP900
  • DS1815+: DSM61(15047u2),16GB,2x845DCPro,4xWD60EFRX,2xWD60PURX;LAN:1+2,3,4
  • DS1513+: DSM43(3827u8),4GB,5xWD30EFRX;LAN:1+2+3,4
  • RS2414RP+: DSM52(5644u8),4GB,8xWD30EFRX;LAN:1+2+3,4
  • Media eq.:
    • DENON AVR4311
    • TV: UE55ES8000Q,UE32ES6800Q,UE22F5410AY
    • Gigaset: 2xDX800A,1xSL910H,2xDA210
    • Galaxy Note3,A5; Nokia N8
uemeulo
Trainee
Trainee
Posts: 12
Joined: Tue Sep 06, 2011 9:55 pm
Location: Italy

Re: Plex shortcut opens wrong address, gives "Bad Request"

Postby uemeulo » Thu Nov 14, 2013 11:34 pm

Impressive!!! Thanks dMajo!!

Worked 100%, without stopping or uninstalling Plex, or even restarting NAS for that matter!

I have Link Agggregation enabled and by removing a pair of extra "quote" signs (') from the 2nd line of that plex.cgi file, it worked.

Wish I could understand what it just fixed, but this thing, Linux, remains still a mystery to me.

Thanks for your help.
User avatar
dMajo
Knowledgeable
Knowledgeable
Posts: 353
Joined: Sun Aug 19, 2012 12:26 pm
Location: Italy
Contact:

Re: Plex shortcut opens wrong address, gives "Bad Request"

Postby dMajo » Fri Nov 15, 2013 9:10 am

You are welcome

IIRC the error was in the "if" clause that is never evaluated for the users non using the link aggregation who defaults to the "else".
Last edited by dMajo on Tue Mar 04, 2014 2:02 pm, edited 1 time in total.
  • APC SMT2200I+AP9631
  • Vigor2830Vn+: LoadBal 2xADSL(20M/1M.mcr512K,8IP)+1x4G/LTE
  • D-Link DGS1210-28P (CoreSW, PoE+)
    • 4x IntelliJack NJ2000G, 4x IntelliJack NJ220
    • 2x Netgear GS108T
    • 2x VigorAP900
  • DS1815+: DSM61(15047u2),16GB,2x845DCPro,4xWD60EFRX,2xWD60PURX;LAN:1+2,3,4
  • DS1513+: DSM43(3827u8),4GB,5xWD30EFRX;LAN:1+2+3,4
  • RS2414RP+: DSM52(5644u8),4GB,8xWD30EFRX;LAN:1+2+3,4
  • Media eq.:
    • DENON AVR4311
    • TV: UE55ES8000Q,UE32ES6800Q,UE22F5410AY
    • Gigaset: 2xDX800A,1xSL910H,2xDA210
    • Galaxy Note3,A5; Nokia N8
targuy
Trainee
Trainee
Posts: 11
Joined: Wed Aug 24, 2011 10:05 am

Re: Plex shortcut opens wrong address, gives "Bad Request"

Postby targuy » Thu Feb 06, 2014 8:21 pm

I did set that fix in DSM and updating Plex (manually,from plex website) hadn't reversed the changes until I installed DSM5 beta and need to update Plex with a beta from Synology website. :x
Would be nice to have a fix in the Syno package directly 8)
User avatar
dMajo
Knowledgeable
Knowledgeable
Posts: 353
Joined: Sun Aug 19, 2012 12:26 pm
Location: Italy
Contact:

Re: Plex shortcut opens wrong address, gives "Bad Request"

Postby dMajo » Fri Feb 07, 2014 10:31 am

Unfortunately this is a plex script and since with the latest release they have introduced autoupdates it will be overwritten each time.
The good thing is that it only corrupts the webpage to setup the server and not the server service itself. Thus you'll need to reapply the patch only if you need to change the server settings.

The fix should be done by the plex team, but I am unsure if it's a bug or it is related to different bash/shell (or however you call) version of the various linux distros.
  • APC SMT2200I+AP9631
  • Vigor2830Vn+: LoadBal 2xADSL(20M/1M.mcr512K,8IP)+1x4G/LTE
  • D-Link DGS1210-28P (CoreSW, PoE+)
    • 4x IntelliJack NJ2000G, 4x IntelliJack NJ220
    • 2x Netgear GS108T
    • 2x VigorAP900
  • DS1815+: DSM61(15047u2),16GB,2x845DCPro,4xWD60EFRX,2xWD60PURX;LAN:1+2,3,4
  • DS1513+: DSM43(3827u8),4GB,5xWD30EFRX;LAN:1+2+3,4
  • RS2414RP+: DSM52(5644u8),4GB,8xWD30EFRX;LAN:1+2+3,4
  • Media eq.:
    • DENON AVR4311
    • TV: UE55ES8000Q,UE32ES6800Q,UE22F5410AY
    • Gigaset: 2xDX800A,1xSL910H,2xDA210
    • Galaxy Note3,A5; Nokia N8
Asintus
Trainee
Trainee
Posts: 14
Joined: Mon Mar 03, 2014 5:54 pm

Re: Plex shortcut opens wrong address, gives "Bad Request"

Postby Asintus » Mon Mar 03, 2014 6:03 pm

Hello!

Thanks very much for this info, as its exactly the problem I'm having on my 412+. I quick test to disable LAG lets me back into Plex.

However, I'm unable to implement the fix prescribed. I can't cd into Plex from my console login on the DS. I get:

-ash: cd: can't cd to plex


Why? Please consider that I know enough Linux/Unix to change IP addresses and that's it, but I use command-line OSes all the time (routers/firewalls).

Thanks!
User avatar
trumpy81
Novice
Novice
Posts: 56
Joined: Fri Oct 11, 2013 3:02 pm

Re: Plex shortcut opens wrong address, gives "Bad Request"

Postby trumpy81 » Mon Mar 03, 2014 7:21 pm

This is not a fault or error perse, The problem occurs because Plex installs a link for the default DSM environment which is non secure, so the link address is http://, however, if you change the DSM environment to be secure, the link will require https:// instead of http:// and that causes the BAD Request error messages.

In other words, you are making changes in DSM and expecting Plex to know about them and correct itself. You would have to write an entire routine to fix that automatically I would imagine.
Regards
Andy M

Synology DS1813+ 8x ST4000VN000 Windows 7 Professional 64 bit Windows 10 Professional 64 bit Panasonic TH-L42ET60A Panasonic TH-55DX600U
User avatar
dMajo
Knowledgeable
Knowledgeable
Posts: 353
Joined: Sun Aug 19, 2012 12:26 pm
Location: Italy
Contact:

Re: Plex shortcut opens wrong address, gives "Bad Request"

Postby dMajo » Mon Mar 03, 2014 9:08 pm

Asintus wrote:Hello!

Thanks very much for this info, as its exactly the problem I'm having on my 412+. I quick test to disable LAG lets me back into Plex.

However, I'm unable to implement the fix prescribed. I can't cd into Plex from my console login on the DS. I get:

-ash: cd: can't cd to plex


Why? Please consider that I know enough Linux/Unix to change IP addresses and that's it, but I use command-line OSes all the time (routers/firewalls).

Thanks!


This is the path /var/packages/Plex Media Server/target/dsm_config/plex/plex.cgi
but you can reach it also at /volume1/@appstore/Plex Media Server/dsm_config/plex/plex.cgi
or whatever other volume you have installed the app. This is for DSM4.3 (and perhaps below), I do not know if the application path has changed in dsm5 ... eventually search for plex.cgi script.


trumpy81 wrote:This is not a fault or error perse, The problem occurs because Plex installs a link for the default DSM environment which is non secure, so the link address is http://, however, if you change the DSM environment to be secure, the link will require https:// instead of http:// and that causes the BAD Request error messages.

In other words, you are making changes in DSM and expecting Plex to know about them and correct itself. You would have to write an entire routine to fix that automatically I would imagine.

Sorry, but I have to disagree, this has nothing to do with http to https redirection. The syntax in the compare caluse is syimply wrong so the script always default to the else part which is not showing errors for the ones having one or more nics in which case the gui was searching for eth0, but is definitively wrong for those using lag and thus having their virtual nic named bond0
The script infact simply extract the ip address from the nic configuration and merges it with the plex server port number and http prefix to make the url.
  • APC SMT2200I+AP9631
  • Vigor2830Vn+: LoadBal 2xADSL(20M/1M.mcr512K,8IP)+1x4G/LTE
  • D-Link DGS1210-28P (CoreSW, PoE+)
    • 4x IntelliJack NJ2000G, 4x IntelliJack NJ220
    • 2x Netgear GS108T
    • 2x VigorAP900
  • DS1815+: DSM61(15047u2),16GB,2x845DCPro,4xWD60EFRX,2xWD60PURX;LAN:1+2,3,4
  • DS1513+: DSM43(3827u8),4GB,5xWD30EFRX;LAN:1+2+3,4
  • RS2414RP+: DSM52(5644u8),4GB,8xWD30EFRX;LAN:1+2+3,4
  • Media eq.:
    • DENON AVR4311
    • TV: UE55ES8000Q,UE32ES6800Q,UE22F5410AY
    • Gigaset: 2xDX800A,1xSL910H,2xDA210
    • Galaxy Note3,A5; Nokia N8
User avatar
trumpy81
Novice
Novice
Posts: 56
Joined: Fri Oct 11, 2013 3:02 pm

Re: Plex shortcut opens wrong address, gives "Bad Request"

Postby trumpy81 » Tue Mar 04, 2014 4:55 am

I have Bond0 enabled and yet my link works perfectly (no secure connection here). As I wrote, if you have DSM configured to use a secure connection then the address to Plex must use https:// in the link.

If you read the last line of the script, it will ALWAYS use http:// and NOT https:// regardless of what the IP address to the NAS is.

The rest of the script is working fine.
Regards
Andy M

Synology DS1813+ 8x ST4000VN000 Windows 7 Professional 64 bit Windows 10 Professional 64 bit Panasonic TH-L42ET60A Panasonic TH-55DX600U
User avatar
dMajo
Knowledgeable
Knowledgeable
Posts: 353
Joined: Sun Aug 19, 2012 12:26 pm
Location: Italy
Contact:

Re: Plex shortcut opens wrong address, gives "Bad Request"

Postby dMajo » Tue Mar 04, 2014 9:18 am

trumpy81 wrote:I have Bond0 enabled and yet my link works perfectly (no secure connection here). As I wrote, if you have DSM configured to use a secure connection then the address to Plex must use https:// in the link.

If you read the last line of the script, it will ALWAYS use http:// and NOT https:// regardless of what the IP address to the NAS is.

The rest of the script is working fine.


DSM configuration over secure connections has nothing to do. Beside this there is separate separate configuration options for secure connection of the web server (80 to 443) and the dsm (5000 to 5001). And this options adjust the working behavior only of these two instances of apache. Any sw that have its own web server module is not affected.

Moreover my dsm is not configured to force secure connection ... and ... even if it was, can you explain me why on earth, the removal of two quotation signs and brackets in the IF condition line solve the issue. What have this to do with https?

Code: Select all

if [ 'ifconfig |grep -q bond0' ]

if ifconfig |grep -q bond0

And finally, the line that you are foolishly focusing on, the one that merges http prefix and the port number to form the url is executed always because is not in the if statement, the only thing that changes is the IP_ADDR variable that is set accordingly to the "if" condition result.

When you have understood the script you'll be allowed to debate this further.

Or, if you prefer, YOU ARE RIGHT so we can stop this debate here and you can feel happy.
  • APC SMT2200I+AP9631
  • Vigor2830Vn+: LoadBal 2xADSL(20M/1M.mcr512K,8IP)+1x4G/LTE
  • D-Link DGS1210-28P (CoreSW, PoE+)
    • 4x IntelliJack NJ2000G, 4x IntelliJack NJ220
    • 2x Netgear GS108T
    • 2x VigorAP900
  • DS1815+: DSM61(15047u2),16GB,2x845DCPro,4xWD60EFRX,2xWD60PURX;LAN:1+2,3,4
  • DS1513+: DSM43(3827u8),4GB,5xWD30EFRX;LAN:1+2+3,4
  • RS2414RP+: DSM52(5644u8),4GB,8xWD30EFRX;LAN:1+2+3,4
  • Media eq.:
    • DENON AVR4311
    • TV: UE55ES8000Q,UE32ES6800Q,UE22F5410AY
    • Gigaset: 2xDX800A,1xSL910H,2xDA210
    • Galaxy Note3,A5; Nokia N8
elfaure
Trainee
Trainee
Posts: 14
Joined: Sun May 31, 2015 12:25 am

Re: Plex shortcut opens wrong address, gives "Bad Request"

Postby elfaure » Tue Jul 21, 2015 4:12 am

Thanks for the heads up! I knew the problem was in the Plex.cgi file and I just needed to hunt it down and edit it (after saving a backup copy). You can clearly see that some script is changing the URL of the link found for Plex server under Packages. On mine, it clearly shows the link as 192.168.1.4:32400/web (Wireless1) but when connecting, it mysteriously changes to 192.168.1.2:32400/web (LAN1) and then cannot connect (since I only have Wireless1 connected, no LAN1 or LAN2.

Thks :D :D :D

Return to “Plex”

Who is online

Users browsing this forum: No registered users and 1 guest