Closed snhardin closed 3 years ago
Hmm, that's weird, as WSL and other Hyper-V VMs should be the same. Are you running x11-over-vsock.exe
with admin privilege?
Yes, I am. I have also made sure that my account is added to the Hyper-V Administrators group.
To test, I installed WSL2 and ran x11-over-vsock.exe
once without any arguments and once with the WSL VMID specified. Both commands succeeded without error.
So, I decided to start from scratch and follow the instructions at https://x410.dev/cookbook/hyperv/using-x410-with-hyper-v-linux-virtual-machines-via-vsock/, substituting x11-over-vsock.exe
and vcxsrv for x410. Everything worked without issue. Not sure what I was doing wrong the first time. Thanks for making a wonderful tool. 🙂
You may close the issue at your leisure.
Glad you have your issue resolved.
I have the same error while running wsldhost.exe
as an admin user.
Failed to listen: An attempt was made to access a socket in a way forbidden by its access permissions. (os error 10013)
The preferred solution across the internet to check if the port being used by the program is in the exclusion list, which was not the problem in my case.
PS C:\Users\kayg> netsh interface ipv4 show excludedportrange protocol=tcp
Protocol tcp Port Exclusion Ranges
Start Port End Port
---------- --------
5357 5357
49152 49251
49252 49351
49352 49451
49452 49551
49679 49778
49779 49878
49879 49978
50000 50059 *
50060 50159
50160 50259
50260 50359
50460 50559
50560 50659
50660 50759
50760 50859
50860 50959
50960 51059
55078 55177
55178 55277
55278 55377
56472 56571
56572 56671
56672 56771
56772 56871
56972 57071
57072 57171
57172 57271
58942 59041
59042 59141
59142 59241
59242 59341
59342 59441
59442 59541
* - Administered port exclusions.
I also tried disabling the firewall but no luck.
wsldhost does not listen to any TCP port, it only listens to the Hyper-V socket. Check if the correct VMID is used, or maybe just listen to the wildcard socket: wsldhost 00000000-0000-0000-0000-000000000000
.
Same problem :(
PS C:\Users\kayg> .\wsldhost.exe --daemon 00000000-0000-0000-0000-000000000000
PS C:\Users\kayg> Failed to listen: An attempt was made to access a socket in a way forbidden by its access permissions. (os error 10013)
Failed to listen: An attempt was made to access a socket in a way forbidden by its access permissions. (os error 10013)
Failed to listen: An attempt was made to access a socket in a way forbidden by its access permissions. (os error 10013)
Oh, you shouldn't pass the daemon flag. The daemon flag is meant to spawn a daemon that polls the hcs list looking for WSL process. If you have VMID already or is using a wildcard address, omit the daemon flag.
That works, as in no errors, but the process inside WSL2 isn't able to find the host process:
Cannot connect to wsldhost: Connection timed out (os error 110)
I've tried running it as root even. Here's my config file for reference:
❯ cat ~/.wsld.toml
# Leave out this section to disable X11 forwarding
[x11]
# X11 display number to listen *inside* WSL. The X server in Windows can specified as argument when running wsldhost.exe.
# Default to 0, can be omitted.
display = 0
# Leave out this section to disable time synchronisation
# If you need time synchronisation, you should either run wsld with root, or give it `cap_sys_time` capability using `sudo setcap cap_sys_time+eip <PATH to wsld>`.
[time]
# Interval between syncs
# Default to 10min, can be omitted
interval = "1hr"
# Leave out this section to disable TCP port forwarding
# This feature is experimental, feedbacks and suggestions welcome.
# This feature will WSL localhost to Windows localhost, so you can connect
# servers running in Windows in WSL. This feature requires interaction with
# iptables, so you need to either run wsld as root or allow wsld to use sudo.
# [tcp_forward]
# iptables command to use. nftables seem not to work so you need to have
# the legacy one. If you are not using Debian it is likely you need to change it.
# iptables_cmd = "sudo iptables-legacy"
# Ports to forward
# ports = [ 1234 ]
If you are running it with WSL2, it is not related to this issue. This is issue about using it with Hyper-V VM. Please file a new issue instead.
Alright, sorry about that.
For Hyper-V VMs (not WSL2), the service needs to be registered:
In elevated PowerShell:
$service = New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\GuestCommunicationServices" -Name "00001770-facb-11e6-bd58-64006a7986d3"
$service.SetValue("ElementName", "WSLD Socket")
Where 00XXXXXX-facb-11e6-bd58-64006a7986d3 is a template GUID, with the XXXX being the port. For wsld, it's 6000, so 1770 (hex).
After that, you can start wsldhost on wildcard VMID - this allows you to run it even if the VMs are down: wsldhost.exe 00000000-0000-0000-0000-000000000000
I know this is meant specifically for WSL, but is there any support planned for Hyper-V virtual machines? Would love to hear others' opinions on this, as I know little about the technicalities. 🙂
Right now, using
x11-over-vsock.exe
on a VMID that isn't WSL results in an OS Error 10013 ("An attempt was made to access a socket in a way forbidden by its access permissions").