Fork me on GitHub
#portal
<
2023-01-23
>
seancorfield20:01:21

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).

seancorfield20:01:53

@U1G869VNV 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...?

djblue20:01:15

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.

djblue20:01:12

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

seancorfield20:01:43

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?

djblue20:01:31

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 :thinking_face:

djblue20:01:36

And restarting the jvm doesn't fix the issue?

seancorfield20:01:58

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

seancorfield20:01:10

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...

djblue20:01:08

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

djblue20:01:31

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

seancorfield20:01:53

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

👍 2
seancorfield20:01:42

Updated Docker and rebooted. Problem is still there 😞

seancorfield20:01:12

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

djblue20:01:24

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

djblue20:01:37

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

djblue20:01:24

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

djblue20:01:04

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

seancorfield20:01:47

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...

seancorfield20:01:41

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")}))

djblue20:01:14

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

djblue01:04:38

@U04V70XH6 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

djblue01:04:46

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

seancorfield02:04:20

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

👍 2
seancorfield23:04:52

Yup! This totally works, thank you!

seancorfield23:04:16

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