XX-net/XX-Net · warning
add_sock_event %s conn:%d e:%r
Error message
add_sock_event %s conn:%d e:%r
What it means
Registering a connection's socket with the selector (select2.register_event) raised an exception; the connection is then closed as a safety measure. Typically a closed/invalid fd ('EBADF' / 'bad file descriptor') or closed selector.
Source
Thrown at code/default/x_tunnel/local/base_container.py:431
self._debug_log("ConnectionPipe stop")
def _debug_log(self, fmt, *args, **kwargs):
if not self.session or not self.session.config.show_debug:
return
self.xlog.debug(fmt, *args, **kwargs)
def add_sock_event(self, sock, conn, event):
# this function can repeat without through an error.
if not sock:
return
with self._lock:
self._debug_log("add_sock_event conn:%d event:%s", conn.conn_id, event)
try:
self.select2.register_event(sock, event, conn)
except Exception as e:
self.xlog.warn("add_sock_event %s conn:%d e:%r", sock, conn.conn_id, e)
self.close_sock(sock, str(e) + "_when_add_sock_event")
return
# if sys.platform == "win32" and (sock not in self.sock_conn_map or event == selectors.EVENT_WRITE):
# self.notice_select()
self.sock_conn_map[sock] = conn
if not self.th:
self.th = threading.Thread(target=self.pipe_worker, name="x_tunnel_pipe_worker")
self.th.start()
self._debug_log("ConnectionPipe start")
def remove_sock_event(self, sock, event):
# this function can repeat without through an error.
with self._lock:
if sock not in self.sock_conn_map:View on GitHub (pinned to cfa5bc17b6)
Solutions
- Check if the pipe/worker is shutting down before issuing commands
- Ensure sockets are unregistered before closing
- Upgrade/patch race conditions around close_sock and register_event
Defensive patterns
Strategy: try-catch
Validate before calling
if not pipe.running:
return # skip issuing commands while shutting down Try / catch
try:
pipe.add_sock_event(sock, event, conn)
except Exception:
# already handled internally; conn is closed Prevention
- Check running flag before sending commands to a stopping pipe
- Ensure single ownership of socket close/unregister
When it happens
Trigger: add_sock_event called from start, put_cmd_data, process_cmd or send_to_sock after the socket was already closed, or during ConnectionPipe shutdown.
Common situations: Race between socket close and event registration; shutting down the tunnel while data still flows.
Related errors
- ConnectionPipe remove sock e:%r
- unregister %s e:%r
- XTunnelNotRunning
- proxy handler read error %r
- login session server is down, try get new server.
AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27).
Data as JSON: /api/errors/d02fdf50aac027ec.
Report an issue: GitHub.