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

Tunnel to WSL2 refuses connection #186205

Closed
xisui-MSFT opened this issue Jun 26, 2023 · 3 comments
Closed

Tunnel to WSL2 refuses connection #186205

xisui-MSFT opened this issue Jun 26, 2023 · 3 comments
Labels
*as-designed Described behavior is as designed

Comments

@xisui-MSFT
Copy link
Contributor

xisui-MSFT commented Jun 26, 2023

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.79.2
  • OS Version: Windows 11 (22621.1926) + WSL2 (Ubuntu 22.04)

Steps to Reproduce:

  1. Create a workspace extension, in which create a server listening to a port (workspacePort)
  2. Create a UI extension, in which create a tunnel, like this (proposed API tunnels is required):
    tunnel = await vscode.workspace.openTunnel({ remoteAddress: { port: workspacePort, host: 'localhost' } });
  3. In the UI extension, connect to the tunnel:
    const tunnelConnection = new Promise<void>((resolve, reject) => {
    
        const doConnect = () => tunnelSocket.connect(tunnelPort, 'localhost', () => resolve());
    
        tunnelSocket.on('data', data => {
            ... // Do something
        });
    
        tunnelSocket.on('end', () => {
            ... // Do something
            resolve();
        });
    
        tunnelSocket.on('error', err => {
            if (err) {
                console.log(`Error: ${err.message}`);
            }
    
            ... // Do something
            reject();
        });
    
        doConnect();
    });
  4. Run the extensions, so that the UI extension runs locally, and the workspace extension runs in WSL. Notice that error messages like Error: connect ECONNREFUSED 127.0.0.1:46871 are shown in the console.

A side question: This does NOT repro for docker containers or codespaces. But I wonder if there's a better way to do raw TCP communication between host and WSL?

@xisui-MSFT
Copy link
Contributor Author

@alexr00 Could you please take a look?

@alexr00
Copy link
Member

alexr00 commented Jun 28, 2023

This is by design. We do not support port forwarding with a WSL connection. Someone else just made a feature request to support port forwarding with WSL: microsoft/vscode-remote-release#8621

@alexr00 alexr00 closed this as completed Jun 28, 2023
@alexr00 alexr00 added the *as-designed Described behavior is as designed label Jun 28, 2023
@sandros94
Copy link

@xisui-MSFT, if you are interested, be sure to go about and upvote that feature request.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed
Projects
None yet
Development

No branches or pull requests

3 participants