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

Cannot access web app running on WSL from a Windows-hosted client (browser) #22887

Closed
brunoborges opened this issue Jan 14, 2022 · 27 comments · Fixed by #22956
Closed

Cannot access web app running on WSL from a Windows-hosted client (browser) #22887

brunoborges opened this issue Jan 14, 2022 · 27 comments · Fixed by #22956
Labels
env/windows Impacts Windows machines kind/bug Something isn't working
Milestone

Comments

@brunoborges
Copy link
Contributor

Describe the bug

Open a WSL terminal on Windows.
Create a sample app using the quickstart/archetypes.
Run mvn quarkus:dev.
Try to access the app.

Expected behavior

Be able to see the expected output of the quickstart.

Actual behavior

404

How to Reproduce?

As described.

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@brunoborges brunoborges added the kind/bug Something isn't working label Jan 14, 2022
@quarkus-bot quarkus-bot bot added env/windows Impacts Windows machines triage/needs-triage labels Jan 14, 2022
@geoand
Copy link
Contributor

geoand commented Jan 14, 2022

Thanks for reporting.

@rsvoboda do you have a Windows machine so you can verify this?

@rsvoboda
Copy link
Member

I have Windows VM, but it's without nested virtualization so I can't really check WSL 2 now.

I will ask my wife to borrow me her Windows laptop when she gets home ;)

@geoand
Copy link
Contributor

geoand commented Jan 14, 2022

Thanks!

@rsvoboda
Copy link
Member

Good news, I have managed to boot into Boot Camp based Windows with enabled Virtualization thanks to the trick mentioned in https://superuser.com/questions/717421/how-to-enable-hardware-virtualization-on-a-macbook

In WSL 2 I was able to run Quarkus sample app from code.quarkus in dev mode. Application is not accessible from Windows-hosted browser because the default host is localhost / 127.0.0.1 and wsl acts as fast VM.

Running Maven command with -Dquarkus.http.host=0.0.0.0 solves the trouble and I can access the app from browser.

Capture

@geoand
Copy link
Contributor

geoand commented Jan 14, 2022

Thanks @rsvoboda!

Interesting how this seems to be the opposite of #12246...

@famod
Copy link
Member

famod commented Jan 14, 2022

0.0.0.0 is the way to go when running in a WSL2 distribution, using it myself that way.

The other issue seems to be about running "natively" on Windows, not in WSL2.

@brunoborges
Copy link
Contributor Author

@famod have you tried with this setting as a Maven property in the Pom?

@famod
Copy link
Member

famod commented Jan 14, 2022

@brunoborges we have it in application-dev.yaml. It was a team decision that it's ok for everyone like that, even though only I am using WSL, the others are running on Windows natively.

But you should be able to set it via Maven, too.

@brunoborges
Copy link
Contributor Author

I think I tried to set it via Maven in the pom, and did not see success. That's why I'm asking you to test as well.

Granted, my project was an older Quarkus, that then I manually updated to the latest version. So maybe I missed something.

@famod
Copy link
Member

famod commented Jan 16, 2022

Right, just setting property <quarkus.http.host>0.0.0.0</quarkus.http.host> doesn't work, haven't checked why.

But you can either set property <jvm.args>-Dquarkus.http.host=0.0.0.0</jvm.args> or set <jvmArgs>-Dquarkus.http.host=0.0.0.0</jvmArgs> in the configuration section of the quarkus-maven-plugin.

@brunoborges
Copy link
Contributor Author

Isn't this because the Maven plugin is not passing along Maven properties to Quarkus as system properties?

This sounds like a quite useful enhancement.

@geoand
Copy link
Contributor

geoand commented Jan 17, 2022

Quarkus does read properties from Maven, however it only applies them to build time configuration, i.e. configuration that cannot change at runtime - which is not the case for quarkus.http.host.

@famod
Copy link
Member

famod commented Jan 17, 2022

Ah, right! ⬆️ 👍

So it seems we should close this issue.
Or can we improve something on the documentation side of things?

@geoand
Copy link
Contributor

geoand commented Jan 17, 2022

Or can we improve something on the documentation side of things?

Yeah, I think we can likely improve on that. Or maybe even try to detect if we are running in WSL (not sure that's possible) and display a warning message if quarkus.http.host is set to localhost?

UPDATE:

It seems to be possible to detect if the process is running in WSL, see https://stackoverflow.com/a/61036356/2504224

@famod
Copy link
Member

famod commented Jan 17, 2022

Not sure if a warning is too invasive. Nobody stops you from running a desktop in WSL, with a browser.
So if we choose to log something it should be INFO instead.

But logging is actually better than extending the docs, RTFM you know. 😉

@brunoborges
Copy link
Contributor Author

Isn't it better if you just go with the expected behavior of the developer?

If the setting is in the pom, use it. If it is inside WSL, deploy to 0.0.0.0 by default. Document the default behavior.

@geoand
Copy link
Contributor

geoand commented Jan 18, 2022

#22956 makes Quarkus automatically lister on 0.0.0.0 for WSL environments.
@rsvoboda would you be able to test it please?

Thanks

@famod
Copy link
Member

famod commented Jan 18, 2022

IIRC, a long time ago there was a change to not bind to 0.0.0.0 because of security reasons?
Anyway, I think it's alright to use it by default like that.

@geoand
Copy link
Contributor

geoand commented Jan 18, 2022

Yeah, this is only for WSL

@rsvoboda
Copy link
Member

ok, booting to windows

@rsvoboda
Copy link
Member

PR approved, fresh Quarkus build on Windows machine took ages :/

@geoand
Copy link
Contributor

geoand commented Jan 18, 2022

Thanks!

@famod
Copy link
Member

famod commented Jan 18, 2022

fresh Quarkus build on Windows machine took ages :/

Better build in WSL dist whenever you can.

@quarkus-bot quarkus-bot bot added this to the 2.7 - main milestone Jan 18, 2022
geoand added a commit that referenced this issue Jan 18, 2022
Make Quarkus listen on all interfaces in WSL dev mode
@rsvoboda
Copy link
Member

Better build in WSL dist whenever you can.

I had my Windows machine with almost nothing in .m2/repository/ so the download of artifacts took quite a long time.
And I was building in Windows, but I realized that the local maven repo is different in WSL and I miss 999-SNAPSHOT artifacts :) I got through that using -Dmaven.repo.local=. Yeah, it can be tricky to switch between Windows cmd/powershell and WSL ...

@brunoborges
Copy link
Contributor Author

Any tip on how to configure <quarkus.http.host>0.0.0.0</quarkus.http.host> in the pom.xml? Maybe in the quarkus plugin?

@geoand
Copy link
Contributor

geoand commented Jan 18, 2022

Something like:

            <plugin>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>quarkus-maven-plugin</artifactId>
                <version>${quarkus.platform.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                     <systemProperties>
                        <quarkus.http.host>0.0.0.0</quarkus.http.host>
                     </systemProperties>
               </configuration>
            </plugin>

should work, although I haven't tried it.

If that does not work, let me know and I'll try it out tomorrow

@famod
Copy link
Member

famod commented Jan 18, 2022

Or like I have posted 2 days ago: #22887 (comment)

@gsmet gsmet modified the milestones: 2.7 - main, 2.6.3.Final Jan 18, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
env/windows Impacts Windows machines kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants