{"record":{"id":"abd17be0e95ad414","repo":"XX-net/XX-Net","slug":"proxy-handler-read-error-r","errorCode":null,"errorMessage":"proxy handler read error %r","messagePattern":"proxy handler read error %r","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"code/default/x_tunnel/local/proxy_handler.py","lineNumber":65,"sourceCode":"            socks_version = self.read_bytes(1)\n            if not socks_version:\n                return\n\n            if socks_version == b\"\\x04\":\n                self.socks4_handler()\n            elif socks_version == b\"\\x05\":\n                self.socks5_handler()\n            elif socks_version == b\"C\":\n                self.https_handler()\n            elif socks_version in [b\"G\", b\"P\", b\"D\", b\"O\", b\"H\", b\"T\"]:\n                self.http_handler(socks_version)\n                return\n            else:\n                xlog.warn(\"socks version:%s not supported\",  utils.str2hex(socks_version))\n                return\n\n        except socket.error as e:\n            xlog.warn('proxy handler read error %r', e)\n            self.connection.close()\n        except Exception as e:\n            xlog.exception(\"proxy handler err:%r\", e)\n            self.connection.close()\n\n    def read_null_end_line(self):\n        sock = self.connection\n        sock.setblocking(0)\n        try:\n            while True:\n                n1 = self.read_buffer.find(b\"\\x00\", self.buffer_start)\n                if n1 > -1:\n                    line = self.read_buffer[self.buffer_start:n1]\n                    self.buffer_start = n1 + 1\n                    return line\n\n                try:\n                    data = sock.recv(8192)","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/x_tunnel/local/proxy_handler.py#L47-L83","documentation":"The X-Tunnel local proxy's handle() hit a socket.error while reading the initial SOCKS handshake bytes from the client. The connection is closed after logging. Commonly this is ECONNRESET/ECONNABORTED when the client drops the connection before completing the handshake.","triggerScenarios":"Client connects to the X-Tunnel local proxy port then disconnects immediately (port scan, health check, browser preconnect abandoned), or the underlying socket errors mid-read of the version/method bytes.","commonSituations":"Port scanners and health checkers probing the proxy port, flaky client networks, clients that close sockets aggressively.","solutions":["Generally ignorable — it indicates the client side dropped the connection","Filter the log or lower verbosity if noisy","If frequent from real clients, check for middleboxes/NAT resetting the local connections"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    handler.handle()\nexcept socket.error as e:\n    log_debug('client dropped: %r', e)  # expected from probes","preventionTips":["Treat early client disconnects as normal; log at debug level","Keep scanners/health checks away from the SOCKS port"],"tags":["socket-error","connection-reset","x-tunnel","socks"],"backgroundTag":"connection-reset-by-peer","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}