Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: wpa_supplicant randomly disconnects (Read 1193 times) previous topic - next topic
0 Members and 6 Guests are viewing this topic.

wpa_supplicant randomly disconnects

Hi everyone,

I am running Artix on my ThinkPad X220 and wrote a simple script to connect to my institution's Wi-Fi network w/ wpa_supplicant:

Code: [Select]
#!/bin/bash

wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
dhcpcd

I can establish the connection when executing the script. However, the connection is fairly unstable and sometimes randomly disconnects. I tried installing iw and running:

Code: [Select]
# iw wlan0 set power_save off

according to this thread, but that didn't work. I would like to solve the problem in order to stick w/ wpa_supplicant, since I try to avoid GUI programs as much as possible on this machine. Any hint?

Thanks in advance :)

Re: wpa_supplicant randomly disconnects

Reply #1
This table describes the supported features of wireless network configuration utilities. iw, iwd and wpa_supplicant support different wireless standards.

There are service packages for both wpa_supplicant and dhcpcd for all init systems, so you don't need custom scripts. Install wpa_supplicant-your_init and dhcpcd-your_init, replacing your_init with the moniker of your init, for example openrc, suite66, etc and enable and start the appropriate services.

Have you read Wireless#Random disconnections? (Replace systemd-specific commands/features, such as "journal" with those applicable to your init, of course. In this case, logs.)

Re: wpa_supplicant randomly disconnects

Reply #2
I am using runit. I installed and enable both wpa_supplicant-runit and dhcpcd-runit (thank yo for the suggestion).

To investigate more about the disconnections, I looked for the log directory of wpa_supplicant under /etc/runit/sv/wpa_supplicant but could not find it. According to the wiki, this happens for some services. I assume that's were logs are supposed to be stored, but I may be wrong...?

Re: wpa_supplicant randomly disconnects

Reply #3
To investigate more about the disconnections, I looked for the log directory of wpa_supplicant under /etc/runit/sv/wpa_supplicant but could not find it. According to the wiki, this happens for some services. I assume that's were logs are supposed to be stored, but I may be wrong...?
The directory /var/log is the default traditional location for log files. For wpa_supplicant, if you use a logging service such as syslog-ng (installed by default by graphical installer), you can filter the catch-all everything.log:
Code: [Select]
grep wpa_supplicant /var/log/everything.log | tail
or search the specific string. For example, to look for "wlan0" from the article:
Code: [Select]
grep wlan0 /var/log/everything.log | tail

Re: wpa_supplicant randomly disconnects

Reply #4
you can filter the catch-all everything.log:

Thank you. In order to generate/access that file, I suppose I have to install syslog-ng and (maybe) syslog-ng-runit (and enable it), am I correct? (I haven't installed this system through a graphical installer). Will this automatically generate the everything.log file?


Re: wpa_supplicant randomly disconnects

Reply #6
Thank you. In order to generate/access that file, I suppose I have to install syslog-ng and (maybe) syslog-ng-runit (and enable it), am I correct? (I haven't installed this system through a graphical installer). Will this automatically generate the everything.log file?
First, check if the file /var/log/everything.log is there. If it is not, install, enable and start syslog-ng service. Then try to start wpa_supplicant and connect to the Internet. When the connection drops, try filtering /var/log/everything.log again.

You can also try a different kernel as rayburn suggested.

Re: wpa_supplicant randomly disconnects

Reply #7
Wireless connections do drop out briefly due to interference and vehicles / people / you moving about or the router losing it's connection for a while, that's a normal situation. The question is what happens when that occurs. In a simple script usage dhcpcd won't reconnect while dhclient will. This isn't a problem if you use dhcpcd as the backend to network manager because network manager  obviously does some extra stuff (I don't know what) to reconnect. So if that's the problem just use dhclient, it works much better in it's out of the box state, it's an older project so has better cli support.
 You can get problems relating to wifi card model / driver and router model if this is something beyond the ordinary dropouts though, that could be due to updates of firmware, driver / kernel, or even, I suspect, router firmware which might update itself automatically.


 

Re: wpa_supplicant randomly disconnects

Reply #9
But the service just starts dhcpcd with it's default settings.
If you install dhclient, no need to run it as a service, just make an empty dhclient.conf file and I start it like this:
Code: [Select]
dhclient -v -cf /some/where/dhclient.conf (iface name)

all the service does:
#!/usr/bin/openrc-run
# Copyright 2007-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

command=/usr/bin/dhcpcd
#pidfile=/run/dhcpcd/pid
supervisor="supervise-daemon"
command_args_foreground="--nobackground"
command_args=-q
name="DHCP Client Daemon"

depend()
{
        provide net
        need localmount
        use logger network
        after bootmisc modules
        before dns
}

Might be something else, but it's easy to try anyway. I think network manager does some stuff via dbus or something to dhcpcd to make it do what it wants, don't know exactly how it works.

Re: wpa_supplicant randomly disconnects

Reply #10
But the service just starts dhcpcd with it's default settings.
Process supervisor ensures the service is constantly up, so if the dhcpcd process terminates, it restarts it. But dhcpcd can handle reconnects itself. See this thread, for example:

https://bbs.archlinux.org/viewtopic.php?pid=1478577#p1478577

P.S: mayfrost's "Alternatives to bloatware" guide lists dhcpcd after dhclient (meaning it is less bloated). One can also count the dependency tree:
Code: [Select]
$ pactree -u dhclient | wc -l
70
$ pactree -u dhcpcd | wc -l
43

Re: wpa_supplicant randomly disconnects

Reply #11
Well it was a few years now since I used dhcpcd much so it could have improved, although that thread was 2014 so older than my experience, and dhclient definitely was better at reconnecting and also even initially connecting when things were suboptimal. With a good strong steady signal it was fine and you wouldn't notice any difference, I used dhcpcd for a few years quite successfully, but sometimes I would end up having to manually stop and restart the connection whereas dhclient just seems to work without any need for intervention. I think there is just a preset strategy of sending requests, waiting for replies, timeout pauses and so on, and dhclient ships with a better default for simple use than dhcpcd, although obviously given the way dhcpcd works with other net gui things then there is nothing essentially wrong with it, it would just need more configuration to do whatever dhclient does as standard. dhclient was originally designed to work with cli things like ifupdown so is less minimal because it has more inbuilt functionality, and was one part of a set of server tools so has support for those too.