So first thing is to add a portproxy because WSL2 use a virtualized ethernet adapter. If I use the ‘ip addr’ from my ubuntu as connectaddress it does not work, it works only if I use 127.0.0.1:
netsh interface portproxy add v4tov4 listenport=4943 listenaddress=0.0.0.0 connectport=4943 connectaddress=({$ ip addr} from ubuntu)
->does not work
netsh interface portproxy add v4tov4 listenport=4943 listenaddress=0.0.0.0 connectport=4943 connectaddress=127.0.0.1
->works
And I need to run this after I started dfx. Also if I ever stop dfx, I need to remove the portproxy and add it again once dfx is start, otherwise it doesn’t work. It’s a bit annoying.
Now when I access the frontend canister from my phone, it displays correctly, but when I click on the button to trigger the “hello, input!” nothing happens.
Also (on my phone again) when I try to access the backend canister via Candid interface I have the error:
An error happened in Candid canister:
Error: Invalid certificate: Signature verification failed
at http://192.168.2.22:4943/index.js:2:98494
at async Promise.all (index 0)
at async Module.UA (http://192.168.2.22:4943/index.js:2:98732)
at async getDidJsFromMetadata (http://192.168.2.22:4943/index.js:2:266509)
at async Object.fetchActor (http://192.168.2.22:4943/index.js:2:265150)
at async http://192.168.2.22:4943/index.js:2:275457
Any help would be greatly appreciated!
Hi sardariuss.
I remember I had issues with my WSL2 and outbound connections.
In my case it wasn’t the same error you posted, but if nothing else is working, you could give it a try:
This is what I’ve done to make the networking work (i found this somewere):
From the terminal of the WSL:
- Sudo nano /etc/resolv.conf
- Remove line out the nameserver nameserver 17…
- add this new line :
nameserver 8.8.8.8
- ctrl + o and ctrl + x to write a quit
- Sudo nano /etc/wsl.conf
- Paste the following in:
[network]
generateResolvConf = false
- ctrl + o and ctrl + x to write a quit
- Close WSL and reopen it.
I remember defining the netsh rule didn’t help me back then.
I hope this helps!
Hi @juanpablodr,
Thanks for your answer. I gave it a try but unfortunatly the page doesn’t load and gives me an ERR_CONNECTION_REFUSED. Do you remember if you had to add anything custom inside your dfx.json maybe ?
mm, i did the same try ( accessing from my phone to my pc local canister ).
I tested it with a front-end only page ( i dont have right now a quieck project with a canister with back-end to test ).
Apart from the config in the WSL, i had to add this rule in the host PC:
netsh interface portproxy add v4tov4 listenport=4943 connectaddress=127.0.0.1 connectport=4943 listenaddress={YOUR IP}
Where YOUR IP i think would be 192.168.2.22.
I hope this works now
I forgot to mention that the URL I used was
http://{YOUR IP}:4943/?canisterId={FRONT END CANISTER ID}
Nope, if I use my PC IP instead of 0.0.0.0 as the listenaddress it doesn’t work.
If I use 0.0.0.0 the front-end loads on the phone, but the interactions don’t work.
Thanks for the help though!
I found an old practice project with front and backend.
You could check the following:
-Do you have a “devServer” entry in your webpack.config.js ?
What is the value of “target” ? In my case it’s → target: “http://127.0.0.1:4943”,
-Make sure you don’t specify a “networks” property in the dfx.json (i think is deprecated).
-The front-end url is in my case http://localhost:8080/
-I had some weird errors that where solved by deleting the “local” canisters ID in the canister_ids.json. They should be regenerated when you deploy again locally.
1 Like
-Do you have a “devServer” entry in your webpack.config.js ?
What is the value of “target” ? In my case it’s → target: “http://127.0.0.1:4943”,
Yes, same value for me.
-Make sure you don’t specify a “networks” property in the dfx.json (i think is deprecated).
Yeah I used to have some at some point, but not anymore. The hello world example has none.
-The front-end url is in my case http://localhost:8080/
I think I already tried to switch port, I could try again. But should it really matter ? I have to add an exception to my firewall for the port I’m using anyway I guess. Gonna try with 8080.
-I had some weird errors that where solved by deleting the “local” canisters ID in the canister_ids.json.
OK, I could give it a try too.