Jump to content


Photo

[SOLVED] 401 Unauthorized


  • Please log in to reply
12 replies to this topic

#1 tubbybassett

tubbybassett

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 04 November 2011 - 06:20 PM

So after updating to the most recent plex server for linux and android clients I can no longer connect to my server remotely. The manager works fine but the android clients cannot connect. I found this in the logs from my phone when connecting remotely:
I/ActivityManager( 1558): Starting: Intent { cmp=com.plexapp.android/.activity.MediaHomeActivity } from pid 16512

V/c*.p*.h*.HttpClientReq*(16512): Starting fetch for : http://ssvnormandy.com:32400/library/sections

V/c*.p*.h*.HttpClientReq*(16512): Initiating http request for : http://ssvnormandy.com:32400/library/sections

V/c*.p*.h*.HttpClientReq*(16512): Starting fetch for : http://ssvnormandy.com:32400/channels/recentlyViewed

V/c*.p*.h*.HttpClientReq*(16512): Initiating http request for : http://ssvnormandy.com:32400/channels/recentlyViewed

V/c*.p*.h*.HttpClientReq*(16512): Starting fetch for : http://ssvnormandy.com:32400/library/recentlyAdded

V/c*.p*.h*.HttpClientReq*(16512): Initiating http request for : http://ssvnormandy.com:32400/library/recentlyAdded

E/ResourceType(16512): Style contains key with bad entry: 0x0101030e

I/c*.p*.a*.a*.MediaHomeA*(16512): Successfully bound to MediaPlayerService

D/dalvikvm(16512): GC_EXTERNAL_ALLOC freed 984K, 50% free 4472K/8903K, external 1998K/2136K, paused 44ms

I/c*.p*.m*.m*.ObjectFact*(16512): Replacing binding for 'Album' with 'com.plexapp.media_client.model.ObjectFactory$BindingClass@406c5848' was previously 'com.plexapp.media_client.model.ObjectFactory$BindingClass@407323c0'.

I/c*.p*.m*.m*.ObjectFact*(16512): Replacing binding for 'Directory' with 'com.plexapp.media_client.model.ObjectFactory$BindingClass@406c53b0' was previously 'com.plexapp.media_client.model.ObjectFactory$BindingClass@40709858'.

I/c*.p*.m*.m*.ObjectFact*(16512): Replacing binding for 'Video' with 'com.plexapp.media_client.model.ObjectFactory$BindingClass@406ae938' was previously 'com.plexapp.media_client.model.ObjectFactory$BindingClass@407098f0'.

I/c*.p*.m*.m*.ObjectFact*(16512): Replacing binding for 'Track' with 'com.plexapp.media_client.model.ObjectFactory$BindingClass@406aca20' was previously 'com.plexapp.media_client.model.ObjectFactory$BindingClass@407178a0'.

I/c*.p*.m*.m*.ObjectFact*(16512): Replacing binding for 'Location' with 'com.plexapp.media_client.model.ObjectFactory$BindingClass@406abd88' was previously 'com.plexapp.media_client.model.ObjectFactory$BindingClass@40735b90'.

I/c*.p*.m*.m*.ObjectFact*(16512): Replacing binding for 'MediaHierarchyError' with 'com.plexapp.media_client.model.ObjectFactory$BindingClass@406a96e8' was previously 'com.plexapp.media_client.model.ObjectFactory$BindingClass@4073f9d8'.

V/c*.p*.a*.a*.MediaHomeA*(16512): MediaHomeActivity: Called onResume

V/c*.p*.a*.a*.PlexActivi*(16512): Showing progress dialog...

I/c*.p*.a*.a*.MediaHomeA*(16512): Connected to MediaPlayerService service.

I/c*.p*.a*.a*.MediaHomeA*(16512): Attempting to start MediaPlayerService.

D/c*.p*.a*.a*.PlexActivi*(16512): Media Service Connected.

I/dalvikvm(16512): Jit: resizing JitTable from 4096 to 8192

W/DefaultRequestDirector(16512): Authentication error: Unable to respond to any of these challenges: {}

W/DefaultRequestDirector(16512): Authentication error: Unable to respond to any of these challenges: {}

W/DefaultRequestDirector(16512): Authentication error: Unable to respond to any of these challenges: {}

D/c*.p*.h*.HttpClientReq*(16512): Response was 401 - reason phrase: Unauthorized

V/c*.p*.h*.HttpClientReq*(16512): Saw http request failure: The server is denying access to this resource.

V/c*.p*.h*.HttpClientReq*(16512): Permanent failure for URL : http://ssvnormandy.com:32400/channels/recentlyViewed

V/c*.p*.h*.HttpClientReq*(16512): Download failed no more retries - (attempt 0) after 301 ms for url: http://ssvnormandy.com:32400/channels/recentlyViewed

D/c*.p*.h*.HttpClientReq*(16512): Problem during HttpClientRequest (stack trace follows).

W/System.err(16512): com.plexapp.http.HttpUnauthorized

W/System.err(16512): 	at com.plexapp.http.HttpClientRequest.fetchAllData(HttpClientRequest.java:372)

W/System.err(16512): 	at com.plexapp.http.HttpClientRequest.invokeHttpRequest(HttpClientRequest.java:452)

W/System.err(16512): 	at com.plexapp.http.HttpClientRequest.call(HttpClientRequest.java:394)

W/System.err(16512): 	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)

W/System.err(16512): 	at java.util.concurrent.FutureTask.run(FutureTask.java:138)

W/System.err(16512): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)

W/System.err(16512): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)

W/System.err(16512): 	at java.lang.Thread.run(Thread.java:1019)

Any ideas?

#2 tubbybassett

tubbybassett

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 04 November 2011 - 06:34 PM

Apparently if you connect locally first, you will then be able to connect remotely... Still I feel as though this is a bug.
Thoughts?

#3 Tobias Hieta

Tobias Hieta

    Plex Dev Team

  • Plex Employee
  • PipPipPipPipPipPip
  • 3648 posts
  • Location: Gävle, Sweden

Posted 04 November 2011 - 08:15 PM

your client needs a myPlex token for external access these days.

Follow me on twitter @tobiashieta or G+


#4 Michael Rommel

Michael Rommel

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 12 April 2012 - 07:31 PM

So let me get this straight:

If I have a network (wired) 192.168.0.0/24 where my Mac and Linux Server sit on.
And a network (wireless) 192.168.1.0/24 where my iPad lives.

Then I cannot access my media from the iPad without using myPlex? Seriously?
There is no way I can enter a Username/Password combination on the server to allow that?


If that is the case, Plex is dead for me. I certainly will not enable access from the outside world to my network for that.

#5 dashbad

dashbad

    Member

  • Members
  • PipPip
  • 49 posts

Posted 13 April 2012 - 05:15 AM

Why do you run your wireless and wired as two separate networks? Can you not have the server and client on the same network?

Inter-network access requires authentication and the devs have chosen to support myplex as the only form of authentication. There are valid reasons for this and not also supporting the old fashioned method.

#6 Michael Rommel

Michael Rommel

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 13 April 2012 - 07:46 AM

Well I have very strict firewall rules, which traffic may pass from one Network to the other. Wireless networks are inherently more prone to attacks, so all the traffic is more tightly controlled than anything else.
In the end, even, if I used myPlex for the authentication part, the real traffic would then flow directly between my server and my iPad, right?

If this is so, it is basically just the server checking a token of myPlex. Is there a way to, let's say: generate a token in myPlex and then copy/paste it on the server or iPad somewhere?

#7 Tobias Hieta

Tobias Hieta

    Plex Dev Team

  • Plex Employee
  • PipPipPipPipPipPip
  • 3648 posts
  • Location: Gävle, Sweden

Posted 13 April 2012 - 09:21 AM

Well I have very strict firewall rules, which traffic may pass from one Network to the other. Wireless networks are inherently more prone to attacks, so all the traffic is more tightly controlled than anything else.
In the end, even, if I used myPlex for the authentication part, the real traffic would then flow directly between my server and my iPad, right?

If this is so, it is basically just the server checking a token of myPlex. Is there a way to, let's say: generate a token in myPlex and then copy/paste it on the server or iPad somewhere?


Yes traffic will only go between your iPad and your server. You only need the token from myPlex, but there is no way to copy&paste it into the iPad app.

(side-note, search the github for mymyplex to see another solution)

Follow me on twitter @tobiashieta or G+


#8 Michael Rommel

Michael Rommel

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 13 April 2012 - 10:20 AM

First of all - thanks for the quick replies! I appreciate that.

Just now - I am a little bit stuck. I had the Plex Media Server on my Mac and I purchased the iPad app. This still works also without myPlex.

Since I have the media library on my Linux Server, I thought it might be a good idea, to move the Media Server to the server as well and purchase a Roku or similar as a small fanless player for the living room and avoid running the Mac for the Media Server.

I tried to figure out, which rules I had to put into the firewall to use myPlex, but I have not found a good documentation, what is really being transferred back and forth between myPlex and the Media Server and the iPad clients.
I tried to allow outgoing connections to 32400 (unfortunately there seems not to be a static IP Address for the myPlex servers) and port forwarding 32400 to the Linux Media Server. Still the Media Server Webpage says when I click the Publish to myPlex:

(yellow) Waiting for a valid mapping.

Then after a long time it goes to green, saying:

(green) Server is mapped to port 32400 (<public IP address>)
(red) myPlex was unable to connect to your server

No idea, what is missing - the firewall log does not show any dropped packets. Is there any place on the wiki/forum, where the protocol details are described?

#9 Michael Rommel

Michael Rommel

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 13 April 2012 - 10:37 AM

I should add, that I now tried to go back to the Plex Media Server Ubuntu lucid instead of the beta version. The description above for registering with myPlex is still the same, but now the iPad can connect to the server and play.
When I go to the beta version again, it is back to square one. The authorization error occurs again.

#10 Tobias Hieta

Tobias Hieta

    Plex Dev Team

  • Plex Employee
  • PipPipPipPipPipPip
  • 3648 posts
  • Location: Gävle, Sweden

Posted 14 April 2012 - 11:26 AM

I should add, that I now tried to go back to the Plex Media Server Ubuntu lucid instead of the beta version. The description above for registering with myPlex is still the same, but now the iPad can connect to the server and play.
When I go to the beta version again, it is back to square one. The authorization error occurs again.


This requires some explanation, before 0.9.5.3 we detected a local network by looking at client IP and server IP and then looking if they where all in the same A class network. I.e. if the server has ip 192.168.1.1 we assumed that all clients coming from a IP in the range 192.x.x.x was "local". This of course was not very good.

So in 0.9.5.3 we changed that, and used wikipedias definition of private networks and used that as local IPs. So all IPs in the ranges defined as local where whitelisted. Again this was not perfect, because many users had other IP ranges and maybe didn't want all IPs from another private network able to access their manager.

In 0.9.6.0 we tweaked this again, reverting back to the first method, but using the actual netmask instead of 255.0.0.0 as netmask. So now if your server is on 192.168.1.0/24 all clients from the same network are considered local.

That explains why it works for you in 0.9.5.3 but not in 0.9.6.0

Follow me on twitter @tobiashieta or G+


#11 Tobias Hieta

Tobias Hieta

    Plex Dev Team

  • Plex Employee
  • PipPipPipPipPipPip
  • 3648 posts
  • Location: Gävle, Sweden

Posted 14 April 2012 - 11:28 AM

First of all - thanks for the quick replies! I appreciate that.

Just now - I am a little bit stuck. I had the Plex Media Server on my Mac and I purchased the iPad app. This still works also without myPlex.

Since I have the media library on my Linux Server, I thought it might be a good idea, to move the Media Server to the server as well and purchase a Roku or similar as a small fanless player for the living room and avoid running the Mac for the Media Server.

I tried to figure out, which rules I had to put into the firewall to use myPlex, but I have not found a good documentation, what is really being transferred back and forth between myPlex and the Media Server and the iPad clients.
I tried to allow outgoing connections to 32400 (unfortunately there seems not to be a static IP Address for the myPlex servers) and port forwarding 32400 to the Linux Media Server. Still the Media Server Webpage says when I click the Publish to myPlex:

(yellow) Waiting for a valid mapping.

Then after a long time it goes to green, saying:

(green) Server is mapped to port 32400 (<public IP address>)
(red) myPlex was unable to connect to your server

No idea, what is missing - the firewall log does not show any dropped packets. Is there any place on the wiki/forum, where the protocol details are described?



It works like this:

Your server asks your GW for a port map, and your public IP. That is sent to my.plexapp.com over HTTPS. myPlex tries to verify that this port/ip is valid by making a HTTP connection to that port (32400) on that IP. If it fails that's when you see the red lights.

But, that doesn't matter in your case right? If you don't want to open it for the public, just make sure that your iPad can connect to that IP on that port, and all should be dandy.

Follow me on twitter @tobiashieta or G+


#12 Michael Rommel

Michael Rommel

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 14 April 2012 - 01:38 PM

Hi Tobias,

thanks for explaining the difference between the versions regarding the "what is local" algorithm. Now everything is clear and explained and the problem solved.

With that information I could configure the firewall correctly - previously I had assumed, that only the token from the myPlex server is needed, but the connection would be to the original IP address of the Linux Plex Media Server.

Now I know, that the connection attempt actually is going from the WLAN to the public IP adress listed in the mapping and not the local LAN IP address. Now everything is working. When I open up the firewall for the incoming HTTP request, the light turns green, but even when I block the port for the internet connection and enable it only for the WLAN network, is is displayed as red, but the iPad connections work. This is with the beta version of the server. I obviously had to remove the manually entered server adresses with their local IPs and only leave the myPlex published servers in the iPad list.

Thank you for your explanations. If I can now myself add a description of the process and the pitfalls back to a wiki or so, please let me know!

Michael.

#13 Tobias Hieta

Tobias Hieta

    Plex Dev Team

  • Plex Employee
  • PipPipPipPipPipPip
  • 3648 posts
  • Location: Gävle, Sweden

Posted 14 April 2012 - 06:36 PM

Glad you solved it! I am marking this thread as solved.

Follow me on twitter @tobiashieta or G+





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users