I'm testing out the undertow 2.0.0.Alpha1 webserver. When I run it locally it works and returns Hello World
when I go to localhost:80
. I then deploy the webserver on a remote server and go to remote_ip:80
but I get no response back. If I run curl -i -X GET http://localhost:80
on the remote server then I get Hello World
back as well. So the server is definitely running but for some reason it's just not accessible via the remote ip address. If I try to set a hostname as the remote IP in the code (i.e. .addHttpListener(80, "remote.ip")
) then I get a BindException
.
import io.undertow.Undertow;
import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class HelloWorldServer {
public static void main(final String[] args) {
try {
Runtime.getRuntime().exec("sudo fuser -k 80/tcp");
} catch (IOException ex) {
Logger.getLogger(HelloWorldServer.class.getName()).log(Level.SEVERE, null, ex);
}
Undertow server = Undertow.builder()
.addHttpListener(80, null)
.setHandler(new HttpHandler() {
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
exchange.getResponseSender().send("Hello World");
}
}).build();
server.start();
}
}
Any clues?
tcp6 0 0 127.0.0.1:80 :::* LISTEN 2939/java
– Lustrewarelocalhost
is just linked to127.0.0.1
by default on Ubuntu – Lustreware