{"record":{"id":"cc36096484d8e07e","repo":"XX-net/XX-Net","slug":"send-request-except-r","errorCode":null,"errorMessage":"send_request except:%r","messagePattern":"send_request except:%r","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/smart_router/local/dns_query.py","lineNumber":270,"sourceCode":"                    que.put(ips)\n            except Exception as e:\n                xlog.exception(\"dns recv_worker except:%r\", e)\n\n        xlog.info(\"DNS Client recv worker exit.\")\n        sock.close()\n\n    def send_request(self, id, server_ip, domain, dns_type):\n        try:\n            d = DNSRecord(DNSHeader(id))\n            d.add_question(DNSQuestion(domain, dns_type))\n            req4_pack = d.pack()\n\n            if utils.check_ip_valid4(server_ip):\n                self.sock.sendto(req4_pack, (server_ip, 53))\n            else:\n                self.sock6.sendto(req4_pack, (server_ip, 53))\n        except Exception as e:\n            xlog.warn(\"send_request except:%r\", e)\n\n    def query_by_system(self, domain, dns_type):\n        ips = []\n        try:\n            t0 = time.time()\n            ip = socket.gethostbyname(domain)\n            t1 = time.time()\n            ips.append(ip)\n\n            xlog.debug(\"query_by_system, %s %d cost:%f, return:%s\", domain, dns_type, t1 - t0, ips)\n        except Exception as e:\n            xlog.warn(\"query_by_system %s %d e:%r\", domain, dns_type, e)\n\n        return ips\n\n    def query(self, domain, dns_type=1, timeout=3):\n        if sys.platform == \"ios\":\n            return self.query_by_system(domain, dns_type)","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/smart_router/local/dns_query.py#L252-L288","documentation":"send_request() failed to send a UDP DNS query packet to the upstream server. This is a socket sendto() failure — typically ICMP port unreachable, network unreachable, invalid address family, or the socket not being connected/bound. The query is dropped and the caller's waiter eventually times out.","triggerScenarios":"sendto() to (server_ip, 53) raising because the DNS server IP is unreachable, an IPv6 address being passed to the IPv4 socket (or vice versa), the network interface being down, or a local firewall rejecting outbound UDP 53.","commonSituations":"Firewalled outbound port 53 (common in corporate networks forcing internal DNS), wrong IP family in the DNS config, VPN routing breaking UDP, transient network loss.","solutions":["Check the configured DNS server IPs are valid and reachable for the socket family used (verify with check_ip_valid4 routing in the code)","Test outbound UDP 53: 'dig @8.8.8.8 example.com' from the same host","Open/allow outbound UDP 53 in the local firewall or VPN split-tunnel config","Fall back to TCP/TLS/HTTPS DNS transports (this module's TCP, DoT, DoH query classes) since port 53 UDP is commonly blocked"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-check DNS server reachability before sending: try a cheap UDP probe or keep a health flag per server","Maintain multiple upstream servers and rotate on send failure","In restrictive environments use DoH on 443 instead of UDP 53"],"tags":["dns","udp","sendto","network-unreachable","firewall"],"backgroundTag":"udp-send-failed","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}