ubports / ubuntu-touch

Ubuntu Touch's issue inbox is now migrated to GitLab.
https://gitlab.com/ubports/ubuntu-touch
1.28k stars 110 forks source link

Check WiFi status when connected and ignore if no data flows #885

Open zubozrout opened 5 years ago

zubozrout commented 5 years ago

Feature request: There is this issue with some WiFi networks people have in the list of known networks because they may have already connected to them in the past but those requiring to sign in via some kind of a web form via web browser makes these networks useless if you just pass by or don't necessarily want to spend the time going through the login form.

I mean this happens to me quite a lot ... For instance with public transport WiFi hotspots. And if I just take a few stops by a tram or a bus just passes by I don't want Telegram and other services to just stop working during that time.

For example on Android this is being handled quite well at least since 5.x came around and if a network with no data is present mobile data are not blocked. Ideally you want to be able to use the network with no external network connection as you may want to communicate just locally but simultaneously retain all data functionality on a phone.

If there is some kind of a web form present a popup in a form of notification could also rise up to inform user about that. And not only Android does that but also the current Ubuntu 18.04 with Gnome so maybe some implementation of that could be taken from over there.

In any case I am just placing it here since I don't think it has been already mentioned and since it is a long time present issue I am bumping into quite often.

Thank you very much for all you can do about this :).

Flohack74 commented 5 years ago

The real problem here is the upstream Ubuntu NetworkManager. It will automatically try to connect to any network it knows. I already discussed this with people there, to a) make it possible to give priorities to entries, and b) to activate the manual connect as standard, unless we request automatic. Well its not so easy. They dont see the this as necessary, since it is only important for mobile devices. NetworkManager is fully made only for laptops that you dont want to change networks during motion maybe. Even there it is annoying, but acceptable. So this will take much longer to resolve, it goes deep into what we take from upstream, and its currently not really in our maintenance :)

zubozrout commented 5 years ago

I've just got a reply from thaller on NetworkManager's IRC.

He said: "that mostly works. If connectivity check is enabled, NetworkManager will penalize the default-route which provides no connectivity" and: "if you test this, NM will add 20000 to the default-route's metric... e.g. on wi-fi the route-metric defaults to 600. So, you'd get 20600 -- compared to 700 (the default on WWAN)"

In order to do this it seems that some things need to be set up:

  1. it must be compiled with that support and I am not sure that support is in Ubuntu - but to make this easier I hope it is.
  2. A web server with a web page must be set up following the manual: "This page should return the header "X-NetworkManager-Status" with a value of "online". Alternatively, its body content should be set to "NetworkManager is online". The body content check can be controlled by the response option. If this option is blank or missing, connectivity checking is disabled."

Sources: https://manpages.debian.org/unstable/network-manager/NetworkManager.conf.5.en.html#CONNECTIVITY_SECTION https://mail.gnome.org/archives/networkmanager-list/2017-August/msg00012.html https://bugs.archlinux.org/task/35342

zubozrout commented 5 years ago

Hm, it should even be possible to notify user a so-called captive poral is present: https://wiki.archlinux.org/index.php/NetworkManager#Checking_connectivity - which must be what the latest Ubuntu 18.04 with Gnome desktop at least does.

zubozrout commented 5 years ago

Oh, and these two packages exist on Ubuntu 18.04 :)

network-manager-config-connectivity-debian network-manager-config-connectivity-ubuntu

https://unix.stackexchange.com/questions/375748/what-will-network-manager-config-connectivity-debian-do

Flohack74 commented 5 years ago

Ok cool let me dig into this a bit :) - Its very annoying now for me, I have to open a web browser multiple times a day in my new office to log in...

Flohack74 commented 5 years ago

I am currently in touch with the network manager guys and they told me that NM should have support for this already - so I will try to check if it does and how it reacts on changed networks.

zubozrout commented 5 years ago

Right, it may be so as I've only guessed based on the fact I don't see anything related to connectivity in Ubuntu 16.04's nm-related man page while I see that for 18.04.

dobey commented 5 years ago

Correct. Using NM's connectivity testing stuff would require a backport to 16.04 and all the work to integrate that into the unity8 stack, while ensuring other things don't break.

Flohack74 commented 5 years ago

Hmm maybe not, I set it up locally and it was actually doing its job quite fine:

root@ubuntu-phablet:~# tail /var/log/syslog  -f | grep connectivity
Nov 23 22:58:03 ubuntu-phablet NetworkManager[1774]: <debug>
[1543010283.5003] connectivity: check: send periodic request to
'http://connectivity-check.ubuntu.com/'
Nov 23 22:58:03 ubuntu-phablet NetworkManager[1774]: <debug>
[1543010283.8697] connectivity: check for uri
'http://connectivity-check.ubuntu.com/' with Status header successful.
Nov 23 23:03:03 ubuntu-phablet NetworkManager[1774]: <debug>
[1543010583.4998] connectivity: check: send periodic request to
'http://connectivity-check.ubuntu.com/'
Nov 23 23:03:03 ubuntu-phablet NetworkManager[1774]: <debug>
[1543010583.8536] connectivity: check for uri
'http://connectivity-check.ubuntu.com/' with Status header successful.

However, it happens only by time, not by bringup of a new connection. I am asking now NM guys how this could be added. BTW I might travel to Brno in Jan, to meet them in person. They are very responsive and posssitive about supporting us.

So I think when this event is exposed on DBus its easy to catch, create a local notification which includes the URL from the check. This would open the browser on clicking, redirecting the client to the captive portal and you can log in ;)