XX-net/XX-Net · warning

query_over_tcp %s type:%s connect fail.

Error message

query_over_tcp %s type:%s connect fail.

What it means

In the TCP DNS client's query(), get_connection() returned no usable socket, so no query was sent and an empty IP list is returned. This means the previously established connection pool had no live connection and a fresh direct/proxy connect (see direct_connect, error 154) failed.

Source

Thrown at code/default/smart_router/local/dns_query.py:416

                [sock, last_query_time] = self.connections.pop()
                if time.time() - last_query_time < self.connection_timeout:
                    return sock
            except:
                pass

        server_ip = self.get_server()
        if not server_ip:
            return None

        sock = self.connect(server_ip, self.port)
        return sock

    def query(self, domain, dns_type=1):
        t0 = time.time()
        try:
            sock = self.get_connection()
            if not sock:
                xlog.warn("query_over_tcp %s type:%s connect fail.", domain, dns_type)
                return []

            d = DNSRecord(DNSHeader())
            d.add_question(DNSQuestion(domain, dns_type))

            data = d.pack()
            data = struct.pack("!H", len(data)) + data
            sock.sendall(data)

            response = sock.recv(8192)
            if not response:
                return []

            length = struct.unpack("!H", bytes(response[:2]))[0]
            while len(response) - 2 < length:
                response += sock.recv(8192)

            t2 = time.time()

View on GitHub (pinned to cfa5bc17b6)

Solutions

  1. Verify TCP reachability of the DNS server: 'nc -vz 8.8.8.8 53'
  2. Use DoH (port 443) instead of plain TCP DNS in restrictive networks
  3. Check proxy settings if PROXY_ENABLE is on — connect() routes through the proxy in that mode
  4. Retry with backoff; transient connect failures recover and the pool re-establishes
Defensive patterns

Strategy: retry

Try / catch

for attempt in range(2):
    ips = tcp_client.query(domain)
    if ips:
        break
    time.sleep(0.5 * (attempt + 1))

Prevention

When it happens

Trigger: Calling query() on the TCP DNS client when all pooled connections are stale/closed and direct_connect() to the DNS server fails — network down, firewall blocking TCP 53, or proxy mode with PROXY_ENABLE and no working proxy path.

Common situations: Firewalled outbound TCP 53, flaky networks after idle (pooled sockets reset by middleboxes), proxy misconfiguration when PROXY_ENABLE is set.

Related errors


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