frosit / addon-projector-server

Allows using JetBrains IDE's in home assistant using projector, similar to the vscode addon.
MIT License
2 stars 1 forks source link

Error when starting addon - KeyError: 'DS' #2

Open ScottG489 opened 1 year ago

ScottG489 commented 1 year ago

Getting this error when I try to start up with default configuration:

Traceback (most recent call last):
  File "/usr/local/bin/projector", line 8, in <module>
    sys.exit(projector())
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/projector_installer/cmd.py", line 276, in auto_install_app
    do_auto_install(config_name, ide_name, port, hostname)
  File "/usr/local/lib/python3.9/dist-packages/projector_installer/actions.py", line 516, in do_auto_install
    apps = get_all_apps(pattern=app_name)
  File "/usr/local/lib/python3.9/dist-packages/projector_installer/products.py", line 228, in get_all_apps
    apps = get_product_releases(kind, timeout=LONG_NETWORK_TIMEOUT)
  File "/usr/local/lib/python3.9/dist-packages/projector_installer/products.py", line 195, in get_product_releases
    res.append(Product(f'{name} {ver}', link, CODE2KIND[code], ver))
KeyError: 'DS'

I also needed to make the following change to even get it to build: https://github.com/frosit/addon-projector-server/commit/45dd0dea9a643fcb1968bfdb016efc98fcbf8634

Thanks for making this addon btw! Not a big fan of VSCode and was thinking of making this myself. Hopefully you're still active!

ScottG489 commented 1 year ago

Updating to the latest version of projector-installer seemed to do the trick: https://github.com/frosit/addon-projector-server/commit/dac6c5d85492bd7d9779d8512714be34e6ff5f4d

However, now I'm getting an error when I try to use the Web UI:

Handshake failure Reason: Bad handshake token If you wish, you can try to reconnect.

frosit commented 1 year ago

Hi, I'm sorry for my delayed response. I'm still active with this kind of technology but a bit less on the home assistant side and was a bit busy past weeks but I'm certainly open to continue on this. I'm a heavy user of projector and related tech and have integrated it in WSL and cloud development environments as well which are my main dev environments. I'm not dependant of OS'es or machines anymore :)

A lot of improvements can be taken from those setups into this. Thank you for reaching out, feel free to create a PR or share thoughts regarding the direction of this project. It has been a while since you posted this ticket so I was wondering, are you still using it? You think it would be nice if we brush this up a little? I know it's a bit unstable... but can be improved if worth it.

ScottG489 commented 1 year ago

Hey, thanks for getting back to me. I wasn't able to get past error I mentioned in my last comment.

I next attempted to try to get Gateway working since it seems like that's the successor/superset of Projector. Unfortunately, you need to have a license and I need to re-apply for my OSS one. I'm not sure if you're familiar with Gateway and how it compares to Projector?

Otherwise, I'm definitely open to try to get this addon working again. I just attempted to run the addon again and got the same error after trying to open the web ui. There's nothing in the addon logs. Does this still addon still work for you?

ScottG489 commented 1 year ago

I was able to get into the addon container and view the projector.log file. After starting up I get this:

--------------------- Projector log session start. Installer version: 1.8.0 Run config: pycharm - 2023-02-02 17:43:56.767871
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[DEBUG] :: IdeState :: Starting attempts to Init ProjectorClassLoader
[DEBUG] :: util.agent.MiscKt :: dynamically attaching agent: jar=/tmp/projector-agent4505149478318043636.jar, args=isAgent=false;mdPanelClass=org.jetbrains.projector.server.core.ij.md.ProjectorMarkdownPanel;isIdeAttached=true
[DEBUG] :: IjInjectorAgent :: IjInjectorAgent agentmain start, args=isAgent=false;mdPanelClass=org.jetbrains.projector.server.core.ij.md.ProjectorMarkdownPanel;isIdeAttached=true
[DEBUG] :: ProjectorBatchTransformer :: Success (State: Initial): [IjAwtTransformer: (java.awt.GraphicsEnvironment)]
[DEBUG] :: IdeState :: Starting attempts to run transformations
[DEBUG] :: IjInjectorAgent :: IjInjectorAgent agentmain finish
[DEBUG] :: util.agent.MiscKt :: dynamically attaching agent is done: jar=/tmp/projector-agent4505149478318043636.jar, args=isAgent=false;mdPanelClass=org.jetbrains.projector.server.core.ij.md.ProjectorMarkdownPanel;isIdeAttached=true
[DEBUG] :: IdeState :: Starting attempts to initialize IDEA: fix AA and disable smooth scrolling (at start)
[DEBUG] :: IdeState :: Starting attempts to Forbid platform updates and plugin update notifications
[DEBUG] :: IdeState :: Starting attempts to Getting IDE colors
[DEBUG] :: ProjectorServer :: Daemon thread starts
[DEBUG] :: IdeState :: Starting attempts to search for editors
[INFO] :: WebsocketServer :: ProjectorServer is starting on host /0.0.0.0 and port 8099
[INFO] :: HttpWsServerBuilder :: WebSocket SSL is disabled
[INFO] :: HttpWsServer :: Server started on host /0.0.0.0 and port 8099
[DEBUG] :: IdeState :: "Init ProjectorClassLoader" is done
Feb 02, 2023 5:44:14 PM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
Feb 02, 2023 5:44:15 PM java.util.prefs.FileSystemPreferences$6 run
WARNING: Prefs file removed in background /root/.java/.userPrefs/prefs.xml
[DEBUG] :: ProjectorBatchTransformer :: Success (State: IDE_CLASSLOADER_FETCHED): [IjLigaturesDisablerTransformer: (com.intellij.openapi.editor.colors.impl.FontPreferencesImpl), IjBrowserUtilTransformer: (com.intellij.ide.BrowserUtil), IjUiUtilsTransformer: (com.intellij.util.ui.UIUtil), IjRestartDisablerTransformer: (com.intellij.util.Restarter)]
[DEBUG] :: ProjectorBatchTransformer :: Skip (State: IDE_CLASSLOADER_FETCHED): [IjFastNodeCellRendererTransformer: (All classes. Reason: Transformer is not available for provided parameters or environment setup)]
[INFO] :: WsTransportBuilder :: 172.30.32.2 connected.
[INFO] :: ProjectorServer :: 172.30.32.2 disconnected, was connected for 1 s.

The last two lines are logged after I try to open the web UI. Nothing here sticks out to me.

Perhaps it has something to do with me running my HA instance with HTTPS?

ScottG489 commented 1 year ago

I found this which looks really promising: https://youtrack.jetbrains.com/issue/PRJ-887/Reason-Bad-handshake-token-when-opening-a-projector-session-in-a-browser

Unfortunately I wasn't able to get it working. I found the config.ini file in the addon container, but even after deleting the passwords, setting them to empty, or trying to visit the addon URL with the token param specified it didn't work. I suspect the latter would work, but perhaps HA swallows any query params you specify in the URL and they never make it to the projector server?

ScottG489 commented 1 year ago

Ok I got it working with the latter method!

Instead of going to the addon URL like hassio/ingress/abc123_projector-server I went to the like root URL (you can find this in network inspector in your browser dev tools) which is like hassio/ingress/<some long id/hash>/?token=<password in config.ini>.

frosit commented 1 year ago

Hi @ScottG489

Thanks a lot for your in-depth info! I'm responding a bit late as I'm currently in the middle of a career switch, many things changing but it will be over soon.

Yes I know JetBrains gateway, It's great! I like using it with GitPod and have been experimenting with cloud workspaces on the Google cloud using JetBrains gateway, I think this will be the future but on my own cloud dev servers I still use projector. If i remember correctly projector is basically just a wrapper that helps you build the config and fetch the installs etc. But in my case it was already missing some options I needed for my configs so I kinda hacked around it and not use projector that much, mostly for new IDE versions or new installs.

If you want to use the IDE in your browser you also need an SSL connection to be able to copy paste properly etc. and since my projects are often web based I decided to assign subdomains to my projects and provide SSL by using Let's encrypt (certbot). This certbot SSL certificate is also imported in my Projector IDE config and I just run the IDE on a different port but same domain, created a service that looks for the IDE's PID so you can use it as a service etc. For Magento development it's quite nice since those projects use quite some disk space and resources, I can just crank up the specs whenever i need it and downscale when I'm done. I also use this setup in my windows WSL2 environments as WSL is basically some kind of network mount like it is on OSX, only way to beat that performance problem with indexation is to not go outside of the environment, which means running the IDE from within. But, pretty cool. Can work wherever I want, on whatever machine I want and I think JetBrains Gateway is a proper competitor for VSCode. I think in the future setups like these will become the default.

Aside of getting distracted with cool cloud stuff, happy to hear you solved your problem and the info you shared with me is helpful, thanks! I think we can fetch this URL from the supervisor or something using the bashio bash library and use that in our IDE config.

Few questions:

The IntelliJ IDE's don't have the home assistant plugins vscode has, that's a big con for me.

Last, would you be open to help maintain / improve this? By the looks of your Github you know your way with these kind of technologies and share a similar passion.

ScottG489 commented 1 year ago

The IntelliJ IDE's don't have the home assistant plugins vscode has, that's a big con for me.

Yeah same, and I can't think of an easy way around this other than porting the plugin for Intellij. Maybe some day.

I'm also reconsidering this whole workflow slightly. Intellij is fairly heavy, and I'm not sure I want it running on my HA system. I'm thinking of instead running it locally and just connecting via something like sshfs.

To answer your questions in order:

But yeah, when I was using this in the browser it was very slow and not something I'd be able to use regularly. So unfortunately I think I'll be going in the direction of sshfs and running Intellij locally.


Also a slightly unrelated question for you, but do you happen to do any other Home Assistant related development (e.g. integration development)? I'm developing a HA integration in Intellij, but I have a few issues running and debugging things from within Intellij. Unfortunately, VS Code seems to be what's overwhelmingly favored, documented, and supported.

frosit commented 1 year ago

The foremost reason I build this one is because I can, not because I should. VSCode was getting so much popularity while I think IntelliJ is still superior so I wanted to make an example of this alternative. But I also wrote addons that integrated symfony PHP projects in HA which just makes no sense at all but that makes it fun.

I think this type of integration and the IntelliJ IDE's as we know them are indeed too heavy for HA. I think the only reason you want to do this kind of setup is if you can't do otherwise or in my case. I work with Magento projects a lot, indexation is pretty heavy and it fails on filesystem operations because of the large codebase. So with Magento projects, SSHFS is not a good option. You have to run the IDE from the environment to work around indexing issues but if you have smaller projects, SSHFS or other solutions are fine, even better in some cases.

Maybe time to archive this one.

Well, that's pretty cool. I have done a fair amount of custom development in HA, also integrations but it has been a while and most were kept private. But if you are buiding HA integrations for IntelliJ I'm surely open to help out wherever i can. I still do HA development from IntelliJ. I only use vscode for editing yaml files because of the plugin. I think I follow you on twitter, feel free to dm.

ScottG489 commented 1 year ago

Yeah 100% with you that Intellij is superior. Bugs me quite a bit how popular VSCode has gotten because I think it's diluting the IDE market and no one pays attention to other IDEs. I think JetBrains is at least partially to blame cuz they still don't support thing like dev containers.

I'm still not sure I'd say this project is a bad idea. It seemed more like the interface was just sluggish. I know there are also newer offerings like Gateway that could possibly be useful. If the Intellij "engine" could run locally and you could connect to it remotely (which I think is how Gateway works?) then that would be a great option.

Also just to clarify, I'm not currently working on an HA integration for Intellij, I'm just building an unrelated integration using Intellij as my IDE to do so.