code-server: [Bug]: intermittent reconnection

Is there an existing issue for this?

  • I have searched the existing issues

OS/Web Information

  • Web Browser: Chrome
  • Local OS: Windows 11
  • Remote OS: Ubuntu 20.04
  • Remote Architecture: x86_64
  • code-server --version: v4.5.1

image

image

Steps to Reproduce

  1. insrtall the latest version of code-server
  2. open an project and wating sometimes.
  3. open the code-server develope tool, and you can see some log like the below example

image

Expected

can use code-server normal.

Actual

intermittent reconnection

received socket close event (wasClean: false, code: 1006, reason: ).

Logs

No response

Screenshot/Video

No response

Does this issue happen in VS Code or GitHub Codespaces?

  • I cannot reproduce this in VS Code.
  • I cannot reproduce this in GitHub Codespaces.

Are you accessing code-server over HTTPS?

  • I am using HTTPS.

Notes

use nginx reverse proxy code-server, and nginx configure https.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

I’ve been doing some testing and it appears that what’s causing this is a change in behavior to the websocket keep alive between 4.4.0 and 4.5.1. If I add proxy_read_timeout 86400; to my Nginx configuration the issue goes away. By default Nginx has a 60 second read timeout which worked just fine on 4.4.0. Below is my working configuration but we need to figure out why that’s no longer enough. I just don’t know enough about how VSCode works to try and track this down.

server {
    listen 443 ssl;
    server_name dev-1.example.com;
    ssl_certificate /etc/pki/tls/certs/dev-1.cer;
    ssl_certificate_key /etc/pki/tls/private/dev-1.key;
    ssl_protocols TLSv1.2 TLSv1.3;

    location / {
      proxy_pass http://localhost:8080/;
      proxy_set_header Host $host;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection upgrade;
      proxy_read_timeout 86400;
      proxy_set_header Accept-Encoding gzip;
    }
}

There might be shorter values that work, like I said I’m not sure what causing the behavior change since other reverse proxies like Caddy don’t seem to do this.

I can confirm that setting proxy_read_timeout 86400; solves the issue