core icon indicating copy to clipboard operation
core copied to clipboard

Failed to connect to Jellyfin

Open Samega7Cattac opened this issue 1 year ago • 19 comments

The problem

I have an Jellyfin instance running in a docker container in Truenas scale and also access from a cloudflare tunnel. I can access without any issues using the cloudflare tunnel or using local ip. But I can't make the integration in Home Assistant to connect using the local ip no matter what.

What version of Home Assistant Core has the issue?

System Information version | core-2023.7.2 -- | -- installation_type | Home Assistant OS dev | false hassio | true docker | true user | root virtualenv | false python_version | 3.11.4 os_name | Linux os_version | 6.1.34 arch | x86_64 timezone | Europe/London config_dir | /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4943 Installed Version | 1.32.1 Stage | running Available Repositories | 1271 Downloaded Repositories | 3
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 10.3 -- | -- update_channel | stable supervisor_version | supervisor-2023.07.1 agent_version | 1.5.1 docker_version | 23.0.6 disk_total | 33.7 GB disk_used | 4.6 GB healthy | true supported | true board | ova supervisor_api | ok version_api | ok installed_addons | Cloudflared (4.2.1), Studio Code Server (5.8.2), Advanced SSH & Web Terminal (15.0.4)
Instituto Português do Mar e Atmosfera (IPMA) api_endpoint_reachable | failed to load: unreachable -- | --
Dashboards dashboards | 1 -- | -- resources | 0 mode | auto-gen
Recorder oldest_recorder_run | July 15, 2023 at 7:17 PM -- | -- current_recorder_run | July 19, 2023 at 9:40 PM estimated_db_size | 2.95 MiB database_engine | sqlite database_version | 3.41.2
Spotify api_endpoint_reachable | ok -- | --

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

jellyfin

Link to integration documentation on our website

https://www.home-assistant.io/integrations/jellyfin

Diagnostics information

Since the integration isn't created there's none

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Samega7Cattac avatar Jul 19 '23 20:07 Samega7Cattac

Hey there @j-stienstra, @ctalkington, mind taking a look at this issue as it has been labeled with an integration (jellyfin) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of jellyfin can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign jellyfin Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


jellyfin documentation jellyfin source (message by IssueLinks)

home-assistant[bot] avatar Jul 19 '23 20:07 home-assistant[bot]

Hi @Samega7Cattac, based on your description I guess there might be a HTTPS/TLS related issue. Is your local instance secured via HTTPS? If so, does it use a publicly trusted certificate?

The integration works with both HTTP and HTTPS, but does require a publicly trusted certificate if using HTTPS.

j-stienstra avatar Jul 25 '23 18:07 j-stienstra

It doesn't have HTTPS

Samega7Cattac avatar Jul 25 '23 19:07 Samega7Cattac

Okay, does the home assistant log or the Jellyfin log provide any information when you try to connect? If not, you can increase the logging by adding the following to your configuration.yaml

logger:
  default: info
  logs:
    homeassistant.components.jellyfin: debug
    Jellyfin: debug

j-stienstra avatar Jul 26 '23 18:07 j-stienstra

I've got a jellyfin server running on my gaming rig, and just installed homekit on a RP4. The server port is open as my kids connect remotely via their phones, HomeAssistant just adamantly refuses to even connect via lan, or wan.

Log entries that seem to be related are as follows.

Logger: JELLYFIN.jellyfin_apiclient_python.connection_manager
Source: components/jellyfin/client_wrapper.py:67
First occurred: 1:46:48 PM (7 occurrences)
Last logged: 9:50:07 PM

connect_to_address <ADDRESS REMOVED> failed
Failed to connect to server: <ADDRESS REMOVED>/web
Failed to connect to server: <ADDRESS REMOVED>/web/index.html
Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 971, in json return complexjson.loads(self.text, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/simplejson/__init__.py", line 514, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/simplejson/decoder.py", line 386, in decode obj, end = self.raw_decode(s) ^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/simplejson/decoder.py", line 416, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/jellyfin_apiclient_python/connection_manager.py", line 176, in connect_to_server result = self.API.get_public_info(server.get('address')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/jellyfin_apiclient_python/api.py", line 586, in get_public_info return response.json() if response.status_code == 200 else {} ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Failing server connection. ERROR msg: Expecting value: line 1 column 1 (char 0)

raziel420 avatar Sep 21 '23 02:09 raziel420

I cannot connect either. I have Unraid running with Jellyfin in a Docker container and HA on the same machine, also in a docker. HA is in Host networking mode. I can’t connect by the server’s IP, host name, localhost, or otherwise. HA is instantly failing which tells me it’s not a timeout. However other integrations, like APC UPS, who are also on this unraid machine, I can connect to in HA using localhost and port number.

tekeous avatar Dec 02 '23 22:12 tekeous

Hi @raziel420, are you still facing issues? The error that you show points to the underlying Python library that this integration uses. That library calls <your Jellyfin url>/system/info/public at that time in the initialization. Appearently, the result that is returned cannot be decoded by the JSON library. Can you try to retrieve the same information from your browser and share the results?

@tekeous, can you share a log with debugging enabled as described above?

j-stienstra avatar Dec 09 '23 19:12 j-stienstra

Honestly I think my Jellyfin issues go far deeper at this point. Switched back over to plex since it's cloud tunneling feature works more reliably for my kids (at least until I stop sucking as a network engineer).

raziel420 avatar Dec 10 '23 02:12 raziel420

I believe I'm having the same issue as OP, when initially configuring the Jellyfin integration in Home Assistant, it gives me a "failed to authenticate" error, I've entered the correct local IPv4 Address along side the port. I've tried using both my admin and regular user accounts which result in the same error. I've added the logger snippet to my configuration.yaml, the following is the log output related to jellyfin.

Logger: JELLYFIN.jellyfin_apiclient_python.api
Source: components/jellyfin/client_wrapper.py:82
No connection adapters were found for '192.168.1.2:8096/Users/AuthenticateByName' 
Logger: JELLYFIN.jellyfin_apiclient_python.connection_manager
Source: components/jellyfin/client_wrapper.py:67
connect_to_address http://192.168.1.2 failed

HyperlinkNetworking avatar Jan 08 '24 13:01 HyperlinkNetworking

Hi @HyperlinkNetworking,

I just want to clarify that the two log snippets you posted are for two different configuration attempts? The first log snippet seems to suggest the protocol was missing from the URL. Was that the case?

In which case we would need to focus on the second log snippet, but I want to make sure that is the right thing to do first.

j-stienstra avatar Jan 14 '24 18:01 j-stienstra

Just an update I got mine to work by using my domain tunnel instead of using the local ip. Not the best solution but works. I will not close this issue since seems there's other ppl with the same issue and my solution is not good for long term.

Samega7Cattac avatar Jan 15 '24 12:01 Samega7Cattac

Just an update I got mine to work by using my domain tunnel instead of using the local ip. Not the best solution but works. I will not close this issue since seems there's other ppl with the same issue and my solution is not good for long term.

I just got mine working after the recent core update, when entering my Jellyfin Server Address I appended the http:// syntax so for example http://192.168.1.2:8096 this was auto added prior but when I added it manually seemed to work just fine.

Unless they fixed it, could be a bug when someone tries to connect via local IPv4 Address and the add-on auto detects the services protocol. then it nulls out?

just a theory no logs to point to where it fails, I'm gonna have to reconfigure it here soon with https once I get that figured, for now I would definitely keep this open since I also encountered others that are dealing with this issue as-well. but with domains, so this might be wider spread.

Thanks for the update, OP.

HyperlinkNetworking avatar Jan 18 '24 08:01 HyperlinkNetworking

I have tried every combination I can think of among: IP address, hostname, tailscale hostname, tailscale IP, prepending the protocol or not, appending the port or not, verifying my username and password, verifying capslock. Logs don't contain any information other than "failed to connect".

HA is running on an RP4, fully updated. Jellyfin is running on a NixOS box, http only. Both are on the same physical subnet with only a switch between them. I can connect to Jellyfin through the browser, through apps (including locally and over tailscale), etc. just fine. It seems only to be this integration that can't connect. Sincerely apologize for not being able to give you more concrete info, but just wanted to add my pair of pennies to the thread.

crawfordlong avatar Feb 17 '24 16:02 crawfordlong

I got the same issue.. i can login throught he hacs jellyfin integration jellyfin_ha just fine..

vikdb avatar Feb 19 '24 11:02 vikdb

I got a similar issue and was able to resolve it by using HTTP with the IPv4 address. HTTPS and custom DNS entries don't work.

QazCetelic avatar May 11 '24 20:05 QazCetelic

@QazCetelic I used IPv4 directly with HTTP, so no DNS in the mix tho

Samega7Cattac avatar Jun 05 '24 16:06 Samega7Cattac

I was having the same problem, nothing worked.

Turns out the problem was not the URL, but the user name. With user name "adrià" it wouldn't work, but with "adria" it did. So it must be the "à" that is tripping down the integration.

ssorgatem avatar Jun 19 '24 07:06 ssorgatem

I don't have any special chars in both user or pass

Samega7Cattac avatar Jun 20 '24 11:06 Samega7Cattac