audiobookshelf-app icon indicating copy to clipboard operation
audiobookshelf-app copied to clipboard

Unable to play off local server without internet connection

Open Jab2870 opened this issue 2 years ago • 29 comments

I have various wall mounted tablets and similar devices dotted around my house that are on my local network, but do not have wider internet access. The ABS server is accessible to them. However, I am unable to connect to it as the Android app checks for internet connectivity before logging into the serve.

Could the app attempt to connect to the specified ABS server, rather than the generic connectivitycheck.gstatic.com?

Jab2870 avatar Feb 09 '23 09:02 Jab2870

I don't know what you mean. I don't think there are generic connectivity checks. When you put in your server address there is a ping request sent to your server. If it responds then you can login.

advplyr avatar Feb 09 '23 10:02 advplyr

No. On the login form, the login button is replaced by a "No Internet" button that I can't push.

Jab2870 avatar Feb 09 '23 10:02 Jab2870

Oh. Maybe a bug then I will see

advplyr avatar Feb 09 '23 10:02 advplyr

image Here you go. This should demonstrate the issue

Jab2870 avatar Feb 09 '23 10:02 Jab2870

If I click "Add new server", I get the "No internet" button

Jab2870 avatar Feb 09 '23 10:02 Jab2870

So, to add a little bit more to this. I have set up my local DNS server to point connectivitycheck.gstatic.com to a web server on my local network. The ABS app now works as expected, so I think I can say confidently that somewhere, a request to that domain is being made to verify connectivity.

Jab2870 avatar Feb 09 '23 11:02 Jab2870

Must be yeah, we are using a capacitor plugin for the frontend network connectivity check. We'll probably need to replace that plugin and setup something native.

advplyr avatar Feb 09 '23 14:02 advplyr

I know that this has happened for me with other apps. @Jab2870 are you able to remove the local DNS entry so it stops working again, then turn off your Data connection on your phone (while connected to wifi still) and try to have the app connect?

Some apps try to be "smart" and it senses that there is no internet on the wifi so it switches to a Data connection (which when you are trying to do local connections is a dumb thing to do).

yuuzhan avatar Feb 11 '23 03:02 yuuzhan

So, the device I was using has no sim card so there is no way that it was doing anything other than wifi @yuuzhan

Jab2870 avatar Feb 11 '23 20:02 Jab2870

I took a look at the plugin and it just using the regular Android Connectivity Manager api to check for connection. This will need to be investigated further by seeing what info the connectivity manager is returning in this instance.

advplyr avatar Feb 12 '23 18:02 advplyr

Strange...

Please let me know if there is anything else I can do to assist with this then.

Jab2870 avatar Feb 14 '23 09:02 Jab2870

Hi there,

had the same Problem...

Made a Blocking group in my Pi-Hole wich blocks all DNS Querrys with a "." in it. -> Everything to Internet is Blocked. Then made a Whitelist with some entry's like "(.|^)antolin.de$".

App won't show login due Android "Online" checks !

So what i did on my side was following:

  • Disabled WiFi on my Android Tab
  • Opened Live Query's on Pi-hole (on second device) and set a filter for affected device to see blocked query's.
  • Enabled Wifi and checked logs.

In my case (FireHD10) the DNS query for online check is "tabletcaptiveportal.com" -> After whitelisting that, the app login works again. ;-)

C3POH2SO4 avatar Feb 16 '23 08:02 C3POH2SO4

So is there a Fix for this? Do I need to put in DNS entries to resolve back to my server just to get this to work? I only have this issue when my internet is down and honestly cant see why you would ever do a external dns call to validate connectivity.

GuyverFX avatar Nov 30 '23 01:11 GuyverFX

I read another article in this chain (see below) and disabling a phones internal process to bypass a application dependency is not a solution but a workaround. Dont get me wrong, thanks for the information but any workaround could have other unintended impacts due to that change being in the android OS. The application is making that check dependent for itself before functioning.

Trick is to bypass this check by running the following command in ADB shell of the your Android device which is either not connected to the internet or Google's DNS is blocked at firewall level:

settings put global captive_portal_mode 0

GuyverFX avatar Nov 30 '23 01:11 GuyverFX

It seems like one solution would be for the app instead of disabling the sign in button, just say "You don't appear to be online. Attempt connection anyway?" And let the user override it.

hobesman avatar Dec 02 '23 01:12 hobesman

I had the same problem and I can confirm that @GuyverFX 's workaround is working for me.

Here are the steps I used:

  1. Enable developper options
  2. Enable USB debugging
  3. Connect phone to PC and run adb shell in PC's terminal
  4. In adb shell: settings put global captive_portal_mode 0
  5. Restart phone

App version: v0.9.71-beta

xarath avatar Feb 02 '24 01:02 xarath

This work around doesn't really scale. Or at least it's kind of a pain and it may get reset in the future.

I have a couple of tablets that I use ABS with and they all experience this problem. I might use the ADB route but it is not ideal

stratus-ss avatar Feb 28 '24 14:02 stratus-ss

@stratus-ss

I mentioned a much more scalable solution earlier that I use. I have set up my local DNS server to point connectivitycheck.gstatic.com to a web server on my local network which solves the problem.

The relevant part of my nginx config is:

server {
    listen       80;
    listen  [::]:80;

    server_name          connectivitycheck.gstatic.com;

    location / {
            return 204;
    }
}

Jab2870 avatar Feb 29 '24 22:02 Jab2870

That's an interesting solution. I could even use a vhost on the server ABS is running on. If apache is down on the ABS server, ABS isnt going to work anyways.

Thanks for the tip!

stratus-ss avatar Feb 29 '24 23:02 stratus-ss

0.9.73-beta ... no internet, no login on local IP ...

skyzuma avatar Apr 05 '24 16:04 skyzuma

Same issue here. I like the idea of allowing the user to attempt the connection anyway, most of us know what we are doing as we are all fiddling with containers and all sorts of other self hosted stuff anyway. Devices bound to local network access only are quite common.

Great to see a work around, going to update my local Bind with that..

Update : Have nginx up and running, curling http://connectivitycheck.gstatic.com returns a 204 (so does any path under that host) and yet my galaxy tab a still says there is no internet connectivity and audiobookshelf client still won't let me connect to a local server...

nrjohnstone avatar Jun 21 '24 05:06 nrjohnstone

@nrjohnstone - can you see what it is trying to connect to? I believe amazon devices try to connect to something amazon owned, it wouldn't surprise me all that much if Samsung also had a domain they used. Easiest way is probably to look at dns requests if you have a pi hole or similar set up. Failing that you could try wireshark although you'll have to hunt through a lot of junk to find what you want. Also make sure your samsung device is using your dns resolver.

Jab2870 avatar Jun 21 '24 08:06 Jab2870

Internet checking in the Network.java file has been removed. Attached is the file itself for self-build and the builded apk version 0.9.4. MOD_no_check_internet.zip

upais avatar Jul 12 '24 12:07 upais

I would really appreciate if the check gets removed. I try to get ABS connect to a server that is accessible through a Wireguard VPN. On one phone (Oneplus) that works as expected, on another phone (Samsung Galaxy A5) it fails. When the phone was in the same network, it could just connect to the local IP. But now that it is in another network, it needs the VPN and a new connection entry. The form to add a new connection is disabled as soon as I connect to the VPN. The internet is working fine (everything gets resolved as usual, only the ABS server is reachable by its IP). I don't understand why the online check fails. But I also don't know why this check prevents an attempt to login.

Please remove the online check or make it non-blocking :pray:

Tobsic avatar Aug 07 '24 14:08 Tobsic

I would consider adding a small bounty to this if ABS has bug bounties

stratus-ss avatar Aug 08 '24 19:08 stratus-ss

I just ran into this issue too. Samsung Galaxy phone - ABS reports no network, and will not let the on-screen keyboard come up.

Disconnecting temporarily from the VPN allows you to pull up a keyboard and enter the URL. Then reconnecting the VPN instantly causes ABS to revert back to "No network connection" and you cannot submit the URL. So is the network connectivity check running continuously?

The VPN is the only way to connect to the ABS instance.

I reviewed the workarounds but reluctant to reroute connectivity checks for every device on my LAN just to avoid this.

I'm curious why does the app do a connectivity check at all? Just let it try to access the server and fail if there's no network. I do not have this issue with other selfhosted servers and their accompanying apps.

zzyzx-dc avatar Aug 26 '24 16:08 zzyzx-dc