代码服务器WebSocket关闭,状态代码为1006



我正在尝试在云平台上安装代码服务器3.6.2。我尝试过AWS和digitalocean机器,但在这两个系统中,我都可以打开代码服务器,但它会出现错误";WebSocket关闭,状态代码为1006";。

我从https://www.digitalocean.com/community/tutorials/how-to-set-up-the-code-server-cloud-ide-platform-on-ubuntu-20-04

代码服务器使用websocket进行连接。你使用HTTPS吗
如果是,您应该使用ws转发ws。如下所示:

// forward websocket (wss -> ws)
httpsServer.on('upgrade', function (req, socket, head) {
proxy.ws(req, socket, head, {
target: 'ws://...',
ws: true
})
})

通常在本地使用代码服务器时会发生此错误和其他错误为了解决这个问题,你可以使用--link参数,它为你提供一个带有临时https的url,或者你也可以使用ngrok

//Option 1
code-server --host 127.0.0.1 --bind-addr 0.0.0.0:9000 --auth password --link

//Option 2
code-server --host 127.0.0.1 --bind-addr 0.0.0.0:9000 --auth password 
ngrok http 9000

最新更新