首页 > 解决方案 > 代码服务器 WebSocket 关闭,状态码为 1006

问题描述

我正在尝试在云平台上安装 code-server 3.6.2。我已经尝试过 AWS 和 digitalocean 机器,但在这两个系统中,我都可以打开代码服务器,但它会给出错误“WebSocket close with status code 1006”。

我已按照https://www.digitalocean.com/community/tutorials/how-to-set-up-the-code-server-cloud-ide-platform-on-ubuntu-20-04中的程序进行操作

标签: digital-oceandropletcode-server

解决方案


code-server 使用 websocket 连接。你使用 HTTPS 吗?
如果是这样,你应该使用 wss 来转发 ws.like 这样的:

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


推荐阅读