protected void startEventLoop() {
    Socket sub = connectSubSocket();
    connected = true;

    while (!Thread.currentThread().isInterrupted()) {
      try {
        String e = sub.recvStr();
        String data = sub.recvStr();
        handle(e, data);

        if (anytimeHandler == null && handlers.isEmpty()) {
          break;
        }
      } catch (Exception e) {
        LOGGER.warn("Error handling event. Will close sub socket.", e);

        if (e instanceof ZMQException) {
          LOGGER.error("Will close sub socket.");
          break;
        }
      }
    }
    LOGGER.info("closing subscriber");
    sub.close();
  }