Failed to connect to the remote extension host server (Error: WebSocket close with status code 1006) and Could not fetch remote environment
Getting this in Virtual Studio Code ( aka VSCode, vscode )?
Failed to connect to the remote extension host server (Error: WebSocket close with status code 1006) and Could not fetch remote environment
Clear the running remote agent (also called server) and let VScode reconnect:
# ps -ef|grep -Ei vscode
tom@mds+ 5364 1 0 12:48 ? 00:00:00 sh /n/mds.xyz/tom/.vscode-server/bin/12341234124312341234/server.sh –start-server –host=127.0.0.1 –enable-remote-auto-shutdown –port=0 –connection-secret /n/mds.xyz/tom/.vscode-server/.12341234124312341234.token
tom@mds+ 5371 5364 0 12:48 ? 00:00:02 /n/mds.xyz/tom/.vscode-server/bin/12341234124312341234/node /n/mds.xyz/tom/.vscode-server/bin/12341234124312341234/out/vs/server/main.js –start-server –host=127.0.0.1 –enable-remote-auto-shutdown –port=0 –connection-secret /n/mds.xyz/tom/.vscode-server/.12341234124312341234.token
Appears that even attempting to remove the files from the folder results in an error:
# rm -rf *
rm: cannot remove ‘bin/fd6f3bce6709b121a895d042d343d71f317d74e7/.nfsb69106cd86847b680000003f’: Device or resource busy
So checking with lsof what processes are holding locks on them reveals there’s a couple of them running:
# lsof|grep -Ei vscode
bash 14099 tom@mds.xyz 99w REG 0,47 0 13155303466320821096 /n/mds.xyz/tom/.vscode-server/bin/12341234124312341234/.nfsb69106cd86847b680000003f (nfs-c01.nix.mds.xyz:/n/mds.xyz)
sleep 14827 tom@mds.xyz 99w REG 0,47 0 13155303466320821096 /n/mds.xyz/tom/.vscode-server/bin/12341234124312341234/.nfsb69106cd86847b680000003f (nfs-c01.nix.mds.xyz:/n/mds.xyz)
bash 14953 root cwd DIR 0,47 4096 12134188379298541696 /n/mds.xyz/tom/.vscode-server (nfs-c01.nix.mds.xyz:/n/mds.xyz)
lsof 15022 root cwd DIR 0,47 4096 12134188379298541696 /n/mds.xyz/tom/.vscode-server (nfs-c01.nix.mds.xyz:/n/mds.xyz)
grep 15023 root cwd DIR 0,47 4096 12134188379298541696 /n/mds.xyz/tom/.vscode-server (nfs-c01.nix.mds.xyz:/n/mds.xyz)
lsof 15024 root cwd DIR 0,47 4096 12134188379298541696 /n/mds.xyz/tom/.vscode-server (nfs-c01.nix.mds.xyz:/n/mds.xyz)
For reasons that escape me, clearing the above agent might not have been totally necessary since after a Windows Reboot, connectivity was fine. Still uncertain if the redownload and setup of the ~/.vscode-server folder had anything to do with this, but after those two actions, the issue went away. Still, if more debug is needed, use this command off the target host:
# strace -f -s 512 -p <PID>
to get all the trace calls for the VScode Server PID. This usually reveals more, though it’s very chatty. 🙂
Cheers,

