github / gh-net

A network bridge between a Codespace and a local machine.
https://github.com/github/gh-net
284 stars 21 forks source link

Possible issue with Network Proxy settings #40

Open C1aud3 opened 2 years ago

C1aud3 commented 2 years ago

The sudo gh net start command gives the following error:

choosing codespace: error getting codespaces: error making request: Get "https://api.github.com/user/codespaces?per_page=100": dial tcp 140.82.113.5:443: i/o timeout

Reproduce steps

  1. From my desktop, connect to my private enterprise network using a VPN client (Cisco AnyConnect 4.10.01075).
  2. Configure required enterprise proxy settings through the HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment variables.
  3. Optional: run gh codespace list to make sure proxy settings are configured properly.
  4. Run sudo gh net start. The command will fail with the error message provided above.

Expected behavior The sudo gh net start command should display the list of codespaces to choose from successfully.

Desktop:

Additional context The sudo gh net start command successfully displays the list of codespaces when NOT connected to VPN.

legomushroom commented 2 years ago

@C1aud3 thanks for reporting this! Can you try connecting to the Codespace with SSH?

[sudo] gh codespace ssh

This should give us an idea if this is GH CLI issue or not.

Also mind trying the gh codespace list with sudo, e.g. sudo gh codespace list?

Thanks!

C1aud3 commented 2 years ago

@C1aud3 thanks for reporting this! Can you try connecting to the Codespace with SSH?

[sudo] gh codespace ssh

This should give us an idea if this is GH CLI issue or not.

Also mind trying the gh codespace list with sudo, e.g. sudo gh codespace list?

Thanks!

Hi @legomushroom ! The results are below. It looks like using sudo is causing issues.

legomushroom commented 2 years ago

@C1aud3 thanks for testing this!

Wondering if that is a credentials issue, mind trying this:

  1. gh auth status -t -> copy the token
  2. sudo gh auth logout
  3. echo {TOKEN} | sudo gh auth login --with-token
  4. Try connecting to a Codespace again(with sudo) 🤞

We will remove the sudo requirement in the next extension release 🚀

C1aud3 commented 2 years ago

Hi @legomushroom, unfortunately it didn't seem to solve the issue. Here's what I got:

  1. gh auth status -t -> copy the token : ✅
  2. sudo gh auth logout: ✅ Note: The command works with sudo but takes over 30 seconds to execute. Running the command without sudo executes instantly.
  3. echo {TOKEN} | sudo gh auth login --with-token: ❌
    • Fails with: error validating token: Get "https://api.github.com/": dial tcp 140.82.114.6:443: i/o timeout
    • To proceed further, I had to login without using sudo
      1. Try connecting to a Codespace again(with sudo): ❌
    • Fails with the same dial tcp 140.82.112.5:443: i/o timeout error.

Hopefully the upcoming removal of the sudo requirement resolves this 🤞

C1aud3 commented 1 year ago

@legomushroom I confirm I'm still having the issue with the latest version of the plugin and running the gh net start command without sudo:

gh net start
Password:

choosing codespace: error getting codespaces: error making request: Get "https://api.github.com/user/codespaces?per_page=100": dial tcp 140.82.113.5:443: i/o timeout

Plugin version:

gh --version && gh extension list
gh version 2.14.7 (2022-08-25)
https://github.com/cli/cli/releases/tag/v2.14.7
gh net  github/gh-net  v0.12.2
legomushroom commented 1 year ago

@C1aud3 mind trying this custom dev0.12.5-beta1 build? You can install it like this:

gh extension install legomushroom/gh-net

Thanks!

C1aud3 commented 1 year ago

@C1aud3 mind trying this custom dev0.12.5-beta1 build? You can install it like this:

gh extension install legomushroom/gh-net

Thanks!

I'll try to test this a little bit more extensively this week, but a quick test this morning allowed me to successfully list codespaces, select one and connect to it without any error messages. 🎉

legomushroom commented 1 year ago

@C1aud3 thanks for trying it out! Looks like the issue was in missing some of the environment variables.

When we escalate to the root, we allow only few env variables to be inherited for the new escalated process. The custom build you've tried out is the same as released 0.12.4 but now allows for all env vars to be inherited by the new process.Do you know if your proxy setup use any env variables?

C1aud3 commented 1 year ago

Hi @legomushroom , thanks for the fix! Yes, my proxy setup uses env variables. As per my original posting:

Configure required enterprise proxy settings through the HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment variables.

raphberube commented 1 year ago

Hi @legomushroom, I'm working with @C1aud3. Do you have any idea of when this fix will be officially released?