vertx-mqtt icon indicating copy to clipboard operation
vertx-mqtt copied to clipboard

exceptionHandler not used for lower level exceptions

Open codepitbull opened this issue 7 years ago • 1 comments

I am running into the following issue: I am using the following simple MQTT-Verticle

public class MqttVerticle extends AbstractVerticle{
  @Override
  public void start() throws Exception {
    Integer port = config().getInteger("mqttPort");

    System.out.println("STARTING "+port);
    MqttServer server = MqttServer.create(vertx);
    server.exceptionHandler(e -> {
      System.out.println("SERVER EXCEPTION " + port);
    });

    server.endpointHandler(endpoint -> {
      endpoint.exceptionHandler(e -> {
        System.out.println("ENDPOINT EXCEPTION "+e.toString());
      });
    });
    server.listen(port);
  }
}

I want to loadbalance using haproxy and I use the TCP-check for that. This causes logging of tons of java.io.IOException: Connection reset by peer.

None of the above exceptionHandlers is ever hit and the logs are caused by this block in ConnectionBase:

protected synchronized void handleException(Throwable t) {
    this.metrics().exceptionOccurred(this.metric(), this.remoteAddress(), t);
    if(this.exceptionHandler != null) {
      this.exceptionHandler.handle(t);
    } else {
      log.error(t);
    }

  }

My bet would be that we need to add exceptionHandler(rejectHandler); in MqttConnection.init.

codepitbull avatar Jun 19 '17 19:06 codepitbull