XX-net/XX-Net · warning

stopping conn:%d fail:%r

Error message

stopping conn:%d fail:%r

What it means

During session stop, close_all_connection iterates every conn in conn_list and calls conn.stop(reason='system reset'); if an individual connection's stop() raises, the exception is caught per-connection and logged with the conn_id and the exception repr, so one bad connection cannot abort shutting down the rest.

Source

Thrown at code/default/x_tunnel/local/proxy_session.py:510

        self.target_on_roads = \
            min(g.config.concurent_thread_num - g.config.min_on_road, self.target_on_roads + 2)
        self.trigger_more()

        if log:
            xlog.info("Connect to %s:%d conn:%d", host, port, conn_id)
        return conn_id

    # Called by stop
    def close_all_connection(self):
        xlog.info("start close all connection")
        conn_list = dict(self.conn_list)
        for conn_id in conn_list:
            try:
                # xlog.debug("stopping conn:%d", conn_id)
                self.conn_list[conn_id].stop(reason="system reset")
            except Exception as e:
                xlog.warn("stopping conn:%d fail:%r", conn_id, e)
                pass
        # self.conn_list = {}
        xlog.debug("stop all connection finished")

    def remove_conn(self, conn_id):
        try:
            if conn_id in self.conn_list:
                conn = self.conn_list[conn_id]
                # xlog.debug("remove conn:%d %s:%d", conn_id, conn.host, conn.port)
                del self.conn_list[conn_id]
        except Exception as e:
            xlog.warn("remove conn:%d except:%r", conn_id, e)

        if len(self.conn_list) == 0:
            self.target_on_roads = 0

    def send_conn_data(self, conn_id, data):
        if not self.running:

View on GitHub (pinned to cfa5bc17b6)

Solutions

  1. This is handled gracefully — shutdown proceeds; no action needed unless connections leak.
  2. Check the exception repr in the log to identify which stop() path raised and whether connections are actually cleaned up.
  3. If connections leak (fd exhaustion), upgrade x_tunnel / patch the connection stop() to be idempotent.
  4. Avoid triggering stop() concurrently from multiple threads; call session.stop() once.
Defensive patterns

Strategy: try-catch

Try / catch

# per-item catch during mass shutdown
for conn_id in list(session.conn_list):
    try:
        session.conn_list[conn_id].stop(reason='shutdown')
    except Exception as e:
        logger.warning('stop conn %s failed: %r', conn_id, e)

Prevention

When it happens

Trigger: Shutting down / restarting the x-tunnel session while some connection objects are in an inconsistent state (e.g. already-closed socket, error during buffered-write flush in stop()).

Common situations: Restarting the tunnel after network errors; stop racing with a connection whose underlying socket errored concurrently; version upgrades changing connection state fields that stop() expects.

Related errors


AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27). Data as JSON: /api/errors/b5369c05c5ba9fb3. Report an issue: GitHub.