portal

seancorfield 2023-01-23T20:07:21.320789Z

For some reason the Portal VS Code extension has stopped working for me. Windows/WSL2. Portal 0.35.1. The Portal window opens but it is blank. The .portal/vs-code.edn file contains {:host "localhost", :port 43715} but if I look in the developer tools, it looks like Portal is trying to hit this URL http://localhost:34737/main.js?12482da4-365e-4ad4-9a35-7923eefe0092 -- and if I do curl on that in WSL2, it succeeds (and returns a big blob of JS) but the developer tools indicate that is timing out (from the Windows side, presumably -- and a curl in cmd.exe seems to confirm that).

djblue 2023-04-15T01:18:38.820649Z

@seancorfield Just ran into this issue myself and https://superuser.com/questions/1594420/cant-access-127-0-0-180-outside-of-wsl2-ubuntu-20-04 seems to have fixed it for me without needing to specify host, specifically:

Add a file with these contents to C:\Users\Me\.wslconfig:
[wsl2]
localhostForwarding=true

djblue 2023-04-15T01:19:46.676739Z

If you try this and it works, let me know and I'll add the info to the docs 👌

seancorfield 2023-04-15T02:21:20.539349Z

Well take a look over the weekend... Thanks.

👍 1
seancorfield 2023-04-15T23:18:52.883749Z

Yup! This totally works, thank you!

seancorfield 2023-04-15T23:19:16.766799Z

I've removed the hostname shell-out and it all works.

seancorfield 2023-01-23T20:08:53.091909Z

@djblue Any suggestions on how to debug this further? If I do that curl with 43715 on WSL2, it also succeeds (and returns the same blob of JS as far as I can tell) -- so it seems that Portal is running on multiple ports...?

djblue 2023-01-23T20:11:15.092129Z

There are two servers involved, one in the jvm process and another in the vscode process. The vscode.edn contains the server info for the one running in the vscode process.

seancorfield 2023-01-23T20:12:07.106289Z

Ah, ok.

djblue 2023-01-23T20:12:12.917239Z

The 34737 port is the server running in the jvm and the one you want to load the ui from

seancorfield 2023-01-23T20:13:43.968719Z

And that is failing to load for the extension, for some reason. I don't think I've changed anything on my machine -- and this was working just fine on Friday. Although I think Docker updated itself last night so I wonder if it has borked something about WSL2?

djblue 2023-01-23T20:14:31.278969Z

I don't know if http-kit binds to the public interface by default which might be the issue if something related to networking has changed 🤔

djblue 2023-01-23T20:16:36.224409Z

And restarting the jvm doesn't fix the issue?

seancorfield 2023-01-23T20:16:58.196929Z

Nope. I've even rebooted the whole machine and started everything back up.

seancorfield 2023-01-23T20:18:10.834229Z

The Portal extension is installed in WSL2, according to VS Code, so I would have assumed that when it requests the UI, it's doing it on the WSL2 side of things -- and curl succeeds for that...

djblue 2023-01-23T20:24:08.632579Z

I have a similar setup on windows but can't reproduce

djblue 2023-01-23T20:25:31.256579Z

Loading the url in a browser on the windows side also doesn't work, correct?

seancorfield 2023-01-23T20:26:29.586049Z

Correct.

seancorfield 2023-01-23T20:27:53.120429Z

There's an update for Docker Desktop so I'm going to install that and reboot and try again... back in a bit...

👍 1
seancorfield 2023-01-23T20:35:42.161329Z

Updated Docker and rebooted. Problem is still there 😞

seancorfield 2023-01-23T20:36:12.771489Z

Should that URL work in a browser on Windows? (i.e., does it work for you?)

djblue 2023-01-23T20:38:24.835199Z

It does. I wonder if you can not refer to the WSL2 instance via localhost anymore? 🤔

djblue 2023-01-23T20:39:37.414519Z

If you get the ip of the wsl2 machine, you might be able to set it via (portal.api/start {:host "..."})

djblue 2023-01-23T20:40:24.705649Z

For the recent clr work I've done, localhost didn't work and I needed to use ::1 which I think is the ipv6 equivalent

djblue 2023-01-23T20:45:04.282199Z

And it looks like ipv6 addresses have a special syntax to hit in a browser: http://[::1]:<port>/<path>

seancorfield 2023-01-23T20:47:47.253679Z

I can hit the WSL2 IP in a browser... so I'm going to update my Portal-start code to specify the host IP and see if that works...

seancorfield 2023-01-23T20:50:41.007509Z

Yeah, that fixed it. Thanks for the pointers...

(def ^{:doc "Atom for currently selected value."}
                portal
                ((requiring-resolve 'portal.api/open)
                 {:launcher :vs-code
                  :host (-> (sh/sh "hostname" "-I") :out (str/trim))
                  :portal.launcher/window-title (System/getProperty "user.dir")}))

djblue 2023-01-23T20:51:14.275069Z

Awesome! Although it really sucks that you had to do it 😬