【问题标题】:code-server WebSocket close with status code 1006代码服务器 WebSocket 关闭,状态码为 1006
【发布时间】:2020-11-15 09:05:28
【问题描述】:

我正在尝试在云平台上安装 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-ocean droplet code-server


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      当您在本地使用代码服务器时,通常会发生此错误和其他错误 要解决它,您可以使用 --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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-07-18
        • 2019-05-25
        • 1970-01-01
        • 2020-09-06
        • 2013-10-18
        • 2016-11-30
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多