Hellowlol / bw_plex

binge watching for plex
MIT License
368 stars 23 forks source link

Samsung Smart TV - Connection refused #74

Closed UnR34L closed 5 years ago

UnR34L commented 5 years ago

Its working on other devices (although not very consistent) but not with a samsung smart tv (2016+)

2019-02-11 15:03:53,655 :: bw_plex :: DEBUG :: plex.py:976 :: Found The.Orville.s02e06 theme start 02:47, theme end 03:43, ffmpeg_end 03:44 progress 02:50 best_time 03:43 credits_start 00:00 credits_end 00:00
2019-02-11 15:03:53,656 :: bw_plex :: DEBUG :: plex.py:1007 :: The.Orville.s02e06 is in the correct time range theme_end
2019-02-11 15:03:53,656 :: bw_plex :: DEBUG :: plex.py:963 :: Called jump with The.Orville.s02e06 3 223.91002267573697 None
2019-02-11 15:03:53,661 :: bw_plex :: INFO :: plex.py:760 :: Called client_action with 223.91002267573697 03:43 3 None
2019-02-11 15:03:53,708 :: bw_plex :: INFO :: plex.py:795 :: client TV UE40KU6000 170.0
2019-02-11 15:03:53,709 :: bw_plex :: INFO :: plex.py:814 :: b3p9i40bnrg22tdjkd6sitbn b3p9i40bnrg22tdjkd6sitbn
2019-02-11 15:03:53,709 :: bw_plex :: INFO :: plex.py:828 :: Connectiong to TV UE40KU6000
2019-02-11 15:03:53,714 :: bw_plex :: ERROR :: plex.py:831 :: Cant connect to TV UE40KU6000
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.6/dist-packages/urllib3/util/connection.py", line 80, in create_connection
    raise err
  File "/usr/local/lib/python3.6/dist-packages/urllib3/util/connection.py", line 70, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 181, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 168, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f9151c50860>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/dist-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.0.119', port=32400): Max retries exceeded with url: /resources (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9151c50860>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/bw_plex/bw_plex/plex.py", line 829, in client_action
    correct_client.connect()
  File "/usr/local/lib/python3.6/dist-packages/plexapi/client.py", line 91, in connect
    data = self.query(self.key, timeout=timeout)
  File "/usr/local/lib/python3.6/dist-packages/plexapi/client.py", line 160, in query
    response = method(url, headers=headers, timeout=timeout, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.0.119', port=32400): Max retries exceeded with url: /resources (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9151c50860>: Failed to establish a new connection: [Errno 111] Connection refused',))
Hellowlol commented 5 years ago

What not very consistent? They it doesn’t find the intro or that we can’t send the seek command to the client?

What version of the plex client is your Samsung tv? (Just wanted to see if we had the same client)

UnR34L commented 5 years ago

Version: Plex for Samsung 3.84.2 (The updated UI)

When I say not consistent, when I first ran it I got it working with chrome, then after that it stopped working, today I ran the container with --privileged and it worked again, I'm still trying stuff so I didn't want to mention it until I'm sure it's a bug.

But with the TV it just doesn't connect.

Also, I was looking through some old issues regarding plexapi and samsung, https://github.com/pkkid/python-plexapi/issues/161 - It definitely worked with the plexapi :)

Hellowlol commented 5 years ago

Okei, so i pushed a update that simply ignores the connection errors. Lets see if that works, as my samsung version was 1 something...

Also can you try:

import logging
import time
logging.basicConfig(level=logging.DEBUG)

from plexapi.server import PlexServer
baseurl = 'http://192.168.0.54:32400'
token = 'TOKEN'

plex = PlexServer(baseurl, token)

alien = plex.library.section('1.Movies').get('Alien')
client = plex.client("TV UE40KU6000")
client.playMedia(alien)

time.sleep(15)
client.seekTo(600*1000)

And verify that it seeking on that client works?

UnR34L commented 5 years ago

Getting the same error, tried with python2.7 and python3. I think an update has broken something.

This https://github.com/pkkid/python-plexapi/issues/161#issuecomment-318915852 exact script used to work but now it's not. Same error.

Hellowlol commented 5 years ago

Okei, if thats the case run the script copy the out and open a new issue on plexapi.

Hellowlol commented 5 years ago

Closing this as its a upstream issue.