Skip to content
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

SSH: Constant disconnects in VS Code when working on a Next.js app #19284

Open
mrodrigues95 opened this issue Dec 19, 2023 · 7 comments
Open

Comments

@mrodrigues95
Copy link

Bug description

When connecting to a Gitpod workspace via VS Code desktop, I'm noticing my SSH connection periodically lose connection as I'm working. Interesting enough, I'm noticing that this mainly occurs while working on a Next.js web app whether I'm saving changes in VS Code or simply just refreshing the app in my web browser.

SSH logs seems to produce client_loop: send disconnect: Unknown error and/or Failed to set up socket for dynamic port forward to remote port 40269: connect ECONNREFUSED 127.0.0.1:49235. Is the remote port correct? when this occurs, before attempting to reconnect again.

One important thing to note is that if I manually forward the ports via SSH before opening the workspace in VS Code (i.e. don't let VS Code auto-forward them), it works smoothly with no random disconnects.

[11:57:25.877] Remote server is listening on port 37629
[11:57:25.877] Parsed server configuration: {"serverConfiguration":{"remoteListeningOn":{"port":37629},"osReleaseId":"ubuntu","arch":"x86_64","sshAuthSock":"","display":"","tmpDir":"/tmp","platform":"linux","execServerToken":"f7c3be699edb"},"serverStartTime":76,"installUnpackCode":""}
[11:57:25.881] Starting forwarding server. local port 49276 -> socksPort 49265 -> remotePort 37629
[11:57:25.882] Forwarding server listening on port 49276
[11:57:25.882] Waiting for ssh tunnel to be ready
[11:57:25.882] Tunneled port 37629 to local port 49276
[11:57:25.883] Resolved "ssh-remote+7b22686f73744e616d65223a226d726f6472696775657339352d6368617473652d6e3736636a3562317473782e7673732e676974706f642e696f222c2275736572223a226d726f6472696775657339352d6368617473652d6e3736636a356231747378227d" to "port 49276"
[11:57:25.883] Resolving exec server at port 49276
[11:57:25.883] [Forwarding server port 49276] Got connection 0
[11:57:25.886] [Forwarding server port 49276] Got connection 1
[11:57:26.157] Exec server for ssh-remote+7b22686f73744e616d65223a226d726f6472696775657339352d6368617473652d6e3736636a3562317473782e7673732e676974706f642e696f222c2275736572223a226d726f6472696775657339352d6368617473652d6e3736636a356231747378227d created and cached
[11:57:28.909] [Forwarding server port 49250] Got connection 4
[11:58:02.431] [Forwarding server port 49250] Got connection 5
[11:58:02.432] [Forwarding server port 49250] Got connection 6
[11:58:02.695] [Forwarding server port 49250] Got connection 7
[11:58:03.159] [Forwarding server port 49250] Got connection 8
[11:58:03.160] [Forwarding server port 49250] Got connection 9
[11:59:22.503] > client_loop: send disconnect: Unknown error
[11:59:23.786] "install" terminal command done
[11:59:23.786] Install terminal quit with output: client_loop: send disconnect: Unknown error
[11:59:40.272] ------




[11:59:40.273] SSH Resolver called for "ssh-remote+7b22686f73744e616d65223a226d726f6472696775657339352d6368617473652d6e3736636a3562317473782e7673732e676974706f642e696f222c2275736572223a226d726f6472696775657339352d6368617473652d6e3736636a356231747378227d", attempt 2, (Reconnection)
[11:59:40.276] SSH Resolver called for host: mrodrigues95-chatse-n76cj5b1tsx@mrodrigues95-chatse-n76cj5b1tsx.vss.gitpod.io
[11:59:40.276] Setting up SSH remote "mrodrigues95-chatse-n76cj5b1tsx.vss.gitpod.io"
[11:59:40.277] Using commit id "0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2" and quality "stable" for server
[11:59:40.281] Install and start server if needed
[11:59:40.287] Running script with connection command: "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 49235 "mrodrigues95-chatse-n76cj5b1tsx@mrodrigues95-chatse-n76cj5b1tsx.vss.gitpod.io" bash
[11:59:40.288] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[11:59:40.521] > �]0;C:\WINDOWS\System32\cmd.exe�
[11:59:40.521] Got some output, clearing connection timeout
[11:59:42.278] > 0f5affcbf913: running
[11:59:42.370] > Acquiring lock on /home/gitpod/.vscode-server/bin/0ee08df0cf4527e40edc9aa28f4b5b
> d38bbff2b2/vscode-remote-lock.gitpod.0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2   
[11:59:42.386] > Found existing installation at /home/gitpod/.vscode-server/bin/0ee08df0cf4527e40
> edc9aa28f4b5bd38bbff2b2...
> Checking /home/gitpod/.vscode-server/.0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2.l
> og and /home/gitpod/.vscode-server/.0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2.pid
>  for a running server
> Looking for server with pid: 1724
> Found running server...
> Installing extensions...
[11:59:42.559] > Installing extensions...
[11:59:42.636] > Extension 'gitpod.gitpod-remote-ssh' v0.0.50 is already installed. Use '--force'
>  option to update to latest version or provide '@<version>' to install a specifi
> c version, for example: 'gitpod.gitpod-remote-ssh@1.2.3'.
[11:59:42.676] > 
> *
> * Visual Studio Code Server
> *
> * By using the software, you agree to
> * the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-lice
> nse) and
> * the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacyst
> atement).
> *
> 
[11:59:42.683] > Checking server status on port 40269 with wget
> 0f5affcbf913: start
> SSH_AUTH_SOCK====
> DISPLAY====
> webUiAccessToken====
> listeningOn==40269==
> osReleaseId==ubuntu==
> arch==x86_64==
> vscodeArch==x64==
> bitness==64==
> tmpDir==/tmp==
> platform==linux==
> unpackResult====
> didLocalDownload==0==
> downloadTime====
> installTime====
> extInstallTime==290==
> serverStartTime====
> connectionToken==a1a1aaa1-a11a-1a1a-1111-111a11aaa11a==
> 0f5affcbf913: end
[11:59:42.683] Received install output: 
SSH_AUTH_SOCK====
DISPLAY====
webUiAccessToken====
listeningOn==40269==
osReleaseId==ubuntu==
arch==x86_64==
vscodeArch==x64==
bitness==64==
tmpDir==/tmp==
platform==linux==
unpackResult====
didLocalDownload==0==
downloadTime====
installTime====
extInstallTime==290==
serverStartTime====
connectionToken==a1a1aaa1-a11a-1a1a-1111-111a11aaa11a==

[11:59:42.684] Remote server is listening on port 40269
[11:59:42.684] Parsed server configuration: {"serverConfiguration":{"remoteListeningOn":{"port":40269},"osReleaseId":"ubuntu","arch":"x86_64","webUiAccessToken":"","sshAuthSock":"","display":"","tmpDir":"/tmp","platform":"linux","connectionToken":"a1a1aaa1-a11a-1a1a-1111-111a11aaa11a"},"extInstallTime":290,"installUnpackCode":""}
[11:59:42.689] Starting forwarding server. local port 49467 -> socksPort 49235 -> remotePort 40269
[11:59:42.690] Forwarding server listening on port 49467
[11:59:42.690] Waiting for ssh tunnel to be ready
[11:59:42.691] Tunneled port 40269 to local port 49467
[11:59:42.692] Resolved "ssh-remote+7b22686f73744e616d65223a226d726f6472696775657339352d6368617473652d6e3736636a3562317473782e7673732e676974706f642e696f222c2275736572223a226d726f6472696775657339352d6368617473652d6e3736636a356231747378227d" to "port 49467"
[11:59:42.693] [Forwarding server port 49467] Got connection 0
[11:59:42.698] ------




[11:59:42.715] > 
[11:59:42.728] [Forwarding server port 49467] Got connection 1
[11:59:42.932] [Forwarding server port 49467] Got connection 2

[11:59:42.715] > 
[11:59:42.728] [Forwarding server port 49467] Got connection 1
[11:59:42.932] [Forwarding server port 49467] Got connection 2
[12:02:10.978] [Forwarding server port 49467] Got connection 3
[12:02:36.460] [Forwarding server port 49467] Got connection 4
[12:02:36.595] [Forwarding server port 49467] Got connection 5
[12:02:36.596] [Forwarding server port 49467] Got connection 6
[12:02:36.597] [Forwarding server port 49467] Got connection 7
[12:02:36.598] [Forwarding server port 49467] Got connection 8
[12:02:38.351] [Forwarding server port 49467] Got connection 9
[12:02:38.562] Failed to set up socket for dynamic port forward to remote port 40269: read ECONNRESET. Is the remote port correct?
[12:02:38.563] Failed to set up socket for dynamic port forward to remote port 40269: read ECONNRESET. Is the remote port correct?
[12:02:38.563] Failed to set up socket for dynamic port forward to remote port 40269: read ECONNRESET. Is the remote port correct?
[12:02:38.570] > client_loop: send disconnect: Unknown error
[12:02:38.595] Failed to set up socket for dynamic port forward to remote port 40269: connect ECONNREFUSED 127.0.0.1:49235. Is the remote port correct?
[12:02:39.846] "install" terminal command done
[12:02:39.847] Install terminal quit with output: client_loop: send disconnect: Unknown error
[12:02:54.344] Failed to set up socket for dynamic port forward to remote port 40269: connect ECONNREFUSED 127.0.0.1:49235. Is the remote port correct?
[12:02:54.345] Failed to set up socket for dynamic port forward to remote port 40269: connect ECONNREFUSED 127.0.0.1:49235. Is the remote port correct?
[12:02:57.267] Failed to set up socket for dynamic port forward to remote port 40269: connect ECONNREFUSED 127.0.0.1:49235. Is the remote port correct?
[12:02:57.821] ------

Steps to reproduce

Open up the mentioned Gitpod workspace instance in VS Code desktop, observe random disconnects while using the Next.js app at http://localhost:3000/login.

Workspace affected

mrodrigues95-chatse-n76cj5b1tsx

Expected behavior

I shouldn't be disconnected so often.

Example repository

https://github.com/mrodrigues95/chatse

Anything else?

No response

@jeanp413
Copy link
Member

jeanp413 commented Dec 23, 2023

Hi @mrodrigues95, I tried to repro but couldn't, do I just need to visit http://localhost:3000/login or do I need to login too?
Also I have a couple of questions:

  • Does this issue started recently for you?
  • Does it happen randomly or is it a constant thing?
  • Does it happen for all the workspaces you create?

@mrodrigues95
Copy link
Author

mrodrigues95 commented Dec 23, 2023

Hey @jeanp413,

You should be able to reproduce by just visiting http://localhost:3000/login or http://localhost:3000/signup, you may need to refresh the page a few times before being disconnected. I've attached a video below with a demonstration of what's going on.

  • I'm fairly new to Gitpod but it's been consistently happening for me ever since I started opening up my workspace(s) in the VS Code desktop app.
  • It seems kind of random, although I seem to reproduce the disconnects quite a bit by just visiting the Next.js app and/or refreshing the page a few times. It happens enough where the VS Code desktop instance is unusable, I've resorted to using the in-browser instance or manually forwarding the ports (as mentioned in the original post) for now.
  • Yes; I've recently created a new workspace at mrodrigues95-chatse-u45mnfqfzyk and it reproduces there as well.
23.12.2023_13.28.25_REC.mp4

@jeanp413
Copy link
Member

jeanp413 commented Jan 9, 2024

@mrodrigues95 do you still experience this consistently? if so could you run the Developer: Measure Extension Host Latency command when connected to a workspace and share the output 🙏

@mrodrigues95
Copy link
Author

@jeanp413 Yeah, I'm still experiencing this consistently, Here's the output:

Roundtrip latency: 1.120ms
Up: 1418.4 Mbps
Down: 1495.3 Mbps


Authority: ssh-remote+7b22686f73744e616d65223a226d726f6472696775657339352d6368617473652d733379743371726a39616d2e7673732e676974706f642e696f222c2275736572223a226d726f6472696775657339352d6368617473652d733379743371726a39616d227d
Roundtrip latency: 70.400ms
Up: 434.5 Mbps
Down: 439.1 Mbps

I've ran it a few times and it seems pretty consistent with above when idle. I noticed when the workspace disconnects, the latency seems to spike to ~2-4s before going back to < 100ms once reconnected, e.g.

Roundtrip latency: 0.720ms
Up: 1687.8 Mbps
Down: 1629.3 Mbps


Authority: ssh-remote+7b22686f73744e616d65223a226d726f6472696775657339352d6368617473652d733379743371726a39616d2e7673732e676974706f642e696f222c2275736572223a226d726f6472696775657339352d6368617473652d733379743371726a39616d227d
Roundtrip latency: 4439.250ms
Up: 331.4 Mbps
Down: 172.1 Mbps

Again, this only seems to be the case when navigating around the NextJS app as shown in the previous video.

@brianmhunt
Copy link

I've a very similar problem with a firebase app, using the firebase emulator with a single page app.

@akosyakov
Copy link
Member

Could you try to set "remote.SSH.useLocalServer" to false and see whether it improves. We were able to reproduce the issue outside of Gitpod as well and reported on the upstream: microsoft/vscode-remote-release#9921

@jeanp413
Copy link
Member

We were able to reproduce the issue outside of Gitpod as well and reported on the upstream: microsoft/vscode-remote-release#9921

Different issue, but we can repro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants