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

Can't connect from dev container #269

Closed
1 task
Muzosh opened this issue Jun 25, 2024 · 12 comments
Closed
1 task

Can't connect from dev container #269

Muzosh opened this issue Jun 25, 2024 · 12 comments

Comments

@Muzosh
Copy link

Muzosh commented Jun 25, 2024

Software

Pieces OS, VS Code

Operating System / Platform

macOS

Your Pieces OS Version

9.0.7

Early Access Program

  • Yes, this is related to an Early Access Program feature.

Kindly describe the bug and include as much detail as possible on what you were doing so we can reproduce the bug.

Issue description

Hi,

Pieces OS is working fine in VSCode (extension version: v1.16.2), until I load into a dev container.

VSCode gives me these notifications:
image
image

Pieces explorer looks like this:
image

Attempted fixes

I tried to turn off / disable macOS native firewall as well as Lulu completely, but the issue still persists. Not sure how to make inbound firewall rule for port 1000 on macOS, where you need to specify an exact application associated with firewall rules.

One strange behavior

Now, one thing is strange - if PiecesOS is turned off before opening VSCode and I open a VSCode in dev container straight away, PiecesOS automatically starts and shows me the welcome window:
image

Does it mean, that the VSCode extension inside dev container (i.e. docker container) can communicate with host and startup the application? If so, why does it fail to communicate further?

@github-actions github-actions bot added status:new The ticket has been created and is awaiting initial review. app:pieces os app:vs code labels Jun 25, 2024
@rosie-at-pieces rosie-at-pieces removed the status:new The ticket has been created and is awaiting initial review. label Jun 25, 2024
@caleb-at-pieces
Copy link
Contributor

Hey there @Muzosh there could be a few reasons why the docker container is unable to reach your host machine. You are definitely on the right track here, debugging firewall rules. The fact that Pieces was able to launch is interesting, this is done in the app by opening a custom URI: pieces://launch.

A good first check is to see if you can reach your host machine from a shell running in your docker container. Try running curl http://host.docker.internal:1000/.well-known/health while running Pieces OS. If you receive 'ok' then there is no issue with connecting to the host machine from docker. If this is the case, you might need to mark that in the 'custom url' setting within the VS Code extension, although it should be doing this automatically for you.

I think it would be ideal to try and hop on to debug this one together live, schedule with me here if you're interested: https://calendar.google.com/calendar/u/0/appointments/schedules/AcZssZ3IijT1qgm0GgFeIllIuyy5ehWktuYQiPI6jegH4HlNGApAOMMVPiWCcoj_2aPfvgUiDmHHKcQE

@Muzosh
Copy link
Author

Muzosh commented Jun 25, 2024

Interesting, your curl command indeed resulted in the ok output.

Setting the custom url option to http://host.docker.internal:1000 solved the issue, the VSCode Pieces extensions now works as intended.

@Muzosh
Copy link
Author

Muzosh commented Jun 25, 2024

Removing custom url to be blank makes the issue to emerge again.

@Muzosh
Copy link
Author

Muzosh commented Jun 25, 2024

Anyway, thanks a lot. Would you like to still debug this one live?

@caleb-at-pieces
Copy link
Contributor

@Muzosh Very interesting! I have an idea on how I can resolve this one already, thanks for debugging this one with me.

One piece of advice I have for this is, when you are using VS Code dev containers, make sure that Pieces OS is running before VS Code launches. The extension code for determining that it's running in a dev container actually makes a request to Pieces via the host.docker.internal DNS name provided by docker, so it's currently assuming that it's not in a container if the request fails (which it will also fail if Pieces OS is not running).

I'm still willing to hop on a call about this, although it seems we have narrowed the issue down.

I have an idea on how to improve this, so there will be no requirement to have Pieces OS running prior to launching VS Code in order for this to work.

@caleb-at-pieces
Copy link
Contributor

Before I release this however, I recommend using that custom URL setting as a sort of override until I can get this process streamlined in the next release.

@Muzosh
Copy link
Author

Muzosh commented Jun 26, 2024

Let's put the meeting on hold. I also think this issue is significantly less important now. I will be looking forward for the next release.

One thing to keep in mind: in VSCode, there is a global setting dev.containers.defaultExtensions where I currently have Pieces extension. But there is nothing like dev.containers.defaultSettings, so I will have to input the remote URL while working in dev container, but remove it/keep it blank while working in local instance of VSCode.

I have an idea on how to improve this, so there will be no requirement to have Pieces OS running prior to launching VS Code in order for this to work.

Maybe another (or complementary) approach would be to allow users specify multiple URLs in pieces.customUrl via list and try to ping them all from top to bottom (ending the loop on first success)?

@caleb-at-pieces
Copy link
Contributor

@Muzosh This is an interesting approach, we could definitely do something like this!

When you open VS Code settings, is there a tab for you to select 'dev container' settings? Would that also help you in setting the custom URL for only while you are in a dev container?

image

@eliezedeck
Copy link

Hi, this limitation also affects any remote development environment. For example, Gitpod. So, I think there needs to be a robust implementation in this case, as part of the VSCode instance is thus running on a distant remote server, files are not local, and the extension needs to be able to talk to the VSCode frontend on the user's computer.
Once that is in place, all remote dev environment will work out-of-the box, including dev containers.

@caleb-at-pieces
Copy link
Contributor

Hello @eliezedeck . This is a great point, and in the future we should definitely do more to support things like this in a more user friendly way, however we currently don't have a way to get a cloud based IP address of Pieces OS from the user, without the user taking some action to 1: port forward their Pieces OS instance to the cloud and 2: give the VS Code extension that IP address that Pieces OS is port forwarded to.

I go into this in detail on this documentation page: https://docs.pieces.app/product-highlights-and-benefits/connecting-to-a-remote-pieces-os-instance

@eliezedeck
Copy link

Hey @caleb-at-pieces, well I didn't know about this. So, I think one improvement I could propose, is to put this guide in the page where the error is appearing: both on the notification and the Pieces page. Personnaly, I thought there should have been a portforwarding that I should have done, but I didn't bother because I doubted it might not be fully supported. So, having that in the notification and the Pieces section will be a good indication to the right direction. Thanks a lot!

@caleb-at-pieces
Copy link
Contributor

I added a different notification on startup when a remote environment is detected that should ink to the documentation. The VS Code extension should work without any finicking with dev containers. Thanks for the discussion on this!

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

4 participants