[SOLVED] Wifi adapter TP-Link TL-WN823N must be reconnected for it to work

I hope I understand you right, I disabled IPv6 in the network manager GUI, leaved IPv4 so that it obtained an IP from DHCP server. Same procedure as always, I restarted but it did not connect automatically.

But in General tab is set to connect automatically? Also, the password, is is set to be used for all users?

yes it is. It connects automatically if i reconnect the wifi stick, but not at bootup.Screenshot%20from%202018-07-22%2021-53-42

Oh ... i see ... well, see if you can trace some USB event that shows connect/disconnect
I have one issue that is similar, and i can see the event16 that connects and disconnects this particular device in the same time, so i have to turn it on again ... For me it doesn't happen with the 4.14 kernel but with all above that. I was able to see this only in Xorg log right after boot, and after that, same event works as it should. I'm still looking for more about it, but i couldn't find something coherent so far.

Maybe you can see something in the cli-output I posted above. I think there you can see the connect/disconnect of the stick in the output of the journalctl command.

Otherwise can you tell me where to find such a log or how to log the right events? I will then post it tomorrow.

By the way thank you guys for your fast response and help :slight_smile:

All those lines of output and only one line identified the actual adapter model. As fhdk mentioned earlier the kernel modules are not what you want to be using. I am out at the moment and only have use of my phone. When I get home I will send you instructions on the proper driver to install. Thanks for posting the outputs.

I did some research on the available drivers and found out that the kernel modules have been greatly improved recently. Some posts claim the newer rtl8xxxu kernel modules are working as well (or better) than the proprietary drivers from Realtek. So the first thing to try is getting the native kernel modules to work without having to remove and reinsert the wifi dongle. Start your computer normally with the wifi dongle inserted. After your computer is fully started enter each of these commands one at a time.

sudo systemctl stop NetworkManager

sudo ip link set wlp0s20u4 down

sudo modprobe -r rtl8xxxu

sudo modprobe rtl8xxxu

sudo ip link set wlp0s20u4 up

sudo systemctl start NetworkManager

Please post all input/outputs from the above commands.

If this procedure works properly it can easily be scripted to load automatically at startup so that removing/reinserting your wifi dongle is no longer necessary.

In many cases the reverse engineered Linux drivers may never quite achieve the speeds or stability of the drivers that were written specifically for Windows. Even the best Linux drivers may not perform as well as the Windows driver. Hopefully we can achieve satisfactory performance with the native kernel driver for you with out a ton of extra work.

There are easily 4 different driver versions that may work with this card. Before we change drivers I think we should tinker a bit to see if we can get the native drivers working satisfactorily for you. Try the above procedure and let me know how things work afterwards.

You can tweak the power saving settings to see if that improves performance.

Network Managers default power saving settings can cause problems sometimes. Let's alter the defaults.

Create a new file:

sudo nano /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf

in the file create or copy and paste the text below. the default is 3, 2 is less aggressive and more reliable with USB adapters:

wifi.powersave = 2

Reboot and test for improvement.

Could you also please post:

modinfo rtl8xxxu
1 Like

@tbg you are a genius - the commands of you worked perfekt. After this commands the wifi activates and connects automatically. Take a look:

[klaus@klaus-pc ~]$ sudo systemctl stop NetworkManager
[sudo] password for klaus: 
[klaus@klaus-pc ~]$ sudo ip link set wlp0s20u4 down
[klaus@klaus-pc ~]$ sudo modprobe -r rtl8xxxu
[klaus@klaus-pc ~]$ sudo modprobe rtl8xxxu
[klaus@klaus-pc ~]$ sudo ip link set wlp0s20u4 up
[klaus@klaus-pc ~]$ sudo systemctl start NetworkManager

The speedtest shows before the tweak of the power savings this values:

After the reboot this values showed up:

I got similar values before, around 11 download and 0.75 upload. (For comparing under Windows i get ~70 download) So no real improvement based on the power settings. Basically I am already happy if it connects automatically, but a little more speed, without heavy tweaking would be nice.

There you see the last output:

[klaus@klaus-pc ~]$ modinfo rtl8xxxu
filename:       /lib/modules/4.14.54-1-MANJARO/kernel/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.ko.xz
firmware:       rtlwifi/rtl8723bu_bt.bin
firmware:       rtlwifi/rtl8723bu_nic.bin
firmware:       rtlwifi/rtl8192eu_nic.bin
firmware:       rtlwifi/rtl8192cufw_TMSC.bin
firmware:       rtlwifi/rtl8192cufw_B.bin
firmware:       rtlwifi/rtl8192cufw_A.bin
firmware:       rtlwifi/rtl8723aufw_B_NoBT.bin
firmware:       rtlwifi/rtl8723aufw_B.bin
firmware:       rtlwifi/rtl8723aufw_A.bin
license:        GPL
description:    RTL8XXXu USB mac80211 Wireless LAN Driver
author:         Jes Sorensen <Jes.Sorensen@gmail.com>
srcversion:     8ECBECDF88CCF9717CB1423
alias:          usb:v0BDAp818Cd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2019pAB33d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2357p0107d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v7392p7822d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v4855p0091d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2357p0100d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v20F4p624Dd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2019pAB2Bd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2001p330Ad*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2001p3309d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2001p3307d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0E66p0020d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0E66p0019d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp2E2Ed*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0846pF001d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0846p9021d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v07B8p8178d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v07AAp0056d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0789p016Dd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0DF6p0070d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0DF6p0061d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0B05p17ABd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v06F8pE035d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0586p341Fd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v050Dp2103d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v050Dp2102d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v04BBp0950d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2019p1201d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v04F2pAFFCd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v04F2pAFFBd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v04F2pAFF8d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v04F2pAFFAd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v04F2pAFF9d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v04F2pAFF7d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:vCDABp8010d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v4856p0091d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v4855p0090d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2019pED17d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2019pAB2Ed*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2019pAB2Ad*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2019p4902d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2001p330Bd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v13D3p3357d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v103Cp1629d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0EB0p9071d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0DF6p005Cd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0DF6p0052d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp5088d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp1E1Ed*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0B05p17BAd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0846p9041d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v07B8p8189d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v06F8pE033d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v050Dp1102d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v04BBp094Cd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v1058p0631d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp317Fd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp818Ad*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp817Ed*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp817Dd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp817Bd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp817Ad*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp8177d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp8170d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp8191d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2001p3308d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v20F4p648Bd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v050Dp1004d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v7392p7811d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp817Fd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp8178d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp8176d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDApB720d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2357p0109d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2001p3319d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v2357p0108d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp818Bd*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp0724d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp1724d*dc*dsc*dp*icFFiscFFipFFin*
alias:          usb:v0BDAp8724d*dc*dsc*dp*icFFiscFFipFFin*
depends:        mac80211,usbcore
retpoline:      Y
intree:         Y
name:           rtl8xxxu
vermagic:       4.14.54-1-MANJARO SMP preempt mod_unload modversions 
parm:           debug:Set debug mask (int)
parm:           ht40_2g:Enable HT40 support on the 2.4GHz band (bool)
parm:           dma_aggregation:Enable DMA packet aggregation (bool)
parm:           dma_agg_timeout:Set DMA aggregation timeout (range 1-127) (int)
parm:           dma_agg_pages:Set DMA aggregation pages (range 1-127, 0 to disable) (int)
[klaus@klaus-pc ~]$ 

Now i tried to put the commands from you into a sh-file under ~/.config/autostart but that did not work. Maybe because the sudo commands? (The file is marked as executable)

At least a huge thank you guys for your time and help so far, especially to you tbg.

Glad that helped. Read this thread and my posts:

Part 1) WiFi module suspend scripts
Part 2) WiFi module suspend scirpts:

Sorry I forgot those systemd unit files were created for suspend/resume. They would need to be altered for startup/shutdown.

This would be along the lines of what you need as a start unit.

# systemctl cat netmod-resume.service
# /etc/systemd/system/netmod-resume.service

Description=Network module start helper



This should be all you need to run the service at login. You must create the netmod-resume.sh script with your required commands, then activate the service. Full directions on the above linked post. A shutdown systemd unit file should not be required.

I hope that is clear enough, and that it works for you. I am not very experienced at writing systemd unit files, so some tweaking may be required on your part.

Hello tbg,

i tried your instructions but the wifi did not connect automatically:

[klaus@klaus-pc ~]$ sudo xed /usr/bin/netmod-suspend.sh
[sudo] password for klaus: 

** (xed:2340): WARNING **: 08:33:28.740: Set document metadata failed: Setting attribute metadata::xed-encoding not supported

** (xed:2340): WARNING **: 08:33:31.728: Set document metadata failed: Setting attribute metadata::xed-position not supported
[klaus@klaus-pc ~]$ sudo chown root:root /usr/bin/netmod-suspend.sh
[klaus@klaus-pc ~]$ sudo chmod +x /usr/bin/netmod-suspend.sh
[klaus@klaus-pc ~]$ sudo xed /etc/systemd/system/netmod-suspend.service

** (xed:2368): WARNING **: 08:34:59.098: Set document metadata failed: Setting attribute metadata::xed-encoding not supported

** (xed:2368): WARNING **: 08:35:02.009: Set document metadata failed: Setting attribute metadata::xed-position not supported
[klaus@klaus-pc ~]$ sudo chown root:root /etc/systemd/system/netmod-suspend.service
[klaus@klaus-pc ~]$ sudo chmod +x /etc/systemd/system/netmod-suspend.service
[klaus@klaus-pc ~]$ sudo systemctl enable netmod-suspend.service
Created symlink /etc/systemd/system/default.target.wants/netmod-suspend.service → /etc/systemd/system/netmod-suspend.service.
[klaus@klaus-pc ~]$ sudo systemctl start netmod-suspend.service
[klaus@klaus-pc ~]$ sudo xed /usr/bin/netmod-resume.sh

** (xed:2409): WARNING **: 08:37:09.433: Set document metadata failed: Setting attribute metadata::xed-encoding not supported

** (xed:2409): WARNING **: 08:37:22.539: Set document metadata failed: Setting attribute metadata::xed-position not supported
[klaus@klaus-pc ~]$ sudo chown root:root /usr/bin/netmod-resume.sh
[klaus@klaus-pc ~]$ sudo chmod +x /usr/bin/netmod-resume.sh
[klaus@klaus-pc ~]$ sudo xed /etc/systemd/system/netmod-resume.service

** (xed:2424): WARNING **: 08:38:04.768: Set document metadata failed: Setting attribute metadata::xed-encoding not supported

** (xed:2424): WARNING **: 08:38:06.170: Set document metadata failed: Setting attribute metadata::xed-position not supported
[klaus@klaus-pc ~]$ sudo chown root:root /etc/systemd/system/netmod-resume.service
[klaus@klaus-pc ~]$ sudo chmod +x /etc/systemd/system/netmod-resume.service
[klaus@klaus-pc ~]$ sudo systemctl enable netmod-resume.service
Created symlink /etc/systemd/system/suspend.target.wants/netmod-resume.service → /etc/systemd/system/netmod-resume.service.
[klaus@klaus-pc ~]$ sudo systemctl start netmod-resume.service

My two files contains the following:

[klaus@klaus-pc ~]$ cat /usr/bin/netmod-suspend.sh
systemctl stop NetworkManager
ip link set wlp0s20u4 down
modprobe -r rtl8xxxu
[klaus@klaus-pc ~]$ cat /usr/bin/netmod-resume.sh
modprobe rtl8xxxu
ip link set wlp0s20u4 up
systemctl start NetworkManager
[klaus@klaus-pc ~]$ 

Both files are also executeable:

[klaus@klaus-pc ~]$ ls -la /usr/bin/netmod-suspend.sh
-rwxr-xr-x 1 root root 90 26. Jul 08:44 /usr/bin/netmod-suspend.sh
[klaus@klaus-pc ~]$ ls -la /usr/bin/netmod-resume.sh
-rwxr-xr-x 1 root root 86 26. Jul 08:45 /usr/bin/netmod-resume.sh

Did I something wrong or are the scripts running to early in the boot process?

You do not need two separate scripts. Combine all the commands I gave you into one script to be executed at login. The link with the instructions was for separate scripts that needed to be executed at suspend and resume. You only need one script to be executed at login.

Unfortunately, I am not at home and do not have access to a Linux computer. I am on my phone and with my vision I often have problems reading text outputs on such as small screen.

now i put it all together in the resume script. This changes nothing.

In the mean time I tried to run the script manually and got this:

[klaus@klaus-pc bin]$ ./netmod-resume.sh 
RTNETLINK answers: Operation not permitted
modprobe: ERROR: could not remove 'rtl8xxxu': Operation not permitted
RTNETLINK answers: Operation not permitted

What does this mean?

Generally that means you do not have proper root permissions.

1 Like

Damn, i did not see it - my bad :grin:

Now I had the time to boot up my Manjaro again and try it with 'sudo' and this was the output:

[klaus@klaus-pc ~]$ cd /usr/bin/
[klaus@klaus-pc bin]$ sudo ./netmod-resume.sh 
[sudo] password for klaus: 
Cannot find device "wlp0s20u4"

The strange thing there is, the script worked anyway.
What do you think, is there a 'sleep' necessary?
I do not understand why it is not working after the login? Are there any ideas how to make it work?

I tried the 'Startup applications' GUI to run the script at startup and copied the script in /etc/profile.d/ but none of these worked. :frowning:

Without being able to work with it on my system it's difficult to say what the best solution is. As long as you already know the right commands to issue (which you do) then there is a scriptable solution. You will have to research the best method to implement it.

I am not at home and am only on my phone so without a Linux box it is impossible to play with any scripting. I will see if I can come up with some options for you when back at my Linux computers.

As I said I'm not able to test anything ATM, but I did have an idea for an easier method of a startup script without needing root privileges. Sometimes removing the modules is not necessary. Sometimes you can get away with simply restarting network manager.

You could try.

nmcli r wifi off
nmcli r wifi on

These commands do not require root privileges and its possible that this could be enough to refresh your adapter and have it recognized. Give that a try manually, then see if it works in a simple start up script from your users home directory such as ~/. scripts.

If you do not have any luck with an automatic start up script, a bash alias is also another option. You could create an alias such as "wifi" that could be typed in a terminal to start your wifi. There is also the option of creating a desktop start file that calls your script. You could then put the desktop file in your start menu for a one click solution to your problem. There's more than one way to skin a cat.

I tried your commands out, but unfortunately they do not work.

But while playing around I found another interesting thing out:
I mentioned above that I get the message 'could not find device...'. So I thought there must be a reason for this message. I remembered the time when I was at school and learned programming. Sometimes the commands are executed too fast. So i put a simple 'sleep 2' between every command and created a new systemd-service.

Now I do not know when the script runs exactly, but I i am connected 1-2 seconds after I see the desktop.

Thank you again for the help!

Sweet, thanks for letting me know it worked. Yes executing the commands too quickly can be an issue. I was not expecting you to start with scripting the commands. Typed individually there's usually enough time delay for it to work.

That is why I never recommend a network manager restart command. Some systems do not respond quickly enough and the command does not work. You did the right thing when scripting to include a wait command.

If this has fixed your issue for you please mark your thread solved.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by