Wifi does not reconnect if router was gone

I think I found a possible solution. There is indeed a setting for autoconnect:

nmcli connection show my-network

returns

connection.autoconnect:                 yes
connection.autoconnect-priority:        0
connection.autoconnect-retries:         -1 (default)

So, autoconnect is enabled by default, BUT what is the default for autoconnect-retries? :slight_smile:

The nmcli docs state:

The number of times a connection should be tried when autoactivating before giving up. Zero means forever, -1 means the global default (4 times if not overridden).

Four? Why four? Why not 42? What kind of default is that supposed to be?
Kind of “Please try, but not that hard.” :slight_smile:

The command to set it to forever is

nmcli connection modify my-network connection.autoconnect-retries 0

nmcli connection show my-network
> connection.autoconnect-retries: 0 (forever)

You can also modify the parameter using the “my-network” file on SD or USB:

[connection]
...
type=wifi
autoconnect=1
autoconnect-retries=0

Also be sure to check the NetworkManager logs to identify reasons for the connection loss, e.g. if the router kicks you out or whatever:

journalctl -u NetworkManager -n 100 --no-pager

I saw that
cat /etc/NetworkManager/NetworkManager.conf

also shows an entry

[main]
autoconnect-retries-default=0

but that did not apply to the connections (but not sure if it should).

6 Likes