{"record":{"id":"47b34821f8be41ae","repo":"XX-net/XX-Net","slug":"https-r-connect-to-s-d-conn-d-closed","errorCode":null,"errorMessage":"https %r connect to %s:%d conn:%d closed.","messagePattern":"https %r connect to (.+?):(.+?) conn:(.+?) closed\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/x_tunnel/local/proxy_handler.py","lineNumber":325,"sourceCode":"\n        host, _, port = path.rpartition(':')\n        host = host.encode()\n        port = int(port)\n\n        header_block = self.read_headers()\n\n        sock = self.connection\n        conn_id = proxy_session.create_conn(sock, host, port)\n        if not conn_id:\n            xlog.warn(\"https create conn to %s:%d fail\", host, port)\n            sock.send(b'HTTP/1.1 500 Fail\\r\\n\\r\\n')\n            return\n\n        xlog.info(\"https %r connect to %s:%d conn:%d\", self.client_address, host, port, conn_id)\n        try:\n            sock.send(b'HTTP/1.1 200 OK\\r\\n\\r\\n')\n        except:\n            xlog.warn(\"https %r connect to %s:%d conn:%d closed.\", self.client_address, host, port, conn_id)\n\n        if (len(self.read_buffer) - self.buffer_start) > 0:\n            g.session.conn_list[conn_id].transfer_received_data(self.read_buffer[self.buffer_start:])\n\n        g.session.conn_list[conn_id].start(block=True)\n\n    def http_handler(self, first_char):\n        req_line = self.read_crlf_line()\n        words = req_line.split()\n        if len(words) == 3:\n            method, url, http_version = words\n        elif len(words) == 2:\n            method, url = words\n            http_version = b\"HTTP/1.1\"\n        else:\n            xlog.warn(\"http req line fail:%s\", req_line)\n            return\n","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/x_tunnel/local/proxy_handler.py#L307-L343","documentation":"After a successful CONNECT and tunnel creation, sending 'HTTP/1.1 200 OK' back to the client failed (client closed/reset). The bare except logs this and the tunnel data flow continues/terminates accordingly.","triggerScenarios":"Client aborts the CONNECT between request and reply (timeout, cancel, tab close).","commonSituations":"Short client timeouts, cancelled navigations, flaky local connections.","solutions":["Benign in most cases; increase client connect timeout if frequent","Ensure local firewall/AV isn't killing the socket"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    sock.send(b'HTTP/1.1 200 OK\\r\\n\\r\\n')\nexcept OSError:\n    pass  # client went away; tunnel cleaned up","preventionTips":["Tune client timeouts; treat as benign"],"tags":["x-tunnel","http-proxy","client-disconnect"],"backgroundTag":"client-closed-connection","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}