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

java.net.BindException on startup can result in spurious log messages #22967

Closed
jamesnetherton opened this issue Jan 18, 2022 · 6 comments · Fixed by #23186
Closed

java.net.BindException on startup can result in spurious log messages #22967

jamesnetherton opened this issue Jan 18, 2022 · 6 comments · Fixed by #23186
Assignees
Labels
area/vertx kind/bug Something isn't working
Milestone

Comments

@jamesnetherton
Copy link
Contributor

Describe the bug

I was playing with some Camel Quarkus code and was wanting to force an error scenario. So I configured a Netty TCP route to listen on port 8000, which I had already bound to something else. The application correctly fails on startup with java.net.BindException. But the accompanying log messages are confusing.

ERROR [io.qua.run.Application] (main) Port 8080 seems to be in use by another process. Quarkus may already be running or the port is used by another application.
WARN  [io.qua.run.Application] (Quarkus Main Thread) Use 'netstat -anop | grep 8080' to identify the process occupying the port.

In this case, port 8080 is not in use by another process.

Expected behavior

The log messages are either not present in this scenario or reference the correct port.

Actual behavior

Log messages are output as described in the bug description.

How to Reproduce?

  1. If you have netcat installed, bind to port 8000.
nc -l -p 8000
  1. Modify quickstart grpc-plain-text-quickstart by adding configuration property quarkus.grpc.server.port=8000.
  2. Then start the application mvn quarkus:dev.

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

2.6.2.Final

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

No response

Additional information

No response

@jamesnetherton jamesnetherton added the kind/bug Something isn't working label Jan 18, 2022
@geoand
Copy link
Contributor

geoand commented Jan 18, 2022

This isn't actually an error, because what Quarkus is reporting is that the conflict on the HTTP "server"

@geoand geoand closed this as completed Jan 18, 2022
@geoand geoand added the triage/invalid This doesn't seem right label Jan 18, 2022
@jamesnetherton
Copy link
Contributor Author

This isn't actually an error, because what Quarkus is reporting is that the conflict on the HTTP "server"

If the error message states Port 8080 seems to be in use by another process when it clearly isn't. How is that not incorrect / misleading?

@geoand
Copy link
Contributor

geoand commented Jan 18, 2022

I thought you were starting Quarkus for both processes. Now I read the description more carefully.
Indeed the warning is misleading.

@geoand geoand reopened this Jan 18, 2022
@quarkus-bot quarkus-bot bot removed the triage/invalid This doesn't seem right label Jan 18, 2022
@famod
Copy link
Member

famod commented Jan 19, 2022

@geoand I think in VertxHttpRecorder.doServerStart() we should throw a custom BindException which contains the exact info which port (and which property) is affected and remove all that guesswork from ApplicationLifecycleManager.
WDYT? I could add it to my list.

@geoand
Copy link
Contributor

geoand commented Jan 20, 2022

Yeah, absolutely. BindException should contain the port, so we should definitely use it

@geoand geoand self-assigned this Jan 25, 2022
geoand added a commit to geoand/quarkus that referenced this issue Jan 25, 2022
This exception is used to record the actual ports that
cause binding conflicts, thus allowing Quarkus to properly
inform the user of which port(s) caused conflicts
instead of guessing based on what the provided configuration.

Fixes: quarkusio#22967
@geoand
Copy link
Contributor

geoand commented Jan 25, 2022

#23186 takes care of the issue

geoand added a commit that referenced this issue Jan 25, 2022
Introduce QuarkusBindException
@quarkus-bot quarkus-bot bot added this to the 2.8 - main milestone Jan 25, 2022
@gsmet gsmet modified the milestones: 2.8 - main, 2.7.1.Final Jan 31, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jan 31, 2022
This exception is used to record the actual ports that
cause binding conflicts, thus allowing Quarkus to properly
inform the user of which port(s) caused conflicts
instead of guessing based on what the provided configuration.

Fixes: quarkusio#22967
(cherry picked from commit b4ad06c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vertx kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants