public void timeout(NHttpServerConnection conn) {
    ProtocolState state = SourceContext.getState(conn);

    if (state == ProtocolState.REQUEST_READY || state == ProtocolState.RESPONSE_DONE) {
      if (log.isDebugEnabled()) {
        log.debug(conn + ": Keep-Alive connection was time out: " + conn);
      }
    } else if (state == ProtocolState.REQUEST_BODY || state == ProtocolState.REQUEST_HEAD) {

      metrics.incrementTimeoutsReceiving();

      informReaderError(conn);
      log.warn("Connection time out while reading the request: " + conn);
    } else if (state == ProtocolState.RESPONSE_BODY || state == ProtocolState.RESPONSE_HEAD) {
      informWriterError(conn);
      log.warn("Connection time out while writing the response: " + conn);
    } else if (state == ProtocolState.REQUEST_DONE) {
      log.warn("Connection time out after request is read: " + conn);
    }

    SourceContext.updateState(conn, ProtocolState.CLOSED);
    sourceConfiguration.getSourceConnections().shutDownConnection(conn);
  }