Wifi randomly disconnects

remove tlp
reboot

or use tlpui to change tlp wifi powersave

2 Likes

The problem still persists :frowning_face:

please go to terminal and type these commands and post the outputs.

inxi -Nn
rfkill list

Also do you have secure boot enabled if so disable it.
If you have bluetooth disable that also and see what happens.

I would recommend installing timeshift and making a backup of your system. Then I would suggest installing Connman and mask Network Manager.

As this is a problematic USB adapter with poor drivers in Linux you may want to consider replacing it.

1 Like

inxi -Nn

Network:
  Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet 
  driver: N/A 
  Device-2: Realtek RTL8188CUS 802.11n WLAN Adapter type: USB 
  driver: rtl8192cu 
  IF: wlp0s18f2u2 state: up mac: 80:1f:02:d7:16:f9

rfkill list

0: phy0: Wireless LAN
	Soft blocked: no
	Hard blocked: no

If you do not want to replace this adapter you could test this service I wrote:

Not a solution by any means, but an adequate workaround in that it will reestablish a dropped connection in Aprox 5 secs. This is adequate for most Internet usage except online gaming. If that is your use case I again suggest you may want to buy a faster more reliable adapter.

2 Likes

This looks great, I hope it works!

With what driver module do I have to replace rtl8723be?

rtl8192cu?

That would be my guess.

1 Like

Doesn't work, maybe I wrote something wrong?

#/usr/local/sbin/network_restart.sh
while true; do
     ping -c 1 8.8.8.8  | grep received
     if [ $? -eq 0 ]; then sleep 2
else
  echo "Connection broken, restarting network connection"
     /bin/sh -c 'nmcli networking off'
       systemctl stop NetworkManager
        ip link set wlp0s18f2u2 down
         modprobe -r rtl8192cu
           sleep 1
            modprobe rtl8192cu
             sleep .5
             ip link set wlp0s18f2u2 up
             sleep .5
            systemctl start NetworkManager
           /bin/sh -c 'nmcli networking on'
          /bin/sh -c 'nmcli r wifi off'
         sleep .5
       /bin/sh -c 'nmcli r wifi on'
      sleep 10
     break
   fi
 done
exec "$ScriptLoc"/usr/local/sbin/network_restart.sh && exit

Did you test running the script via calling it from the terminal?

Did you set the script to be executable?

Did you check the status of the service?

1 Like

After executing it from the terminal it prints this: 1 packets transmitted, 1 received, 0% packet loss, time 0ms repeatedly.

I set it to be an executable.

Output after checking the status:

● network-restart.service - Network Restart Service
     Loaded: loaded (/etc/systemd/system/network-restart.service; enabled; vendor preset: disabled)
     Active: activating (start-pre) since Mon 2020-06-29 10:09:08 CEST; 10s ago
Cntrl PID: 2680 (sleep)
      Tasks: 1 (limit: 3746)
     Memory: 240.0K
     CGroup: /system.slice/network-restart.service
             └─2680 /usr/bin/sleep 15

Jun 29 10:09:08 laurenz-pc systemd[1]: Starting Network Restart Service...

And if you shut your connection down manually with:

nmcli networking off

Does the script/service restart your connection on its own.

Please post:

inxi - nz
1 Like

It does not restart my connection.

inxi -nz:

Network:
  Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet 
  driver: N/A 
  Device-2: Realtek RTL8188CUS 802.11n WLAN Adapter type: USB 
  driver: rtl8192cu 
  IF: wlp0s18f2u2 state: up mac: <filter> 

Are you missing the first line of the script (the shebang)?

It is missing in what you posted?

#!/bin/bash

You need a shebang of some sort at the start of an executable script. Did you ommit it by mistake?

1 Like

It's missing, should it be put into the .sh?

Well ya, it won't work without it. Do not have a space before thos entries. First line of script, no spaces before it.

1 Like

Good, now it looks like this:

#!/bin/bash
#/usr/local/sbin/network_restart.sh
while true; do
     ping -c 1 8.8.8.8  | grep received
     if [ $? -eq 0 ]; then sleep 2
else
  echo "Connection broken, restarting network connection"
     /bin/sh -c 'nmcli networking off'
       systemctl stop NetworkManager
        ip link set wlp0s18f2u2 down
         modprobe -r rtl8192cu
           sleep 1
            modprobe rtl8192cu
             sleep .5
             ip link set wlp0s18f2u2 up
             sleep .5
            systemctl start NetworkManager
           /bin/sh -c 'nmcli networking on'
          /bin/sh -c 'nmcli r wifi off'
         sleep .5

And it works!

As advertised.

It helps if you follow my fairly detailed directions.

Hope that helps.

2 Likes

Forum kindly sponsored by