You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Published "appPorts" are not reused when opened using serverReadyAction (and likely vscode.env.openExternal / asExternalUri) #1817
Currently it appears that if you use the appPort property in devcontainer.json, the port is not reused if launched from serverReadyAction in launch.json. This is likely the case with vscode.env.openExternal and vscode.env.asExternalUri as well.
Expected: A browser window pointing to http://127.0.0.1:5000 appears Actual: Browser opens http://127.0.0.1:<random port>
The random port appears to be due to the fact that 5000 is already in use - which is true because devcontainer.json includes "appPort":[5000,5001] and the web application is listening on 5000 already.
This might happen with SSH for ports that were forwarded using ~/.ssh/config as well.
Alex Ross (@alexr00) The extension now tells the core which ports are being forwarded, so this would seem to be possible to implement. Maybe it already is?
The ITunnelService allows you to get the tunnels which returns an array of RemoteTunnels that debug could check, but we don't keep track of the "source" of the forward. I'm not sure this matters. Andre Weinand (@weinand) would you want a source to check against? A tunnel could exist for several reasons:
an extension forwarded a port
there was an API call to openExternal or resolveExternal
In the case that the source is the user: If the user is trying to forward and using local port 5000 and we see that they there is already a tunnel using 5000 then we should pick a different local port.
One limitation of appPort is that its local endpoint is on the machine where the Docker daemon runs. Maybe the extension should not return these ports when the connection is not to a socket path (as a heuristic) since the 'open' action also wouldn't work if the daemon runs remotely.
Updated Remote-Containers to only return exposed ports as existing tunnels if DOCKER_HOST is not set (otherwise assuming they are exposed on another machine).
Activity
chrmarti commentedon Nov 11, 2019
The resolver will need a way to tell the core that a certain port is being forwarded.
chrmarti commentedon Feb 26, 2020
Alex Ross (@alexr00) The extension now tells the core which ports are being forwarded, so this would seem to be possible to implement. Maybe it already is?
alexr00 commentedon Feb 26, 2020
The
ITunnelServiceallows you to get thetunnelswhich returns an array ofRemoteTunnelsthat debug could check, but we don't keep track of the "source" of the forward. I'm not sure this matters. Andre Weinand (@weinand) would you want a source to check against? A tunnel could exist for several reasons:openExternalorresolveExternalchrmarti commentedon Feb 26, 2020
Alex Ross (@alexr00) Couldn't the the tunnel service return the existing local port when there already is one?
alexr00 commentedon Feb 26, 2020
No, since if the request to open a tunnel comes from any of the sources we do need to use a different port.
chrmarti commentedon Feb 26, 2020
Which sources and why can't the existing tunnel not be reused?
alexr00 commentedon Feb 26, 2020
In the case that the source is the user: If the user is trying to forward and using local port 5000 and we see that they there is already a tunnel using 5000 then we should pick a different local port.
chrmarti commentedon Oct 26, 2020
Alex Ross (@alexr00) I guess if the remote port is the same as in the existing forwarding, couldn't that be reused?
alexr00 commentedon Oct 26, 2020
I agree, we should be able to do that.
chrmarti commentedon Oct 27, 2020
One limitation of
appPortis that its local endpoint is on the machine where the Docker daemon runs. Maybe the extension should not return these ports when the connection is not to a socket path (as a heuristic) since the 'open' action also wouldn't work if the daemon runs remotely.chrmarti commentedon Nov 17, 2020
Updated Remote-Containers to only return exposed ports as existing tunnels if DOCKER_HOST is not set (otherwise assuming they are exposed on another machine).
alexr00 commentedon Nov 23, 2020
Fixed this with microsoft/vscode@f19b190