xbmc / xbmc

Kodi is an award-winning free and open source home theater/media center software and entertainment hub for digital media. With its beautiful interface and powerful skinning engine, it's available for Android, BSD, Linux, macOS, iOS, tvOS and Windows.
https://kodi.tv/
Other
18.56k stars 6.3k forks source link

UPNP not working on Fire Stick v2, wrong 192.168.49.1 address #14743

Closed dazad closed 1 year ago

dazad commented 6 years ago

Bug report

UPNP Server and/or Receiver does not work on Amazon Fire Stick v2, appears to be using incorrect 192.168.49.1 address

Describe the bug

Here is a clear and concise description of what the problem is:

If Kodi is configured as a UPNP Server and/or UPNP Receiver on an Amazon Fire TV Stick v2 it is not visible to any other UPNP enabled devices. The same configuration works as expected on Windows 7 and Android tablets but not on Android Fire TV Stick v2. Until a year ago I had a Fire TV Stick v1 and on this device UPNP Server and Receiver worked correctly. The Fire TV Stick v2 has never worked for UPNP despite trying Kodi 17.6, 18 betas and many nightly builds up to 29/10/18. I have tried many factory resets and clean installations.

Kodi.log debug log appears to show references to IP address 192.168.49.1 which is the Fire Sticks Wifi Direct IP address that it uses to connect to the remote. My Fire TV Stick v2 uses IP address 192.168.0.25 on its network WiFi port which functions correctly for HTTP and Airplay connectivity.

Expected Behavior

Here is a clear and concise description of what was expected to happen:

With Kodi configured as a UPNP Server and/or UPNP Receiver it should be possible to stream video to or from an Amazon Fire TV Stick v2 but this is not possible.

Actual Behavior

Amazon Fire TV Stick v2 is not visible to any other UPNP configured device including Kodi on Windows 7 & Android Tablet, and Android Tablet using 3rd party apps such as Bubble Upnp, AllCast, Power Media Player, VLC

Possible Fix

Kodi debug log references IP address 192.168.49.1 (Wifi Direct address for remote control). Is Kodi just picking up wrong address/interface for UPNP but correct one for HTTP & Airplay?

To Reproduce

Steps to reproduce the behavior:

  1. On Fire TV Stick v2 enable following options under UPnP/DLNA settings: Enable UPnP support Share my libraries Announce library updates Look for remote UPnP players Allow remote control via UPnP

  2. On another device (Windows/Android) attempt to add new UPnP file source. Fire TV Stick v2 will not be visible

  3. On another device (Windows/Android) attempt to "Play Using" a video to the Fire TV Stick v2 but it will not be visible.

Debuglog

The debuglog can be found here: https://paste.kodi.tv/fuciwonoru.kodi

Screenshots

Here are some links or screenshots to help explain the problem:

Additional context or screenshots (if appropriate)

Here is some additional context or explanation that might help:

Your Environment

Used Operating system:

note: Once the issue is made we require you to update it with new information or Kodi versions should that be required. Team Kodi will consider your problem report however, we will not make any promises the problem will be solved.

ghost commented 6 years ago

I also see this issue on a Windows PC with 18 RC1 where discovery only happens right after Kodi is started. For some reason, the UPNP server on Kodi doesn't stay discoverable if say, Kodi is on for hours at a time. It only seems to be discoverable on other devices for a short period of time after Kodi is started.

dazad commented 5 years ago

Today I've got hold of an old Fire Stick v1 and have been able to do some comparison testing between the Fire Stick v1 and v2 using the same Kodi configuration options on both.

On the Fire Stick v1 UPnP Server and Receiver both work on Kodi 17.6 but don't work on Kodi 18 RC3 or the latest nightly build 20181216. On the Fire Stick v2 I am still unable to get UPnP Server or Receiver to work on any build including 17.6, 18 RC3 or the latest nightly build 20181216. I suspect this is partly due to it trying to use the 192.168.49.1 Wifi Direct address from the remote

I can get the Fire Stick v2 to function as a UPnP Server using an App called DLNA Server and as a Receiver using an App called AirPlay/DLNA Receiver (LITE) both from the Google Play Store. It would be good to get this working through Kodi though without the need for other/extra apps.

I'm particularly interested in getting UPnP Server and Receiver working using Kodi on Fire Stick v2. Has anyone had any success with this and if so how?

dazad commented 5 years ago

I've recently got a new phone which supports screen cast/miracast and have been testing it using an Amazon FireTV Stick v2. During testing I came across the following... Once connected to the Firestick in a miracast I can see Kodi as a UPnP device but running on 192.168.49.1 not the 192.168.0.25 IP address the Fire Stick is configured for. As suggested when I originally raised this issue I believe in the case of UPnP Kodi is using the wrong interface/IP address but for all other services SMB, HTTP, Airplay it is using the correct interface/IP address. I believe the 192.168.49.1 address relates to the Fire Sticks Wifi Direct IP address that it uses to connect to the remote and now also in some way for Miracast.

Is there a way, xml file setting or similar, to override this behaviour to force kodi to use the correct interface/IP address on a fire tv stick v2?

thanks

Montellese commented 5 years ago

AFAIK the decision which interface to use is hidden deep within the Planimum SDK Kodi uses for UPnP because I had noticed this issue two or so years ago as well. But I just looked into the Platinum code again and it actually looks like it's trying to join the respective multicast group on every interface, see https://github.com/xbmc/xbmc/blob/master/lib/libUPnP/Platinum/Source/Core/PltUPnP.cpp#L172. But then it looks like Kodi only creates the server and renderer on the first interface / IP address it finds, see https://github.com/xbmc/xbmc/blob/d92d5d1b356d8f2a991570a251f56948819b3758/xbmc/network/upnp/UPnP.cpp#L423-L431.

dazad commented 5 years ago

Thanks for the information Montellese, I was starting to think only I was seeing this problem despite lots of people running Kodi on FireTV.

Is this something that can be fixed in a future build?

stianhaugli commented 4 years ago

hi.. thanks to this thread - i managed to connect to upnp servers in kodi (running on the new fire tv stick with voice remote). it is exactly as dazad says, .. Kodi/upnp uses the remotes wifi direct 'socket/connection as the upnp listening device. my workaround is: remove the remote from fire tv (settings/remote etc/remove..) .. as you cant remove the remote currently in use, you have to installe the remote app from the play store on an android mobile and use that to get rid of the voice remote.. then restart the FTV stick and start kodi - voilla, kodi now it sees upnp/dnla servers. i have later added my voice remote back again and the workaround seems to persist, .. i suspect the remote became the 1st available "wifi socket" as its added before the wifi netork during initial setup of the firetv stick. then by removing the remote and adding it back it gets a sequential id higher than my local network... and it seems to work.. if this is true, you may have to remove and re add the remote control again every time the stick is connected to a new wifi network.. it is def. a bug as kodi should confirm it is listening over the correct connection, not just jump on the first available.

numbermonkey commented 3 years ago

Still an issue here in Apr 2021. But the process described above does solve the issue 1 Install one of the smartphone/tablet "Fire TV" (by Amazon) apps and use it to turn your phone/tablet into a remote 2 Using it, remove your existing remote. You do this under Settings..Remotes. Go into Amazon Fire TV Remotes, highlight the one you need to remove, press the three line button and then read the prompt to unpair the remote 3 Restart the stick and then start Kodi. Problem instantly solved. 4 Quit Kodi then re-add your remote.

itcsburnett commented 3 years ago

I just discovered this. While I didnt check the IP when I first installed, I was able to navigate and attach a SMB NAS share and it populated the content. A few days later, I noticed the system hanging while trying to update the media database. That's when i went into the system information and noticed the 192.168.49.1 address. I am guessing that during install, it picked up the correct IP from the FireStick, but upon restart it picked up the sticks wifi direct.

Sadly, the updated FireTV App on IOS or perhaps the Firestick itself doesnt allow me to remove the Amazon Remote following the above instructions. the three line button on the IOS app interface does nothing

clownshoes19 commented 3 years ago

Here's a patch for optionally choosing NIC via advancedsettings.xml: advancedSettingsNIC.txt and an example advancedsettings.xml for Fire TV Stick 4K.

<advancedsettings version="1.0"><network><defaultInterfaceName>wlan0</defaultInterfaceName></network></advancedsettings>
clownshoes19 commented 3 years ago

Here's a build of 18.9: https://drive.google.com/file/d/1yH3tHkEQK2J7_JARPz0A5kRq-RPI2-Fd.

clownshoes19 commented 3 years ago

I should note that even without the advancedsettings.xml I see in the logs (added logging below) its picking the right IP; however, I have to restart the Kodi UPnP server while the client is scanning.

2021-11-28 13:10:36.507 T:4904  NOTICE: Detecting NIC
2021-11-28 13:10:36.512 T:4904  NOTICE: Previous line repeats 1 times.
2021-11-28 13:10:36.512 T:4904  NOTICE: UPnP using IP 192.168.0.8

vs.

2021-11-28 13:12:54.436 T:7464  NOTICE: Using NIC wlan0
[...]
2021-11-28 13:12:54.523 T:7464  NOTICE: UPnP using IP 192.168.0.8
+  if (CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_defaultNetworkInterfaceName.empty()) {
+    CLog::Log(LOGNOTICE, "Detecting NIC");
+    for(CNetworkInterface* intf : m_interfaces)
+    {
+      if (intf->IsEnabled() && intf->IsConnected() && !intf->GetCurrentDefaultGateway().empty())
+        return intf;
+    }
+  } else {
+    CLog::Log(LOGNOTICE, "Using NIC %s", CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_defaultNetworkInterfaceName);
+    return CNetworkBase::GetInterfaceByName(CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_defaultNetworkInterfaceName);

     else if(m_IP.empty())
         m_IP = "localhost";

+    CLog::Log(LOGNOTICE, "UPnP using IP %s", m_IP);
+