Wasi-Browser: Access exposed ports [Question]
Thanks again for this great project! I'm trying to convert a web server container into wasm then run it in browser with wasi-browser. The container is exposing an http port, but unfortunately I am not able access it.
I've tried to add ˋEXPOSEˋ rule in Dockerfile, and to use port socket binding and port mapping in c2w-net to host port. Looking for GVisor networking, logs tell that connection is refused.
Do you have any idea or configuration to access exposed port, from c2w-net port mapping or directly from JS?
Thanks!
This looks like VM mac address and/or the one registered to c2w-net don't match.
If you can see the VM's mac address (currently it's assigned a random value), you need to pass that mac address to c2w-net via -mac flag.
Or, you can patch worker.js to simply disable the random assigning of the mac address.
--- a/examples/wasi-browser/htdocs/worker.js
+++ b/examples/wasi-browser/htdocs/worker.js
@@ -18,7 +18,7 @@ onmessage = (msg) => {
resp['arrayBuffer']().then((wasm) => {
if (netParam) {
if (netParam.mode == 'delegate') {
- args = ['arg0', '--net=socket', '--mac', genmac()];
+ args = ['arg0', '--net=socket'];
} else if (netParam.mode == 'browser') {
recvCert().then((cert) => {
var certDir = getCertDir(cert);
@pierreavn Is this issue solved?