Skip to content

Expose command to establish live connection to remote apps in vscode #947

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Eskibear opened this issue Jan 10, 2023 · 9 comments
Closed

Comments

@Eskibear
Copy link
Contributor

Context
In VS Code Spring Boot Dashboard extension, we want to allow user to establish live connection to remote apps with one click. See microsoft/vscode-spring-boot-dashboard#262 (comment)

This requires vscode-spring-boot to expose a command to establish the connection given jmxUrl.

Current Behavior

Technically I can call command sts/livedata/connect, if jmxUrl of the app is specified in setting boot-java.remote-apps. But that will modify user's settings file.

Expected Behavior
What I'm thinking now is either of the following approaches:
Option a) allow sts/livedata/connect to connect to the app, even when it's not specified in the settings.
Option b) expose a specific command, allowing downstream extensions to establish live connection on demand via calling it.

Or any other approach to unblock the use case.

@martinlippert
Copy link
Member

I would prefer option a, enhancing the existing command with the option to specify all your need to connect to the running process as params to the command. And we can keep this backwards compatible with the existing connect command, so that you can use it for both cases.

@BoykoAlex
Copy link
Contributor

@Eskibear This seems available already to me. Not in the most convenient and documented way, however it seems usable... I'd be very happy if you could try it out and provide feedback.
There are 2 commands to execute rather than 1.

  1. sts/livedata/remoteConnect Defines your remote apps such that you can connect/refresh/disconnect but without changing vscode user settings, i.e. runtime only and not persistent. It has 2 parameters (see Reference Code):
    1. owner - unique string key under which registration of a list of remote apps is done. Replaces previous list of remote apps under the same owner
    2. List of remote apps. JSON of RemoteBootAppData
  2. sts/livedata/connect with the same key you used when added the app in the user settings json file

@Eskibear
Copy link
Contributor Author

@BoykoAlex Thanks for the info. The commandsts/livedata/remoteConnect works. I can also disconnect it by passing an empty list of remote apps.

  • When I have multiple remote apps under the same owner connected, it seems impossible to disconnect one of them without refreshing all the other connections. This all-in-one command is convenient but cannot cover above case. But it's not a big problem, as I don't know if it's common to have multiple livedata connections at the same time, and whether refreshing exiting connection is expensive.

BTW, what was owner initially defined for? Is it level of platform or cloud provider like Cloud Foundry/Azure. Or is it just a more general concept I can use to group remote apps? E.g In Azure if I have multiple apps under different subscription, maybe I can set each subscription as an owner?

@BoykoAlex
Copy link
Contributor

I don't recall what the exact meaning of owner parameter was... @kdvolder might remember. I was actually thinking having app's name as the owner and only one remote app in the list for this such that you only work with one app without interfering with others...

@BoykoAlex
Copy link
Contributor

@Eskibear how's it going? Are you okay with these 2 commands? Is sts/livedata/remoteConnect command sufficient? Feel free to propose anything...

@Eskibear
Copy link
Contributor Author

sts/livedata/remoteConnect is usable, I can register each app with a dedicate owner as you mentioned above. I'm implementing the feature and will let you know if there's any update.

I'm closing this issue now. Thanks!

@Eskibear
Copy link
Contributor Author

Eskibear commented Feb 2, 2023

@BoykoAlex I'm reopening this issue as I find an unexpected behavior when using this command, i.e. I cannot "remoteConnect" the same remote app again after disconnecting it.

Steps to repro:

  1. We can running a spring-petclinic on localhost, e.g. using mvn spring-boot:run
  2. Run sts/livedata/remoteConnect, with params [anArbitraryOwnerId, [{host: "localhost", jmxurl: "http://localhost:8080/actuator"}]] . It's connected.
  3. Call sts/livedata/disconnect with required params like processKey, it's disconnected.
  4. Repeat Step 2, now it fails to establish the connection. At this time, I can establish the connection via either a) pass a new host in the params when calling sts/livedata/remoteConnect, or b) through command "manage live spring boot process connections" (which calls sts/livedata/connect underlying i guess), because now the remote process entry is listed there.

I expect the command sts/livedata/remoteConnect to always work, not only for the first time.

@Eskibear Eskibear reopened this Feb 2, 2023
@BoykoAlex
Copy link
Contributor

I think it should be like this:
Connect:
sts/livedata/remoteConnect with params ['my-app-name', [{host: "localhost", jmxurl: "http://localhost:8080/actuator"}]]
Disconnect:
sts/livedata/remoteConnect with params ['my-app-name', []]

@Eskibear
Copy link
Contributor Author

Eskibear commented Feb 7, 2023

Yes, you are right. Sorry I forgot it after the long vacation... 🤦

@Eskibear Eskibear closed this as completed Feb 7, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants