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

Enable samples to work with ipv4 #146

Closed
dsyer opened this issue Jun 1, 2022 · 3 comments
Closed

Enable samples to work with ipv4 #146

dsyer opened this issue Jun 1, 2022 · 3 comments

Comments

@dsyer
Copy link
Contributor

dsyer commented Jun 1, 2022

Out of the box without ipv6 enabled:

$ bazel run samples/wasm/src/main/java/com/google/j2cl/samples/wasm:jsapp_dev_server
...
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
Jun 01, 2022 9:34:45 AM io.bazel.rules.closure.webfiles.server.WebfilesServer run
SEVERE: Webfiles server died
java.net.SocketException: Protocol family unavailable
        at java.base/java.net.PlainSocketImpl.socketBind(Native Method)
        at java.base/java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:436)
        at java.base/java.net.ServerSocket.bind(ServerSocket.java:395)
        at java.base/java.net.ServerSocket.<init>(ServerSocket.java:257)
        at java.base/javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:231)
        at io.bazel.rules.closure.webfiles.server.NetworkUtils.createServerSocket(NetworkUtils.java:51)
        at io.bazel.rules.closure.webfiles.server.WebfilesServer.runForever(WebfilesServer.java:137)
        at io.bazel.rules.closure.webfiles.server.WebfilesServer.run(WebfilesServer.java:125)
        at io.bazel.rules.closure.webfiles.server.WebfilesServer.main(WebfilesServer.java:76)

It works if you enable ipv6, but that's a huge pain for a lot of users. The Docker daemon does not enable ipv6 by default so if you want to build in a container you can't, without doing some manual configuration. It would be easier if it just worked.

@gkdn
Copy link
Member

gkdn commented Jun 3, 2022

I think this is happening at JVM level. Can you configure Java environment instead of enabling IPV6 in Docker daemon?

I mostly clueless on Docker containers but found following online:

ENV JAVA_OPTS="-Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true"

@dsyer
Copy link
Contributor Author

dsyer commented Jun 3, 2022

I think you mean JAVA_TOOL_OPTIONS? Anyway it doesn't work even though you can see it being logged as in use:

$ bazel run samples/wasm/src/main/java/com/google/j2cl/samples/wasm:jsapp_dev_server
INFO: Analyzed target //samples/wasm/src/main/java/com/google/j2cl/samples/wasm:jsapp_dev_server (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //samples/wasm/src/main/java/com/google/j2cl/samples/wasm:jsapp_dev_server up-to-date:
  bazel-bin/samples/wasm/src/main/java/com/google/j2cl/samples/wasm/jsapp_dev_server
  bazel-bin/samples/wasm/src/main/java/com/google/j2cl/samples/wasm/jsapp_dev_server.ignoreme
INFO: Elapsed time: 0.803s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
Picked up JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true
Jun 03, 2022 9:25:46 AM io.bazel.rules.closure.webfiles.server.WebfilesServer run
SEVERE: Webfiles server died
java.net.SocketException: Protocol family unavailable
        at java.base/java.net.PlainSocketImpl.socketBind(Native Method)
        at java.base/java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:436)
        at java.base/java.net.ServerSocket.bind(ServerSocket.java:395)
        at java.base/java.net.ServerSocket.<init>(ServerSocket.java:257)
        at java.base/javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:231)
        at io.bazel.rules.closure.webfiles.server.NetworkUtils.createServerSocket(NetworkUtils.java:51)
        at io.bazel.rules.closure.webfiles.server.WebfilesServer.runForever(WebfilesServer.java:137)
        at io.bazel.rules.closure.webfiles.server.WebfilesServer.run(WebfilesServer.java:125)
        at io.bazel.rules.closure.webfiles.server.WebfilesServer.main(WebfilesServer.java:76)

@gkdn
Copy link
Member

gkdn commented Jun 7, 2022

I am guessing this is not fixed with the flag since the default address is still IPV6:
https://github.com/bazelbuild/rules_closure/blob/03e1d4111227f88402da409e2b69a4ada5953550/closure/webfiles/web_library.bzl#L131

You may need both to fix this. I will check if I can change the default address.

@gkdn gkdn closed this as completed Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants