Image showing [SOLVED] code server WebSocket close with status code 1006

[SOLVED] code server WebSocket close with status code 1006

affiliate best offer

At the end of the installation of the code server, you are ready to enjoy your new development workflow, and then, you see this message “WebSocket close with status code 1006”. How to solve it? Check out these answers

Note: If you are confused about what code server is, check this post which explains it.

TL;DR

Check your https connection. Your browser cannot reach your code server instance.

What is the websocket 1006 error?

The websocket 1006 error means that the connection has been closed, locally, by your browser.

If you see a close code 1006, you have a very low level error with WebSocket itself as this error is not really meant for the user. The websocket 1006 error points to a low level issue with your code and implementation.

Why do I see this error?

The main reason is that the connection was closed abnormally (locally) by the browser implementation.

It means that your browser cannot reach your remote code server. The main issue is about your https connection to the server.

How to fix it?

You might not be sure about the process to follow in order to setup code server. I did a tutorial on how to setup code server cloud IDE platform on digitalocean using kubernetes.

If you speak french, the french version is here.

The good news is that, there are two possible solutions :

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

Option 2 : Use ngrok

ngrok will tunnel and create an https connection to your server.

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

Use wss to forward

Here is the code to perform the forwarding and solve the issue

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

You may get into a related type of issue where code-server complains about the bindings file. The solution is in this blog post about solving binding file not found error.

Also, kubernetes and minikube are great choices to host code server.

Full Bright

Full Bright

A professional and sympathic business man.

Contact

Contact Us

To order one of our services, navigate to the order service page

Address

10 rue de Penthièvre,
75008 Paris

Email Us

hello at bright-softwares dot com

Open Hours

Monday - Friday
9:00AM - 05:00PM