-
Notifications
You must be signed in to change notification settings - Fork 40
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
fix: Port already bound Error #56
Conversation
@jdegoes I have a similar experience working on a port already bound issue with the Kubernetes organization. I have implemented the retry mechanism to allocate port as same as what I have done in Kubernetes to ensure port bound error doesn't exist anymore :) It's ready for your review |
@jdegoes Have a look at this PR |
@jdegoes Could you take a time to review this PR? |
@jdegoes A gentle reminder to have a look on it 😄 |
@jdegoes PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR doesn't resolve the issue mentioned! Please open the PR whenever it is resolved!
sbt:zio-quickstart-restful-webservice> run
[info] running dev.zio.quickstart.MainApp
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
timestamp=2024-08-16T15:43:51.288677Z level=ERROR thread=#zio-fiber-1 message="" cause="Exception in thread "zio-fiber-10,6,4" io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use
at dev.zio.quickstart.MainApp.run(MainApp.scala:16)"
[error] Exception in thread "zio-fiber-10,6,4" io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use
[error] at dev.zio.quickstart.MainApp.run(MainApp.scala:16)
[error] at dev.zio.quickstart.MainApp.run(MainApp.scala:16)
[error] Caused by: io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use
[error] stack trace is suppressed; run last Compile / run for the full output
[error] (Compile / run) Exception in thread "zio-fiber-10,6,4" io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use
[error] at dev.zio.quickstart.MainApp.run(MainApp.scala:16)
[error] Total time: 3 s, completed Aug 16, 2024, 7:13:51 PM
sbt:zio-quickstart-restful-webservice> run
[info] running dev.zio.quickstart.MainApp
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
timestamp=2024-08-16T15:44:09.636552Z level=ERROR thread=#zio-fiber-1 message="" cause="Exception in thread "zio-fiber-10,6,4" io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use
at dev.zio.quickstart.MainApp.run(MainApp.scala:16)"
[error] Exception in thread "zio-fiber-10,6,4" io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use
[error] at dev.zio.quickstart.MainApp.run(MainApp.scala:16)
[error] at dev.zio.quickstart.MainApp.run(MainApp.scala:16)
[error] Caused by: io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use
[error] stack trace is suppressed; run last Compile / run for the full output
[error] (Compile / run) Exception in thread "zio-fiber-10,6,4" io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use
[error] at dev.zio.quickstart.MainApp.run(MainApp.scala:16)
[error] Total time: 3 s, completed Aug 16, 2024, 7:14:09 PM
sbt:zio-quickstart-restful-webservice>
@khajavi Have you tried with updated cmds in README.md? sbt-resolver plugin is used for this |
@varshith257 |
It is the library suggested by @guizmaii which works good for this Port bind error. Or else my previous approach of retry logic |
@varshith257 |
Ok, I will add docs for it in a note for Zio-quickstarts in Zio.dev for this problem. I also mention how to configure this plugin instead the updation of here |
@varshith257 |
What about port retry logic? |
How does that logic resolve this issue? Will it handle the ctrl+c signal and release the acquired port? |
Yes, it will check for that porr if is already occupied it checks for another free port. So that there is no choice that Port bind error occurs |
The reason the user can't bind to that port is that on the last run, the port was not successfully released. So, you need to release it instead of choosing another port. |
@khajavi Here we go! Check out this PR, the solution releases port and no changes to any cmds |
@khajavi, I disagree with you here. We need to improve the current examples by introducing sbt-revolver.
Well, that means that updating the doc for part of this work. But we should not introduce dedicated code to do this release like done here #57
Yes, it does solve the issue because sbt-revolver solves the issue by introducing the Finally, sbt-revolver is part of the zio-http doc and should be used instead of |
I am in the situation of two reviewers different perspectives 😅 Both have valid reasons. Yes, but if example semantics doesn't need to change as well as the newbie who starts zio with quickstarts can feel it overwhelmed with what's happening with this diff lines of codes rather than being intended with perspective of showing him about Zio concepts. For this i agree with @guizmaii
For this i agree with @khajavi |
How about adding sbt-revolver plugin to quickstarts and add the single line in docs of quickstarts under a note to redirect here for port binding errors |
@guizmaii Overall, I understand and acknowledge your comments. Let me elaborate:
That was the concern about maintaining uniform material across documents and quickstart source codes, but not enforcing how to do that. As I mentioned, I'm not opposed to the
Makes sense and I agree
I mentioned that it's not fixed because the reported issue is expected when using |
@guizmaii What do you think ? Lets go with |
@varshith257 Yes and part of your work here is to update the documentation too |
@khajavi Thanks for your detailed answer :) |
fixes zio/zio-http#2776
/claim zio/zio-http#2776
Here's the working demonstration:
https://www.loom.com/share/8a39b9440e4341ceb1137f3ea8ab6f2d?sid=84c7ed14-8e7a-4aca-98cc-be593198e939