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.5k stars 6.3k forks source link

Kodi WebServer fails to start on Android with no Internet connection #16041

Closed D3VL-Jack closed 10 months ago

D3VL-Jack commented 5 years ago

Bug report

Describe the bug

Kodi WebServer fails to start on Android devices where no internet connection is present.

Under windows, Without an internet connection the WebServer is allowed to start.

Expected Behavior

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

The WebServer should be allowed to start on devices without an internet connection to allow for other local services & plugins to access Kodi's JSON-RPC via localhost

Actual Behavior

When Kodi starts without an internet connection, a error message is displayed informing the user that the WebServer failed to start

Possible Fix

To Reproduce

Steps to reproduce the behavior:

  1. Obtain an Android Device
  2. Disable Data & WiFi
  3. Open Kodi
  4. Attempt to start the WebServer (Settings -> Services -> Control -> Allow remote control via HTTP)

Debuglog

The debuglog can be found here: N/A

Screenshots

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

N/A

Additional context or screenshots (if appropriate)

Here is some additional context or explanation that might help:

N/A

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.

xbmc-gh-bot[bot] commented 5 years ago

Thank you for using Kodi and our issue tracker. This is your friendly Kodi GitHub bot :wink:

The issue that you have opened was marked as ignoring the rules of our bug tracker by a team member. Please review the following requirements for issue reports and make sure that you follow all of them:

Please understand that adherence to these rules is required for the team to be able to handle the volume of open issues efficiently. The issue will be closed after one week has passed without satisfactory follow-up from your side.

ritiek commented 5 years ago

I was able to reproduce the problem as @Jack-Rogers.

I tried to enable the webserver with mobile data and WiFi turned off but it gave me this error:

kodi_webserver_error

and the option was automatically turned back to off upon receiving this error:

kodi_option_turns_off

Here is the log while me doing all this: kodi_webserver_failed.log


I then connected to a WiFi network, restarted Kodi and was successfully able to enable the webserver. Here is the log for starting the webserver successfully: kodi_webserver_success.log

I compared both these logs and it looks like when WiFi and mobile data is turned off, the value of Local hostname is set to [unknown] (see logs). I dunno the best solution here but we could probably fallback to 127.0.0.1 if there is no network available rather than [unknown].

DaVukovic commented 5 years ago

@ritiek

You have banned add-ons/repositories installed. Please remove them and provide a new log.

Thanks in advance.

ritiek commented 5 years ago

@DaVukovic Sorry about that, I've updated my previous post with new logs.

DaVukovic commented 5 years ago

@ritiek sorry for the delay.

I labeled this issue now and asked a team member. Generally I don't see a reason to start the webserver if no network connection can be established.

I don't know enough about Android network management and if there's a loopback adress or not. Maybe @peak3d is able to answer that.

ritiek commented 5 years ago

No problem! Let me know if you need any more information.

peak3d commented 5 years ago

@ritiek it makes not much sense to fallback to localhost / 127.0.0.1, because kodi will not be reachable from outside (and the web server should be reachble, right?). Either way there must be a proper implementaion which restarts all TCP server if a network change occurs. Not sure if / how this is implemented currently.

What happens, if you plugin / enable network after a failed start?

ritiek commented 5 years ago

it makes not much sense to fallback to localhost / 127.0.0.1, because kodi will not be reachable from outside (and the web server should be reachble, right?).

@peak3d Yup, Kodi will indeed not be reachable from outside in case it listens on 127.0.0.1 (localhost).

But also as @Jack-Rogers mentioned in the original issue:

The WebServer should be allowed to start on devices without an internet connection to allow for other local services & plugins to access Kodi's JSON-RPC via localhost

And I think instead of 127.0.0.1, we could also fallback to 0.0.0.0 (listen to all interfaces). That way Kodi will also be able to communicate atleast with other local devices connected to the Android device's hotspot (without mobile data turned on).

Either way there must be a proper implementaion which restarts all TCP server if a network change occurs. Not sure if / how this is implemented currently.

Yup, that would be nice.

What happens, if you plugin / enable network after a failed start?

I'll check it and report back soon. Looks like it shows the "Failed to start" error only when attempting to enable the webserver without connected to either WiFi or Mobile Data. After connecting to a WiFi or Mobile Data and then re-enabling the webserver (without restarting Kodi) works fine.

teamonce commented 4 years ago

Any news? that bug still continues :S,

I use a kodi launcher, and kodi starts faster than the lan/wifi, having the failed start webservice problem

lacek commented 4 years ago

Having the same issue. I use Launch on Boot to start Kodi when the Android TV boots. When configured to use cable network, the error seldom occurs. When configured to use WiFi instead, the error occurs almost every boot.

Two of workarounds I could think of are:

  1. Listen for network state change and start the serve only when network is available.
  2. Retry web server start up with some reasonable interval for a few times before announcing failure.
SamJongenelen commented 3 years ago

I also use launch on boot on android tv, over wifi and experience this non starting http server frequently recently.

A third workaround for me would be to optionally delay start the webserver by n seconds.

pgcd commented 3 years ago

I have a different use case: I use my phone to connect to my a tablet's hotspot while driving, so my children can watch shows on Kodi; since I store the videos on the tablet itself, I don't need any external connection - and Kodi should be able to start the webserver regardless of Internet connection. As it is, it seems that I can start the server while connected to Wifi and then turn the hotspot on, but it's a bit cumbersome.

diogosena commented 10 months ago

This still hapenning consistently, kodi should be able to detect network changes and try to start webserver.

thexai commented 10 months ago
  1. Obtain an Android Device
  2. Disable Data & WiFi
  3. Open Kodi
  4. Attempt to start the WebServer (Settings -> Services -> Control -> Allow remote control via HTTP)

This is inherent to how TCP/IP works: to start a web server it is necessary to have a valid IP address assigned (no Internet connection is necessary).

If data and WiFi are disabled on a mobile (there is no Internet or local network) there is no IP to start any server.

This by itself is not a bug...

It can be implemented "listen network change events" and re-start services if is detected a change from not valid IP to valid IP... but this is a feature/improvement.

pgcd commented 10 months ago

This is inherent to how TCP/IP works: to start a web server it is necessary to have a valid IP address assigned (no Internet connection is necessary).

You can start a web server on 0.0.0.0, though. I do it daily in my dev VMs.

(Kodi might not want to do it for other reasons, but it's definitely not a TCP/IP problem)

D3VL-Jack commented 10 months ago

Closing this (after 5 years) is counter productive. It's a valid issue on android, a behaviour that (as far as I know) is handled properly on other platforms.

If data and WiFi are disabled on a mobile (there is no Internet or local network) there is no IP to start any server. - This is factually incorrect. As noted above, you can listen on all interfaces 0.0.0.0, then other local apps can still target 127.0.0.1. Just because networking is disabled, does not mean that the concept of a network stack just disappears.

thexai commented 10 months ago

"WebServer fails to start on Android with no Internet connection" is bad formulated as OP says "WebServer fails to start on Android with no valid IP address" and this is no a bug.

Is not possible bind a TCP server without valid/reachable IP. If device not has connectivity (Disable Data & WiFi) What's the point of having a server?

D3VL-Jack commented 10 months ago

"If device not has connectivity (Disable Data & WiFi) What's the point of having a server?"

Other local applications that may want to control, or (if memory serves) our original case for making this issue, a python plugin within kodi using the RPC api.

pgcd commented 10 months ago

Is not possible bind a TCP server without valid/reachable IP. If device not has connectivity (Disable Data & WiFi) What's the point of having a server?

In my case I did have local connectivity and an IP address - just no Internet connectivity. And the point is, as mentioned, to be able to control it from another device on the same local network.

thexai commented 10 months ago

In my case I did have local connectivity and an IP address - just no Internet connectivity. And the point is, as mentioned, to be able to control it from another device on the same local network.

Then provide debug log demonstrating that Kodi on device with valid local IP address (e.g.: 192.168.1.x) with connectivity on local network can not start a web server.

pgcd commented 10 months ago

In my case I did have local connectivity and an IP address - just no Internet connectivity. And the point is, as mentioned, to be able to control it from another device on the same local network.

Then provide debug log demonstrating that Kodi on device with valid local IP address (e.g.: 192.168.1.x) with connectivity on local network can not start a web server.

I'd be happy to, although it would've been much easier three years ago when I had the actual setup I was talking about. But it's outside the scope of the issue (which mentions no connectivity at all) and, frankly, I don't feel the need to score points with you, especially not after you've been moving targets to justify closing a 5yrs old issue ("it's TCP/IP" -> "well it's useless anyway" -> "oh then provide debug logs").

Do whatever you want, I'm no longer affected by the specific problem and rude open source maintainers contributors don't put any bread on my table. =)