{"record":{"id":"2e68974fa1021343","repo":"v2rayA/v2rayA","slug":"dns-upstream-exchange-raw-tcp-fallback-w","errorCode":null,"errorMessage":"dns upstream: exchange raw tcp fallback: %w","messagePattern":"dns upstream: exchange raw tcp fallback: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/dns/upstream_stub.go","lineNumber":528,"sourceCode":"\t\tprotocol = \"udp\"\n\t}\n\n\tclient := m.getClientForProtocol(upstream, protocol)\n\n\tresp, rtt, err := client.Exchange(msg, upstream.Addr)\n\tif err != nil {\n\t\treturn nil, rtt, fmt.Errorf(\"dns upstream: exchange raw: %w\", err)\n\t}\n\n\t// Handle UDP truncation → TCP fallback.\n\tif resp != nil && resp.Truncated && protocol == \"udp\" {\n\t\tlog.Printf(\"[dns upstream] truncated raw response, falling back to TCP: %s\",\n\t\t\tupstream.Addr)\n\n\t\ttcpClient := m.getClientForProtocol(upstream, \"tcp\")\n\t\tresp, rtt, err = tcpClient.Exchange(msg, upstream.Addr)\n\t\tif err != nil {\n\t\t\treturn nil, rtt, fmt.Errorf(\"dns upstream: exchange raw tcp fallback: %w\", err)\n\t\t}\n\t}\n\n\treturn resp, rtt, nil\n}\n\n// exchangeViaDispatcher sends a DNS query through xray-core's internal routing\n// dispatcher. It uses the RouteDispatcher to create a connection through\n// xray-core's routing engine (like xray-core's traditional DNS module does),\n// then performs DNS-over-TCP on that connection.\n//\n// This replaces the external SOCKS5 proxy approach with v2raya-core's built-in\n// routing logic, supporting any outbound type (VMESS, VLESS, Trojan, etc.).\nfunc (m *UpstreamManager) exchangeViaDispatcher(upstream *UpstreamInstance, query *DnsQuery) (*DnsResponse, error) {\n\tif upstream == nil || m.dispatcher == nil {\n\t\treturn nil, nil\n\t}\n","sourceCodeStart":510,"sourceCodeEnd":546,"githubUrl":"https://github.com/v2rayA/v2rayA/blob/71e5442fc548c05680ee55eae943e6c0afe9ac51/core/dns/upstream_stub.go#L510-L546","documentation":"Raised in ExchangeRaw when the primary UDP response had the TC (truncated) bit set and the retry over TCP (via a tcp-protocol client) also failed: the full DNS answer could not be retrieved from the upstream after the standard UDP-to-TCP fallback.","triggerScenarios":"Thrown at core/dns/upstream_stub.go:528 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check whether TCP/53 to the upstream is blocked","Try a different upstream server","Verify overall network connectivity"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"71e5442fc548c05680ee55eae943e6c0afe9ac51","analyzedAt":"2026-09-05T20:04:37.459Z","contentChangedAt":"2026-09-05T20:04:37.459Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}