Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyper-V Virtual Ethernet Adapter for WSL disables and enables itself which drops X11 connection #8279

Closed
tan-wei-xin-alez opened this issue Apr 12, 2022 · 2 comments
Labels

Comments

@tan-wei-xin-alez
Copy link

tan-wei-xin-alez commented Apr 12, 2022

Version

Microsoft Windows [Version 10.0.19042.1466]

WSL Version

WSL 2

Kernel Version

Linux version 5.10.60.1-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220)

Distro Version

Distributor ID: Ubuntu
Description: Ubuntu Jammy Jellyfish (development branch)
Release: 22.04
Codename: jammy

Other Software

vcxsrv x server version 1.20.9.0
terminator 2.1.1
powershell 7.2.0

Repro Steps

  1. Install and set up WSL2
  2. Download and install VcXsrv from https://sourceforge.net/projects/vcxsrv/
  3. Install Powershell as per instructions on https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.2
  4. Install terminator in WSL2 by running the following in Powershell
wsl
sudo apt install terminator
  1. Start VcXsrv using the following command in Powershell
Start-Process -FilePath 'C:\Program Files\VcXsrv\vcxsrv.exe' -ArgumentList (':0'),('-ac'),('-terminate'),('-lesspointer'),('-multiwindow'),('-clipboard'),('-wgl'),('-dpi'),('auto') -NoNewWindow
  1. Start terminator using the following command (I have a shortcut for this)
Start-Process -FilePath (Get-Command bash.exe).Source -ArgumentList ('-c'),('-l'),('"DISPLAY=$(awk ''/nameserver / {print $2; exit}'' /etc/resolv.conf 2>/dev/null):0 LIBGL_ALWAYS_INDIRECT=1 exec $(wslpath ''\\wsl$\Ubuntu-22.04\usr\bin\terminator'')"') -NoNewWindow
  1. Search for "Ethernet Settings" in windows search bar and click on "Change adapter options" on left
  2. Disable network device that is connected to internet [either ethernet or wifi device, mine is named "Ethernet"]
  3. Enable same network device
  4. Watch "Hyper-V Virtual Ethernet Adapter" for WSL [mine is named "vEthernet (WSL)"] disable and enable itself which causes window containing terminator to automatically close [same behavior should be observed for any other X11 application]

Expected Behavior

The virtual ethernet adapter for WSL should not reset itself?

I don't know if the virtual ethernet adapter for WSL is supposed to reset itself but I do think it is an issue as network devices usually power down after some time when the machine is put in sleep mode.

This behavior is not seen if you physically unplug the ethernet cable and plug it back again [or disconnect and reconnect to wifi], only if the network device is reset [via disabling/enabling or power off/on].

Right now my workaround is to set the advanced properties of the network devices using Powershell via

Set-NetAdapterAdvancedProperty -Name Ethernet -DisplayName 'Energy Efficient Ethernet' -DisplayValue Off
Set-NetAdapterAdvancedProperty -Name Wi-Fi -DisplayName 'MIMO Power Saving Mode' -DisplayValue 'No SMPS'

so that they don't power down when the machine is in sleep mode but I am also not 100% sure that it works all the time

Edit

Yeah the above settings don't work if the machine is left on sleep mode overnight

Actual Behavior

Watch "vEthernet (WSL)" closely and you should see it disable and enable itself

hyper_v_virtual_ethernet_adapter_for_wsl_disables_and_enables_itself.mp4

Diagnostic Logs

No response

@OneBlue
Copy link
Collaborator

OneBlue commented Apr 12, 2022

Thanks for reporting this @tan-wei-xin-alez.

Looks like you're using the host's IP address for $DISPLAY, which explains why the connection gets dropped when the adapter gets reset.

I'd say that the WSL network adapter being reset when the host's network adapter is reset is by design. Given that vcxsrv isn't officially supported, I'd recommend looking at switching to wslg, or, giving that this is a custom solution, keep using the workaround that you found.

@tan-wei-xin-alez
Copy link
Author

tan-wei-xin-alez commented Apr 13, 2022

Thanks for the confirmation @OneBlue

Unfortunately, wslg requires Windows 11 and I'm stuck on Windows 10 due to other software requirements (p_-)
Are there any other alternatives to wlsg for Windows 10 that would not be affected by this issue?

I've seen some alternatives on https://derkoe.dev/blog/development-environment-in-wsl2/ but I do not know whether x2go would encounter the same issues.
Can anyone with experience in the matter chime in?

EDIT

Have been using x2go for a while now which does not experience the same problems as a vanilla vcxsrv, only issue is that sometimes WSL2 shuts itself down during sleep which leaves the x2go session hanging and thus, unrecoverable but that's a different issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants