Skip to content

Cannot reconnect. Please reload the window. #4693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kkv0id opened this issue Jan 6, 2022 · 30 comments · Fixed by #4840
Closed

Cannot reconnect. Please reload the window. #4693

kkv0id opened this issue Jan 6, 2022 · 30 comments · Fixed by #4840
Assignees
Labels
high-priority This issue needs to be resolved ASAP
Milestone

Comments

@kkv0id
Copy link

kkv0id commented Jan 6, 2022

OS/Web Information

  • Web Browser: Google Chrome 97.0.4692.71
  • Local OS: windows 11
  • Remote OS: centos 8
  • Remote Architecture: amd64
  • code-server --version: 4.0.1

same of #1884

 INFO [Service Worker] registered
log.ts:301  INFO [remote-connection][ExtensionHost][1a408…][reconnect] starting reconnecting loop. You can get more information with the trace log level.
log.ts:301  INFO [remote-connection][ExtensionHost][1a408…][reconnect] resolving connection...
log.ts:301  INFO [remote-connection][ExtensionHost][1a408…][reconnect] connecting to 10.1.1.182:443...
log.ts:301  INFO [remote-connection][ExtensionHost][1a408…][reconnect] reconnected!
log.ts:301  INFO [remote-connection][ExtensionHost][1a408…][reconnect] starting reconnecting loop. You can get more information with the trace log level.
log.ts:301  INFO [remote-connection][ExtensionHost][1a408…][reconnect] resolving connection...
log.ts:301  INFO [remote-connection][ExtensionHost][1a408…][reconnect] connecting to 10.1.1.182:443...
log.ts:301  INFO [remote-connection][ExtensionHost][1a408…][reconnect] reconnected!
log.ts:313   ERR Error received from starting extension host (kind: Remote)
log.ts:313   ERR The remote extenion host took longer than 60s to send its ready message.
log.ts:301  INFO [remote-connection][ExtensionHost][1a408…][reconnect] starting reconnecting loop. You can get more information with the trace log level.
log.ts:301  INFO [remote-connection][ExtensionHost][1a408…][reconnect] resolving connection...
log.ts:301  INFO [remote-connection][ExtensionHost][1a408…][reconnect] connecting to 10.1.1.182:443...
log.ts:313   ERR [remote-connection][ExtensionHost][1a408…][reconnect][10.1.1.182:443] received error control message when negotiating connection. Error:
log.ts:313   ERR Error: Connection error: Unknown reconnection token (seen before)
    at W (remoteAgentConnection.ts:732:17)
    at remoteAgentConnection.ts:327:17
    at l.fire (event.ts:577:16)
    at u.fire (ipc.net.ts:511:19)
    at r._receiveMessage (ipc.net.ts:873:27)
    at ipc.net.ts:818:73
    at l.fire (event.ts:577:16)
    at d.acceptChunk (ipc.net.ts:284:21)
    at ipc.net.ts:245:51
    at browserSocketFactory.ts:197:39
log.ts:313   ERR [remote-connection][ExtensionHost][1a408…][reconnect] A permanent error occurred in the reconnecting loop! Will give up now! Error:
log.ts:313   ERR Error: Connection error: Unknown reconnection token (seen before)
    at W (remoteAgentConnection.ts:732:17)
    at remoteAgentConnection.ts:327:17
    at l.fire (event.ts:577:16)
    at u.fire (ipc.net.ts:511:19)
    at r._receiveMessage (ipc.net.ts:873:27)
    at ipc.net.ts:818:73
    at l.fire (event.ts:577:16)
    at d.acceptChunk (ipc.net.ts:284:21)
    at ipc.net.ts:245:51
    at browserSocketFactory.ts:197:39
abstractExtensionService.ts:644 Extension host (Remote) terminated unexpectedly. Code: 0, Signal: null

Steps to Reproduce

  1. edit config.yaml and add this:
bind-addr: 127.0.0.1:8080
auth: password
password: "12345"
cert: true
  1. run code-server: code-server

Expected

code-server can be accessed via HTTPS and all expected features work.

Actual

Browser complains about about SSL certificate says "Cannot reconnect"

Screenshot

image

@wombatinua
Copy link

I have the same situation.
Additionally it seems like some extensions can't load their settings and don't work.

@tenpaiyomi
Copy link

Receiving the same issue here as well, completely fresh install. I've noticed a few things, similar to the above, which makes me believe this is the extension host again.

1, the reconnecting loop happens exactly 3 times.
2, Between the 2nd and 3rd reconnect loop, I'm getting the following error message in the console logs

The connection to wss://192.168.1.5:8500/?type=ExtensionHost&reconnectionToken=6661fa0b-34b7-457a-8498-104b5f0249be&reconnection=true&skipWebSocketFrames=false was interrupted while the page was loading.

3, After the 2nd reconnect, before the 3rd, I get the following errors:

Error received from starting extension host (kind: Remote)
The remote extenion host took longer than 60s to send its ready message.

@tenpaiyomi
Copy link

Additionally, reverting to 3.12.0, I do not exhibit the above behavior.

@aleleba
Copy link

aleleba commented Jan 6, 2022

It happens to me too.

@jsjoeio
Copy link
Contributor

jsjoeio commented Jan 7, 2022

Can someone please provide reproduction steps? I'm running 4.0.1 on macOS with Brave and do not see this.

@jsjoeio jsjoeio added the waiting-for-info Waiting for more information from submitter label Jan 7, 2022
@tenpaiyomi
Copy link

@jsjoeio for me it was just installing the image, starting it up and loading up the UI. Latest Firefox, Win 10.

@jsjoeio
Copy link
Contributor

jsjoeio commented Jan 7, 2022

I'm running from source directly on macOS + Brave and can't reproduce this :(

image

@code-asher any ideas?

@onepunchdan
Copy link

onepunchdan commented Jan 7, 2022

For me, this behavior occurs on a fresh install when specifying a cert in config.yaml. Extensions successfully load with cert: false and I no longer get the "Cannot reconnect. Please reload the window." popup.

(edit: my environment)
Pop!_OS 21.10 x86_64
Firefox 96.0b10

@JtMotoX
Copy link

JtMotoX commented Jan 8, 2022

@onepunchdan good catch!

I upgraded to 4.0.1 and now none of my extensions loaded and after about 5 seconds I receive the error and same console logs that the OP mentioned.

I commented out my cert configs in my config.yaml and reloaded and now it loads fine with all my extensions and no errors (except for the untrusted connection error).

@jsjoeio maybe this will be enough info for you to replicate the issue?

@tenpaiyomi
Copy link

Counter point, I have never touched the config.yml file when experiencing this issue. I went and checked mine to be sure and it is, I presume, default:

bind-addr: 127.0.0.1:8080
auth: password
password: <redacted>
cert: false

@ochen1
Copy link

ochen1 commented Jan 8, 2022

Additionally, reverting to 3.12.0, I do not exhibit the above behavior.

I can confirm, 3.12.0 does not exhibit the same behavior. No errors after downgrading.

@JtMotoX
Copy link

JtMotoX commented Jan 8, 2022

I was able to downgrade my Ubuntu install which is working fine now.

> curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 3.12.0
Ubuntu 20.04.3 LTS
Installing v3.12.0 of the amd64 deb package from GitHub.

How do I downgrade my macOS install? Even though I pass the version, it tries to install the latest.

> curl -fsSL https://code-server.dev/install.sh | sh -s -- --version 3.12.0
macOS v11.6.2
Installing latest from Homebrew.

@vincentchu37
Copy link

Can confirm same behavior using the codercom/code-server:4.0.1 docker image on docker. codercom/code-server:3.12.0 works as intended.

vincent@3:~/code/.config/code-server$ cat config.yaml 
bind-addr: 127.0.0.1:5443
auth: password
password: redacted
cert: true
proxy-domain: code.quickbrownfoxes.org

@JtMotoX
Copy link

JtMotoX commented Jan 9, 2022

This can be replicated & tested on any system (tested on macOS, Windows, and Linux) with the docker command below.

Log in with https on port 8080 with the password "temp" and bypass the untrusted cert warning. Just sit back and watch the Console logs and after about 2 minutes you will get the connection error. Even when I pass a valid trusted cert, I still get the reconnection errors.

If I remove the --cert flag and log in with http, I do not get any reconnection errors.

docker run --rm --name code-server --entrypoint "/usr/bin/entrypoint.sh" -p 0.0.0.0:8080:8080 -e PASSWORD="temp" codercom/code-server:4.0.1 --bind-addr 0.0.0.0:8080 --auth "password" --cert

@jsjoeio
Copy link
Contributor

jsjoeio commented Jan 10, 2022

@code-asher any ideas on this?

@jsjoeio
Copy link
Contributor

jsjoeio commented Jan 10, 2022

How do I downgrade my macOS install? Even though I pass the version, it tries to install the latest.

@JtMotoX Looks like it installed with Homebrew. AFAIK, Homebrew does not keep track of old formula so you can't downgrade using Homebrew. You should be able to brew remove code-server and then download a standalone release to downgrade versions. See these docs

@jsjoeio jsjoeio added needs-investigation This issue needs to be further investigated and removed waiting-for-info Waiting for more information from submitter labels Jan 10, 2022
@code-asher
Copy link
Member

code-asher commented Jan 10, 2022 via email

@danopia
Copy link

danopia commented Jan 13, 2022

So the current status of 4.x is that it doesn't work with existing TLS certificates? Given that numerous features (clipboard, webview, etc) only work when loaded from HTTPS this seems like a pretty important issue..

I had trouble getting Chrome to properly take the self-signed certs so instead, I was able to get my session working again by putting code-server on a different HTTP port and then running a Caddy instance in front:

$ cat ~/.local/share/code-server/Caddyfile
my-code-server.danopia.net:8080

reverse_proxy localhost:8079
tls cert.pem cert-key.pem

This reverse proxy situation seems to work properly without triggering "Cannot reconnect" message

@JtMotoX
Copy link

JtMotoX commented Jan 13, 2022

I had trouble getting Chrome to properly take the self-signed certs so instead, I was able to get my session working again by putting code-server on a different HTTP port and then running a Caddy instance in front

I thought about doing this with a docker nginx reverse proxy sitting in front of it but it just seemed easier to rollback to 3.x until this issue gets resolved.

@hugoovf
Copy link

hugoovf commented Jan 20, 2022

Even with the extensions activated, I try to open the list of accounts and it keeps loading, until several seconds pass and the same error appears. I think the problem is there.

@JtMotoX
Copy link

JtMotoX commented Jan 28, 2022

Still have the same issue with the newly released v4.0.2.

@jsjoeio
Copy link
Contributor

jsjoeio commented Jan 28, 2022

@JtMotoX thank you for confirming! We'll hopefully get to this soon.

@hecnavsanz
Copy link

Hi, I've been working during months w/ 4.0.1 ('ms-python.python', 'redhat.java' and 'kelvin.vscode-sshfs' extensions) deploying many different environments w/o any issues using "curl -fsSL https://code-server.dev/install.sh | sh" and systemctl and the following "$HOME/.config/code-server/config.yaml" file:

bind-addr: <server_ip>:443
auth: none
cert: true

after upgrading to 4.0.2 I'm getting the same error "Cannot reconnect. Please reload the window." in the web browser.

I started manually Code-Server w/ "code-server --verbose" and this is the log output:

[13:49:02] Started scanning user extensions
[13:49:02] Scanned user extensions: 0
[2022-01-29T13:49:18.050Z] debug 5 active connections
[2022-01-29T13:49:18.050Z] trace heartbeat
[13:49:19] [192.168.56.1][ae561d21][ExtensionHostConnection] - startParams language: en
[13:49:19] [192.168.56.1][ae561d21][ExtensionHostConnection] - startParams env: {"VSCODE_PROXY_URI":"https://192.168.56.10/proxy/{port}"}
[13:49:19] [192.168.56.1][ae561d21][ExtensionHostConnection] The client has reconnected.
[13:49:40] [192.168.56.1][ae561d21][ExtensionHostConnection] - startParams language: en
[13:49:40] [192.168.56.1][ae561d21][ExtensionHostConnection] - startParams env: {"VSCODE_PROXY_URI":"https://192.168.56.10/proxy/{port}"}
[13:49:40] [192.168.56.1][ae561d21][ExtensionHostConnection] The client has reconnected.
[13:50:00] [192.168.56.1][ae561d21][ExtensionHostConnection] - startParams language: en
[13:50:00] [192.168.56.1][ae561d21][ExtensionHostConnection] - startParams env: {"VSCODE_PROXY_URI":"https://192.168.56.10/proxy/{port}"}
[13:50:00] [192.168.56.1][ae561d21][ExtensionHostConnection] The client has reconnected.
[13:50:00] [192.168.56.1][ae561d21][ExtensionHostConnection] <10989> Extension Host Process exited with code: 0, signal: null.
[2022-01-29T13:50:18.051Z] debug 8 active connections
[2022-01-29T13:50:18.051Z] trace heartbeat
[13:50:20] [192.168.56.1][ae561d21][ExtensionHostConnection] - startParams language: en
[13:50:20] [192.168.56.1][ae561d21][ExtensionHostConnection] - startParams env: {"VSCODE_PROXY_URI":"https://192.168.56.10/proxy/{port}"}
[13:50:20] [192.168.56.1][ae561d21][ExtensionHostConnection] Unknown reconnection token (seen before).
[13:50:20] [192.168.56.1][165be397][ManagementConnection] The client has disconnected gracefully, so the connection will be disposed.
[2022-01-29T13:51:18.052Z] debug 7 active connections
[2022-01-29T13:51:18.053Z] trace heartbeat

and even I'm trying to rollback now to install Code-Server w/ the old version 4.0.1 in a totally new env and I don't know why now I'm having the same problem too as of 4.0.2 when it wasn't in the past ... it's supposed that the 4.0.1 code has not been modified, isn't it?

Thanx again.

@jsjoeio
Copy link
Contributor

jsjoeio commented Jan 31, 2022

@kexirong thanks for the notes! I'm not 100% what the issue is. We'll need to take a closer look.

@jsjoeio jsjoeio added this to the On Deck - High Priority milestone Jan 31, 2022
@tomsherrod
Copy link

tomsherrod commented Feb 1, 2022

code-server: v4.0.2
VS Code: v1.63.0
Commit: 5cdfe74
Date: 2022-01-27T22:22:39Z
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36 Edg/96.0.1054.43

Upgraded from 3.11 and now getting the "Cannot reconnect. Please reload window." so often, it's unusable.
Going to try a downgrade.

Re-reading comments, I am using --cert option.
[Service]
Type=exec
ExecStart=/usr/bin/code-server --cert /home/foo/ssl/some.crt --cert-key /home/foo/ssl/some.key --bind-addr 0.0.0.0:8080
Restart=always
User=%i

Running on an ubuntu box, with deb install and upgrades since 3.9.
Reverted to 3.12, no issues.

@jsjoeio jsjoeio added the high-priority This issue needs to be resolved ASAP label Feb 1, 2022
@jsjoeio jsjoeio modified the milestones: On Deck - High Priority, 4.0.3 Feb 1, 2022
@jsjoeio jsjoeio self-assigned this Feb 1, 2022
@invictus2010
Copy link

Just to clarify...this is making code-server unusable for everyone right?

Is there a certain browser it does work with? I work off of my macOS Chrome and my iPad (Safari) and getting this issue in both places.

@vincentchu37
Copy link

Just to clarify...this is making code-server unusable for everyone right?

Is there a certain browser it does work with? I work off of my macOS Chrome and my iPad (Safari) and getting this issue in both places.

Stick with 3.12.0 until they release 4.0.3 where a patch for this issue is slated

@hecnavsanz
Copy link

hecnavsanz commented Feb 4, 2022

Just to clarify...this is making code-server unusable for everyone right?

Is there a certain browser it does work with? I work off of my macOS Chrome and my iPad (Safari) and getting this issue in both places.

for me a fresh 4.0.2 (SSL) installation is not working with "$HOME/.config/code-server/config.yaml" file:

bind-addr: <server_ip>:443
auth: none
cert: true

in any browser in Windows and MacOS.
But more strange is that a fresh installation of 4.0.1 "curl -fsSL https://code-server.dev/install.sh | sh -s -- --version=4.0.1" also is not working now too when it was before 4.0.2 was released.

As a workaround, I disabled SSL in 4.0.2 to use nginx as front-end with "$HOME/.config/code-server/config.yaml" file:

bind-addr: 127.0.0.1:8080
auth: password
password: <my_password>
cert: false

and it's working.

@jsjoeio
Copy link
Contributor

jsjoeio commented Feb 8, 2022

I'm looking into this now. I was able to reproduce locally and updated the original issue with steps and a screenshot.

I need to continue investigating. I'll update this comment with my notes.

Notes

❌ The generated cert is not the issue

If you put cert: true in your config.yaml, we generate an SSL certificate for you. I used openssl to generate a certificate and passed that to code-server --cert <path-to-cert> --cert-key <path-to-key> and received the same results.

Therefore, I do not believe the generated certificate is the root cause of this issue.

❓ What about the place where code-server tells VS Code about the cert?

TODO - investigate

Asher gave me some pointers. I'm going to see if we can take a TDD approach to show this is a bug and then fix it.

Notes from debug with Asher 2/9

It seems that VS Code is getting stuck before sending the socket to the extension host (after calling socket drain). Not sure why, we'll need to investigate tomorrow.

Workarounds

use a tool like ngrok

It appears exposing the port with ngrok solves the problem (because ngrok has a valid SSL certificate).

i.e. ngrok http https://localhost:8080 -> gives you something like https://f2c9-65-127-76-6.ngrok.io/

2/10/22

What do we know so far?

We know that --cert worked in 3.12.0 and this bug did not exist. We wrote a new e2e test that proves this used to by testing it against a 3.12.0 build (video in issue description).

@kkv0id
Copy link
Author

kkv0id commented Feb 14, 2022

Looking forward to it being fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high-priority This issue needs to be resolved ASAP
Projects
None yet
Development

Successfully merging a pull request may close this issue.