Hoa Le
Hoa Le

Reputation: 11

http client vertx in unix

I'm getting an issue when running vertx on a Unix server. When full message is received the end handler does not work.

HttpClientRequest request = client.post (8580, "localhost", "/", response -> 
{

  if (response.statusCode () == 200) {
    response.handler (t -> {

        LOG.info ("RECEIVE DATA: " + t.toString ());

    });
    response.endHandler (t -> {
        LOG.info ("endHandler: DONE"); //DO NOT PRINT ON LOG FILE
    });

  } else {
    LOG.info  ("Sent error:"+response.statusMessage ());
  }
});

My source demo: https://github.com/blueskyvn/vertx_client.

Upvotes: 1

Views: 189

Answers (1)

berserkk
berserkk

Reputation: 1007

  1. You should close your HTTP client after request is completed. So, move client.close(); line to the response handler.
  2. Move your entire code for working with HTTP client to the verticle. You can just move it to your HttpVerticle class and call it after server is started. Use listen method with callback.

Upvotes: 1

Related Questions