Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasi-Browser: Access exposed ports [Question] #272

Open
pierreavn opened this issue May 9, 2024 · 2 comments
Open

Wasi-Browser: Access exposed ports [Question] #272

pierreavn opened this issue May 9, 2024 · 2 comments
Labels
question Further information is requested

Comments

@pierreavn
Copy link

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!

@ktock
Copy link
Owner

ktock commented May 10, 2024

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

@ktock ktock added the question Further information is requested label May 10, 2024
@ktock
Copy link
Owner

ktock commented May 19, 2024

@pierreavn Is this issue solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants