eclipse-vertx / vert.x

Vert.x is a tool-kit for building reactive applications on the JVM
http://vertx.io
Other
14.31k stars 2.08k forks source link

vert.x 4.4.9 and above, http server will not receive requests after deployment #5306

Open xddcode opened 2 months ago

xddcode commented 2 months ago

Questions

Do not use this issue tracker to ask questions, instead use one of these channels. Questions will likely be closed without notice.

Version

4.4.9 +

Context

vert.x 4.4.9 and above, http server will not receive requests after deployment

Steps to reproduce

@Slf4j public class HttpDeviceNetwork implements IDeviceNetwork {

private Vertx vertx;

private HttpServer backendServer;

private HttpConfig httpConfig;

private CountDownLatch countDownLatch;

@Override
public void send(String topic, int qos, byte[] content) {

}

@Override
public NetworkType getType() {
    return NetworkType.http;
}

@Override
public void init(NetworkConfig config) {
    try {
        vertx = Vertx.vertx();
        httpConfig = config.getConfig("http", HttpConfig.class);
        backendServer = vertx.createHttpServer();
        log.info("======>>>>>http network init success.");
    } catch (Exception e) {
        log.error("======>>>>>http network init fail.");
    }
}

@Override
public void start() {
    Router router = Router.router(vertx);
    router.route().handler(BodyHandler.create());

    router.get("/test").handler(rc -> {
        log.info("======>>>>>http network request received.");
        HttpServerResponse httpServerResponse = rc.response();
        httpServerResponse.putHeader("content-type", "text/plain");
        httpServerResponse.end("Hello from Thingverse HTTP Server!");
    });

    backendServer.requestHandler(router)
            .listen(httpConfig.getPort(), http -> {
                if (http.succeeded()) {
                    log.info("http server create succeed,port:{}", httpConfig.getPort());
                } else {
                    log.error("http server create failed", http.cause());
                }
            });
}

@Override
public void stop() {
    backendServer.close();
}

}

C:\Users\Administrator>curl -v http://localhost:28888/test

Host localhost:28888 was resolved. IPv6: ::1 IPv4: 127.0.0.1 Trying [::1]:28888... Connected to localhost (::1) port 28888 GET / HTTP/1.1 Host: localhost:28888 User-Agent: curl/8.8.0 Accept: /

Request completely sent off Empty reply from server Closing connection curl: (52) Empty reply from server

Deploy a server instance that starts up with no errors, but just doesn't receive requests.A version 4.4.8 or lower is fine

Extra

tsegismont commented 1 month ago

The release notes are short and I can't see anything other than a Netty upgrade that could be related.

Given Vert.x is embedded into a Spring app in your case, perhaps there's a dependency conflict somewhere?