microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.64k stars 29.04k forks source link

Can not connect to WSL2 running Ubuntu-22.04... #221727

Closed diagonjope closed 3 months ago

diagonjope commented 3 months ago

Type: Bug

Please take a look at the details provided here ==> https://stackoverflow.com/questions/78733419/can-not-connect-vscode-to-wsl2-running-ubuntu-22-04

VS Code version: Code 1.91.0 (ea1445cc7016315d0f5728f8e8b12a45dc0a7286, 2024-07-01T18:52:22.949Z) OS version: Windows_NT x64 10.0.22631 Modes: Connection to 'WSL: Ubuntu-22.04' could not be established WebSocket close with status code 1006

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz (12 x 2592)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|31.91GB (12.81GB free)| |Process Argv|--folder-uri=vscode-remote://wsl+Ubuntu-22.04/home/diagonjope/mojo-tests --remote=wsl+Ubuntu-22.04 --crash-reporter-id 8875e5f1-e052-45ee-a659-c813b03011c1| |Screen Reader|no| |VM|0%| Connection to 'WSL: Ubuntu-22.04' could not be established WebSocket close with status code 1006
Extensions: none
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstes627:30244334 vscoreces:30445986 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonnoceb:30805159 asynctok:30898717 pythonregdiag2:30936856 pythonmypyd1:30879173 h48ei257:31000450 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 chatpanelc:31048052 dsvsc021:30996838 01bff139:31013167 pythoncenvpt:31062603 a69g1124:31058053 dvdeprecation:31068756 dwnewjupyter:31046869 newcmakeconfigv2:31071590 impr_priority:31082723 refactorc:31093864 ```
vscodenpa commented 3 months ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.91.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

diagonjope commented 3 months ago

VS Code updated to latest version. Got the same results and same error persists:

2024-07-15 13:03:25.659 [error] CodeExpectedError: WebSocket close with status code 1006 at WebSocket. (vscode-file://vscode-app/c:/Users/josep/AppData/Local/Programs/Microsoft%20VS%

aeschli commented 3 months ago

Can you remove the `networkingMode=mirrored`` from your wslconfig file to see if that causes the problem?

diagonjope commented 3 months ago

Greetings @aeschli ! I commented the line and now VS Code can connect to WSL2 and install extensions in Ubuntu. Thanks for the suggestion!

However, when I do this, I also loose the capability of connecting to the outside world from Ubuntu. So, in order to install or update any package, I have to shutdown WSL, uncomment the "networkingMode=mirrored" line and save the .wslconfig file, initiate a new WSL session, do the update, and then revert everything again.

Do you have any thoughts about how to solve this problem? I've had this problem since last year, and had given up on using WSL until I found the "networkingMode=mirrored" option a couple of weeks ago.

I'd appreciate your comments.

Cheers,

++José

aeschli commented 3 months ago

We have https://github.com/microsoft/vscode-remote-release/issues/9222 for this and we have contacted the WSL team: https://github.com/microsoft/WSL/issues/11184 It's unclear why networkingMode=mirrored doesn't work for some users.

Can you please collect networking logs by following the instructions below and attach them, together with a description of your distro setup in https://github.com/microsoft/WSL/issues/11184 ? https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#collect-wsl-logs-for-networking-issues

aeschli commented 3 months ago

Marking as dup of https://github.com/microsoft/vscode-remote-release/issues/9222.

diagonjope commented 3 months ago

Greetings!

The wsl networking log collected weights about 126 MB, but github has a 25 MB allowance.  Where else can I drop the log file?

Cheers,

++José [https://www.linkedin.com/in/diagonjope/]

[https://ci3.googleusercontent.com/mail-sig/AIorK4xjYDmx0dd_nnJzqLW6Ye3fbNXpgORing2wF0IKbIWymQNbPlv_JbELP8uhGguYMt37Q_vz5_t4WXIV]

José P. Díaz G. | General Manager | Diextra International, S.R.L. Plaza Morichal, Suite 11-C | c/Max Henríquez Ureña #83 Ens. Piantini | Santo Domingo | D.N. | Dominican Republic T: +1-829-547-9228 | M: +1-829-718-1638 Email: @. @. | Skype: jose.p.diaz.g | Twitter: @diagonjope

[data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=3D] On Tue, Jul 16, 2024 at 12:22 PM Martin Aeschlimann @.***> wrote:

We have microsoft/vscode-remote-release#9222 [https://github.com/microsoft/vscode-remote-release/issues/9222] for this and we have contacted the WSL team: microsoft/WSL#11184 [https://github.com/microsoft/WSL/issues/11184] It's unclear why networkingMode=mirrored doesn't work for some users.

Can you please collect networking logs by following the instructions below and attach them, together with a description of your distro setup in microsoft/WSL#11184 [https://github.com/microsoft/WSL/issues/11184] ? https://github.com/microsoft/WSL/blob/master/CONTRIBUTING. md#collect-wsl-logs-for-networking-issues [https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#collect-wsl-logs-for-networking-issues]

— Reply to this email directly, view it on GitHub [https://github.com/microsoft/vscode/issues/221727#issuecomment-2231342060], or unsubscribe [https://github.com/notifications/unsubscribe-auth/ABMYCQZ6A2DIKRHEIRWJZWDZMVCGDAVCNFSM6AAAAABK42MUJGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZRGM2DEMBWGA]. You are receiving this because you authored the thread.[https://ci3.googleusercontent.com/meips/ADKq_NZys-CWLDCt9u9uL7t1i-wCX5FIkr57icrgchPHndMPqqfdXrAtbcYnsmHkiwN-9qQOqhdA9yel7X-TEw9Ij7K3JccmwW2si70viYvqN7wrFK-tu0ucgFI8gLRmL3qblDnzh8RKZEkfTiGSMaUwn-MjTEpV7TfffB8eiGiXKK1NTbJf1I_HF8xAvjo0K6W3tLvtlh06miRy7Ig0vR0SFs9aqIdH9bmjUv2-zeAd6ChAltvrkxVsMh4=s0-d-e1-ft#https://github.com/notifications/beacon/ABMYCQ5AL27W3B35GCAV5J3ZMVCGDA5CNFSM6AAAAABK42MUJGWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUE76J6Y.gif]Message ID: @.***>

cyh2004 commented 3 months ago

I have the same problem. But I seem to have found a workaround. In /etc/wsl.conf I wrote the following to enable systemctl

[boot] systemd=true

After deleting the two lines, vscode worked smoothly. I can keep setting "networkingMode=mirrored" in .wslconfig and my vscode can connect to wsl, which has network connection

The content of my .wslconfig:

[wsl2] networkingMode=mirrored dnsTunneling=true firewall=true autoProxy=true

But the problem arise after I upgrade wsl from Ubuntu 20.04 to Ubuntu 24.04 using do-release-upgrade. Before that, systemd=true and networkingMode=mirrored coexist fairly well.

klawdyo commented 3 months ago

My Pc started this error today