Montellese / mediaimporter.emby

Media importer add-on for Kodi to import items from Emby servers into Kodi
GNU General Public License v2.0
12 stars 3 forks source link

IP autodiscovery function fails when the Emby server runs in a docker container #41

Closed m4tt075 closed 3 years ago

m4tt075 commented 3 years ago

Observation: Local authentification procedure keeps failing, despite of correct user credentials

Expectation: Local authentification succeeds

Relevant log entries: 2021-03-20 16:28:46.360 T:12024 ERROR <general>: [mediaimporter.emby] error retrieving response from POST http://172.20.0.4:8096/emby/Users/AuthenticateByName: HTTPConnectionPool(host='172.20.0.4', port=8096): Max retries exceeded with url: /emby/Users/AuthenticateByName (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x000002BD13B28D30>, 'Connection to 172.20.0.4 timed out. (connect timeout=2)'))

Context:

Potential fixes (TBC):

Montellese commented 3 years ago

Thanks for the report. Do you know if the IP address you manually configured ends up in the discovery message broadcasted by the Emby server? Because the add-on simply gets the IP address from there. If that one isn't correct I'm not sure how the override IP could be retrieved from the Emby server since the add-on can't know how to access it. In that case a setting to manually change the URL would be the only way....

m4tt075 commented 3 years ago

Thanks for your quick response.

I'm not sure about where I can find the discovery message you mention. I've activated debug logging in kodi, but could neither find the actual server IP nor the hostname within it. If I need to look elsewhere, please do let me know...

What I do know though, is that this IP address should(TM) be announced somehow, at least if I believe the help text of the corresponding setting within the Emby server. It reads:

Optional. Überschreibt die lokale IP-Adresse, die der Server Emby-Apps zeigt. 
Wenn leer, wird der Server die lokale Netzwerkadresse ermitteln.

I'd freely translate that as:

Optional. Overrides the local IP address, which the server exposes to Emby-apps. 
When empty, the server will evaluate the local network address.

EDIT: I found some jellyfin documentation indicating that the discovery message is sent on UDP port 7359. I used wireshark to look into it. Apparently Emby uses that port for the discovery message, too. It seems to send an IP address, the client ID and the client name. It seems to contain the (wrong) bridge network IP though. So either the override IP is sent elsewhere, or there is a bug in the emby server. I'll start inquiring with them, too. If I learn anything new, I'll let you know...

Montellese commented 3 years ago

Thanks for the investigation and no need to translate German since I live in Switzerland ;-)

Yeah the discovery message contains the server's ID, name and IP address which is used by mediaimporter.emby to prepare the discovered media provider.

m4tt075 commented 3 years ago

No news from the Emby forum. I've found a workaround but still encountered unexpected behaviour. Here is why:

I actually still believe that the Emby server keeps broadcasting the wrong IP address and not what is defined via override. But could it also be that the server IP address is just evaluated once, on initial configuration? And if so, would it be better to update it whenever the access settings are entered in order to account for changed configurations?

Montellese commented 3 years ago

Thanks for the details. You are right, the mediaimporter.emby add-on currently doesn't support updating the URL / IP address of a discovered provider. It does detect changes to the name but not to the URL because that one is stored in the custom settings of the media provider. In that case manually deleting the media provider, restarting Kodi and waiting for the media provider to be properly detected would have solved the problem as well. But I agree that this is not very intuitive.

I'll have to look into this. Off the top of my head I can't think of a simple solution due to how the URL is stored.

Either way I think having the possibility to manually change the URL of a detected Emby server is a good idea. As mentioned by LongMan I've already done this for mediaimporter.plex so it shouldn't be too hard to add here as well.

m4tt075 commented 3 years ago

Thanks for the follow-up and your explanations. All makes sense.

And from additional reading on problems with network setups and autodiscovery on the Emby forum over the weekend, I also agree with your conclusion.

Many thanks for your great work and all your support on this!

Montellese commented 3 years ago

Can you give the improvement/change_url branch a try? It adds a button to the media provider settings which allows you to change the address / URL of the Emby server.

m4tt075 commented 3 years ago

Many thanks, @Montellese. I've tested your changes and can confirm that it's working.

Here my test in detail:

I still don't know why the Emby server is not broadcasting the override IP, but that is a bug or at least non-intuitive (to me) on their end.

Again, my sincere thanks for your work and contributions. I'm closing the issue as you've definitely fixed it. Thanks again.

Montellese commented 3 years ago

Thanks for the detailed feedback. I've pushed the commit to the master branch so it will be part of the next release.

m4tt075 commented 3 years ago

Just to close the loop: The Emby team have acknowledged the problem / inconsistency and promised that they will fix it with the next release. Then, the broadcast message should actually entail the IP address in the Emby server override. So, eventually, it seems we'll even have two solutions to the problem... :-)

Here the link for reference: https://emby.media/community/index.php?/topic/96249-emby-server-discovery-broadcast-ignores-network-override-setting/