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

SDM BindException: Address already in use #9944

Closed
niloc132 opened this issue Mar 29, 2024 · 0 comments · Fixed by #9946
Closed

SDM BindException: Address already in use #9944

niloc132 opened this issue Mar 29, 2024 · 0 comments · Fixed by #9946

Comments

@niloc132
Copy link
Contributor

GWT version: 2.11
Browser (with version): any
Operating System: Linux/Mac (have not tested Windows


Description

The JettyLauncher has a specific flag passed to Jetty to ensure that SO_REUSEADDR is set, but the SDM code server explicitly disables this, for reasons that are unclear to me. This flag allows a port that was recently used and the browser hasn't yet stopped connecting to to be reused by a new process.

Steps to reproduce
  1. Start any GWT sample with SDM, for example ant devmode in the Hello sample
  2. Open a browser and connect, wait for the page to load
  3. Stop SDM, and quickly start it again - as if some class had changed and we needed a new process to replace it.

Expected: SDM starts right away, and a browser can connect
Actual: SDM fails on startup with an error:

     [java] java.io.IOException: Failed to bind to /127.0.0.1:9876
     [java]     at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:349)
     [java]     at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:310)
     [java]     at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
     [java]     at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:234)
     [java]     at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
     [java]     at org.eclipse.jetty.server.Server.doStart(Server.java:401)
     [java]     at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
     [java]     at com.google.gwt.dev.codeserver.WebServer.start(WebServer.java:138)
     [java]     at com.google.gwt.dev.codeserver.CodeServer.start(CodeServer.java:162)
     [java]     at com.google.gwt.dev.codeserver.CodeServer.main(CodeServer.java:104)
     [java]     at com.google.gwt.dev.codeserver.CodeServer.main(CodeServer.java:55)
     [java]     at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
     [java]     at java.base/java.lang.reflect.Method.invoke(Method.java:580)
     [java]     at com.google.gwt.dev.shell.SuperDevListener.runCodeServer(SuperDevListener.java:112)
     [java]     at com.google.gwt.dev.shell.SuperDevListener.start(SuperDevListener.java:91)
     [java]     at com.google.gwt.dev.DevMode.ensureCodeServerListener(DevMode.java:666)
     [java]     at com.google.gwt.dev.DevModeBase.doStartup(DevModeBase.java:785)
     [java]     at com.google.gwt.dev.DevMode.doStartup(DevMode.java:551)
     [java]     at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:888)
     [java]     at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:705)
     [java]     at com.google.gwt.dev.DevMode.main(DevMode.java:432)
     [java] Caused by: java.net.BindException: Address already in use
     [java]     at java.base/sun.nio.ch.Net.bind0(Native Method)
     [java]     at java.base/sun.nio.ch.Net.bind(Net.java:565)
     [java]     at java.base/sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:344)
     [java]     at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:301)
     [java]     at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:89)
     [java]     at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:344)
     [java]     ... 20 more
Known workarounds

Stop the browser, so that it releases its end of the socket connection, which will free up the port, or wait long enough for the connection to time out.

Links to further discussions

See https://stackoverflow.com/a/3233022/860630 for a good summary of what SO_REUSEADDR does, why it makes sense here.

niloc132 added a commit to niloc132/gwt that referenced this issue Mar 29, 2024
This is Jetty's default for a Connector, and is the configuration also
used by the DevMode Jetty app server instance.

Fixes gwtproject#9944
niloc132 added a commit that referenced this issue Mar 29, 2024
This is Jetty's default for a Connector, and reflects the configuration
used by the DevMode Jetty app server instance.

Fixes #9944
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

Successfully merging a pull request may close this issue.

1 participant