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

debugpy reverse connectivity support #10379

Closed
int19h opened this issue Mar 2, 2020 · 9 comments
Closed

debugpy reverse connectivity support #10379

int19h opened this issue Mar 2, 2020 · 9 comments
Labels
feature-request Request for new features or functionality

Comments

@int19h
Copy link

int19h commented Mar 2, 2020

We're making the existing reverse-connection support (when the debugged process connects to the IDE, rather than the other way around - microsoft/ptvsd#1824) officially supported in debugpy to simplify some user scenarios. In ptvsd, it's only used internally for attach-to-PID.

This means that we need to surface it on the IDE side of things - at the mininum, launch.json, and any associated UX. We need to figure out what exactly it should look like, and make the necessary changes on the extension side.

@int19h int19h added feature-request Request for new features or functionality needs decision labels Mar 2, 2020
@int19h
Copy link
Author

int19h commented Mar 2, 2020

launch.json proposal

Currently, a configuration like this is used for attach:

{
  "request": "attach",
  "host": "127.0.0.1",
  "port": 5678,
}

The direction of the connection in this case is from the IDE to the debug server. Now, we're going to need a way to indicate that the direction is reversed - that the IDE (or rather, the debug adapter) should wait for an incoming connection from the debug server. Furthermore, we want the users to be explicit when choosing the direction - a bad default here can send them down to the path of most resistance to solve their problem.

On the server side, we use --listen and --connect in the CLI, and debugpy.listen() and debugpy.connect() in the API, to indicate the direction of the connection, with connection information passed as an argument. The proposal is to apply the same pattern in JSON thus:

// IDE -> server; same as above
{
  "request": "attach",
  "connect":  {
    "host": "127.0.0.1",
    "port": 5678,
  }
}

// server -> IDE
{
  "request": "attach",
  "listen":  {
    "host": "127.0.0.1",
    "port": 5678,
  }
}

Thus, in any remote attach scenario, it's always "listen" on one end, and "connect" on the other. The objects that have host/port info can have other properties added to them in the future that pertain specifically to connectivity - e.g. if we do implicit SSH port tunneling, this would be where the related settings go.

For backwards compatibility, we should continue to support top-level "host" and "port", and treat them as if they were "connect". However, we should encourage users to update, e.g. by not reflecting that legacy support in launch.json schema.

@int19h
Copy link
Author

int19h commented Jun 16, 2020

@luabud, do we need anything else for this, other than launch.json schema changes (which are already done)?

@luabud
Copy link
Member

luabud commented Jun 18, 2020

@int19h I think we will want to change our default Remote attach configuration to use it (and perhaps create an issue to remove "host" and "port" from the top-level in the launch.json schema if that wasn't part of the updates?). But I believe these can be tracked as separate items if you think that would make sense 😊

@int19h
Copy link
Author

int19h commented Jun 19, 2020

@luabud The debugger still supports top-level "host" and "port" for backwards compatibility. If we remove them from the schema, existing configs will get squiggles (even though they still work). So we probably shouldn't remove those, unless we also add a way to automatically warn about & fix those configs, similar to "pythonPath" treatment.

I suggest that we only change the launch.json templates for now, but keep "host" and "port", to minimize disruption for the users. Then remove it from the schema in the next release, when people are already aware of the new syntax.

@karthiknadig
Copy link
Member

This is done right?

@int19h
Copy link
Author

int19h commented Jul 14, 2020

Yep.

@chitalian
Copy link

Thanks for adding this feature! Is there a way to add a timeout on the listen? Right now its about 5 seconds from what I can tell

@chitalian
Copy link

Another cool feature would be able to run a task while listening.

@int19h
Copy link
Author

int19h commented Sep 21, 2020

@chitalian There's no way to specify a timeout, and we don't actually implement any timeout logic currently... so if it stops debugging after 5s, I suspect it might be VSCode itself.

For the feature request, can you please file it as a separate issue, and describe it in a bit more detail?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants