code: private void reply(final String response, final boolean error,
              final String errorMessage, final String stackTrace,
              final String statusCode, final int statusCodeInt) {
  
          
          if (!sentReply) {
              
              //must update sentReply first to avoid duplicated msg.
              sentReply = true;
              // Close the connection. Make sure the close operation ends because
              // all I/O operations are asynchronous in Netty.
              if(channel!=null && channel.isOpen())
                  channel.close().awaitUninterruptibly();
              final ResponseOnSingeRequest res = new ResponseOnSingeRequest(
                      response, error, errorMessage, stackTrace, statusCode,
                      statusCodeInt, PcDateUtils.getNowDateTimeStrStandard(), null);
              if (!getContext().system().deadLetters().equals(sender)) {
                  sender.tell(res, getSelf());
              }
              if (getContext() != null) {
                  getContext().stop(getSelf());
              }
          }
  
      }
docs: First close the connection. Then reply.
  
  @param response
  the response
  @param error
  the error
  @param errorMessage
  the error message
  @param stackTrace
  the stack trace
  @param statusCode
  the status code
  @param statusCodeInt
  the status code int