Title: SimpleResolver: UDP response larger than the EDNS buffer fails with WireParseException instead of falling back to TCP · Issue #418 · dnsjava/dnsjava · GitHub
Open Graph Title: SimpleResolver: UDP response larger than the EDNS buffer fails with WireParseException instead of falling back to TCP · Issue #418 · dnsjava/dnsjava
X Title: SimpleResolver: UDP response larger than the EDNS buffer fails with WireParseException instead of falling back to TCP · Issue #418 · dnsjava/dnsjava
Description: Summary When a UDP response is larger than the EDNS payload size the query advertised, SimpleResolver fails with WireParseException ("end of input" / "truncated record"). It does not retry over TCP. From the caller's point of view the lo...
Open Graph Description: Summary When a UDP response is larger than the EDNS payload size the query advertised, SimpleResolver fails with WireParseException ("end of input" / "truncated record"). It does not retry over TCP...
X Description: Summary When a UDP response is larger than the EDNS payload size the query advertised, SimpleResolver fails with WireParseException ("end of input" / "truncated record"). It doe...
Opengraph URL: https://github.com/dnsjava/dnsjava/issues/418
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SimpleResolver: UDP response larger than the EDNS buffer fails with WireParseException instead of falling back to TCP","articleBody":"### Summary\n\nWhen a UDP response is larger than the EDNS payload size the query advertised, `SimpleResolver` fails with `WireParseException` (\"end of input\" / \"truncated record\"). It does not retry over TCP. From the caller's point of view the lookup just fails (`Lookup.getResult() == TRY_AGAIN`, `getErrorString() == \"network error\"`), even though the same query over TCP would succeed.\n\nThis can happen with a recursive resolver that appears to return UDP responses larger than the requester's advertised payload size. A resolver that does this isn't RFC 6891-compliant. Even so, dnsjava turns it into a hard failure, and the caller can't do anything about it because it never sees the raw bytes.\n\n### Versions\n\n- dnsjava 3.6.3 (reproduced)\n- The same code paths are unchanged on current `master`\n\n### What happens\n\n1. `SimpleResolver` sends the query over UDP with the default EDNS payload size (1280).\n2. `NioUdpClient.Transaction.processReadyKey()` reads into `ByteBuffer.allocate(max)`, where `max` is that payload size. `DatagramChannel.read()` silently discards the part of the datagram that doesn't fit.\n3. `SimpleResolver.sendAsync()` parses the cut-off bytes before it checks `Flags.TC`. Parsing throws `WireParseException`, so the existing \"Got truncated response ..., retrying via TCP\" path is never reached.\n4. `Lookup` maps the `IOException` to `TRY_AGAIN` / \"network error\".\n\nThe TC-based retry doesn't help here because the TC bit is never evaluated. A resolver that sends the full response over UDP typically doesn't set TC anyway.\n\n### Reproduction\n\nA UDP-only stub that answers any query with ~2.7 KB of TXT records, ignores the EDNS payload size, and never sets TC:\n\n```python\n# oversized_stub.py\nimport socket, struct\ns = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\ns.bind((\"127.0.0.1\", 15353))\nwhile True:\n q, addr = s.recvfrom(4096)\n i = 12\n while q[i] != 0:\n i += q[i] + 1\n question = q[12:i + 5]\n answers = b\"\"\n for n in range(24):\n txt = (\"record-%02d=\" % n + \"x\" * 90).encode()\n rdata = bytes([len(txt)]) + txt\n answers += b\"\\xc0\\x0c\" + struct.pack(\">HHIH\", 16, 1, 60, len(rdata)) + rdata\n header = q[0:2] + b\"\\x81\\x80\" + struct.pack(\">HHHH\", 1, 24, 0, 0) # QR RD RA, no TC\n s.sendto(header + question + answers, addr)\n```\n\n```java\n// Repro.java\nimport org.xbill.DNS.*;\n\npublic class Repro {\n public static void main(String[] args) throws Exception {\n SimpleResolver resolver = new SimpleResolver(\"127.0.0.1\");\n resolver.setPort(15353);\n Message query = Message.newQuery(\n org.xbill.DNS.Record.newRecord(Name.fromString(\"example.com.\"), Type.TXT, DClass.IN));\n try {\n System.out.println(\"answers=\" + resolver.send(query).getSection(Section.ANSWER).size());\n } catch (Exception e) {\n System.out.println(e.getClass().getName() + \": \" + e.getMessage());\n }\n }\n}\n```\n\n`dig +bufsize=4096 -p 15353 @127.0.0.1 example.com TXT` shows the stub's full response (`ANSWER: 24`, `MSG SIZE rcvd: 2741`, no `tc` flag).\n\nOutput with dnsjava 3.6.3 (`org.xbill.DNS.SimpleResolver` at DEBUG):\n\n```\nDEBUG SimpleResolver - Sending example.com./TXT, id=22819 to udp/127.0.0.1:15353\norg.xbill.DNS.WireParseException: end of input\n```\n\nThere is no \"retrying via TCP\" line. Through `Lookup`, the result is `records=null result=2 error=network error`.\n\nDepending on where the cut falls, the exception can also be `WireParseException: truncated record`.\n\n### Expected\n\nA UDP response that didn't fit in the receive buffer should be handled like a truncated response and retried over TCP, the same as a response with TC set. The retry should respect `ignoreTruncation`.\n\n### Related\n\n#240 reported the same exception, but from application code parsing a received message itself. In this case the cut-off happens inside dnsjava's own UDP client, so the caller has no way to detect or handle it.\n","author":{"url":"https://github.com/pssamudr","@type":"Person","name":"pssamudr"},"datePublished":"2026-09-30T20:58:35Z","url":"https://github.com/dnsjava/dnsjava/issues/418"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7cd618c6-4462-8ff4-26bf-2e0e0ab2c106 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8F50:118E6F:4DDAD2:69E6D8:6B060746 |
| html-safe-nonce | dffc8150ecdd31a64735d980fc94cfe695116e76ba01bd25ad6957ff210a7fdf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RjUwOjExOEU2Rjo0RERBRDI6NjlFNkQ4OjZCMDYwNzQ2IiwidmlzaXRvcl9pZCI6IjgwMTA3NDA1NzE1NDk1OTk1NTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 79b1ae2ee8d29f9edf0febbf5958f0325da4047c2cae2cfd2f557141f0062e1c |
| hovercard-subject-tag | issue:5652948219 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/dnsjava/dnsjava/418/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cc275acfe10ca52e07700c4eb5eeb27c709c0eb591a956b3d8eada913f247b1f/dnsjava/dnsjava/issues/418 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cc275acfe10ca52e07700c4eb5eeb27c709c0eb591a956b3d8eada913f247b1f/dnsjava/dnsjava/issues/418 |
| og:image:alt | Summary When a UDP response is larger than the EDNS payload size the query advertised, SimpleResolver fails with WireParseException ("end of input" / "truncated record"). It does not retry over TCP... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pssamudr |
| hostname | github.com |
| expected-hostname | github.com |
| None | 47127d2f2009e000f3401193f8b4163109ac669adad0804de1ee0e6333ca7b9e |
| turbo-cache-control | no-preview |
| go-import | github.com/dnsjava/dnsjava git https://github.com/dnsjava/dnsjava.git |
| octolytics-dimension-user_id | 6755615 |
| octolytics-dimension-user_login | dnsjava |
| octolytics-dimension-repository_id | 17084567 |
| octolytics-dimension-repository_nwo | dnsjava/dnsjava |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 17084567 |
| octolytics-dimension-repository_network_root_nwo | dnsjava/dnsjava |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0760ea46a027ba5099cdef7abd54f27865eb4f44 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width