vscode 远程连接报错,“Resolver error: Error: XHR failed”

[11:06:53.461] Creating bash subshell inside "bash"
[11:06:53.560] > bash version:  4.4.20(1)-release
[11:06:53.586] > bash version:  4.4.20(1)-release
[11:06:53.717] > c448906b72f1: running
[11:06:53.783] > Acquiring lock on /root/.vscode-server/bin/b3e4e68a0bc097f0ae7907b217c1119af9e03435/vscode-remote-lock.root.b3e4e68a0bc097f0ae7907b217c1119af9e03435
[11:06:53.786] > Installing to /root/.vscode-server/bin/b3e4e68a0bc097f0ae7907b217c1119af9e03435...
[11:06:53.791] > c448906b72f1%%1%%
[11:06:53.792] > Downloading with wget
[11:06:54.063] > wget download failed
[11:06:54.063] > ERROR: cannot verify update.code.visualstudio.com's certificate, issued by ‘CN=Microsoft Azure RSA TLS Issuing CA 08,O=Microsoft Corporation,C=US’: Self-signed certificate encountered. To connect to update.code.visualstudio.com insecurely, use `--no-check-certificate'.
[11:06:54.067] > printenv:
[11:06:54.068] >     LC_MEASUREMENT=C.UTF-8
>     SSH_CONNECTION=172.122.49.0 47560 172.122.65.29 22
>     LC_PAPER=C.UTF-8
>     LC_MONETARY=C.UTF-8
>     LANG=C.UTF-8
>     LC_NAME=C.UTF-8
>     USER=root
>     PWD=/root/.vscode-server/bin/b3e4e68a0bc097f0ae7907b217c1119af9e03435
>     HOME=/root
>     SSH_CLIENT=172.122.49.0 47560 22
>     LC_ADDRESS=C.UTF-8
>     LC_NUMERIC=C.UTF-8
>     MAIL=/var/mail/root
>     SHELL=/bin/bash
>     SHLVL=2
>     LC_TELEPHONE=C.UTF-8
>     VSCODE_AGENT_FOLDER=/root/.vscode-server
>     LOGNAME=root
>     PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
>     LC_IDENTIFICATION=C.UTF-8
>     LC_TIME=C.UTF-8
>     _=/usr/bin/printenv
>     OLDPWD=/root
[11:06:54.068] > Trigger local server download
[11:06:54.069] > c448906b72f1:trigger_server_download
> platform==linux==
> vscodeArch==x64==
> destFolder==/root/.vscode-server/bin/==
> destFolder2==b3e4e68a0bc097f0ae7907b217c1119af9e03435==
[11:06:54.069] > c448906b72f1:trigger_server_download_end
> Waiting for client to transfer server archive...
[11:06:54.069] Got request to download on client for {"platform":"linux","arch":"x64","destFolder":"/root/.vscode-server/bin/b3e4e68a0bc097f0ae7907b217c1119af9e03435"}
[11:06:54.069] Downloading VS Code server locally...
[11:06:54.130] Terminating local server
[11:06:54.131] Resolver error: Error: XHR failed
    at C.onerror (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:72:1399)
[11:06:54.133] ------

解决方案是,参考如下链接,
https://blog.csdn.net/hubaoshizhe2014/article/details/136265315

问题概述
当使用VScode连接远程服务器时,往往需要使用Remote-SSH这个插件。而该插件有一个小bug,当远程服务器网络不佳时容易出现。

在控制台会出现下述语句:
Resolver error: Error: XHR failed at y.onerror (vscode-file://vscode-app/d:/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:77:1261)

解决方法
懂了报错的原因,那就可以从中找出解决方法。即手动在本地下载安装包,然后手动传到服务器端。这样是可以解决这个问题的,虽然不是很优雅。

在服务器端,进入下面的目录,获取commit id。

$ ls ~/.vscode-server/bin
flive@flive-virtual-machine:~/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710$

在这里,我的commit id就是flive@flive-virtual-machine:~/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710$

手动下载出问题的包(tarball),注意下面的COMMIT_ID要替换成自己在上一步得到的commit id。

手动下载出问题的包(tarball),注意下面的COMMIT_ID要替换成自己在上一步得到的commit id。

稳定版下载链接:https://update.code.visualstudio.com/commit:COMMIT_ID/server-linux-x64/stable
内测版下载链接:https://update.code.visualstudio.com/commit:COMMIT_ID/server-linux-x64/insider

如我的稳定版链接就是:https://update.code.visualstudio.com/commit:2ccd690cbff1569e4a83d7c43d45101f817401dc/server-linux-x64/stable

下载后会得到一个vscode-server-linux-x64.tar.gz,将其通过sftp等方式传到服务器上。路径:~/.vscode-server/bin/COMMIT_ID/vscode-server-linux-x64.tar.gz

在服务器端进入该路径,解压。

$ cd ~/.vscode-server/bin/$COMMIT_ID
$ tar -xvzf vscode-server-linux-x64.tar.gz --strip-components 1

重新使用VScode进行连接。

posted @ 2024-10-31 11:25  无左无右  阅读(24)  评论(0编辑  收藏  举报