{"record":{"id":"d76472a7af475822","repo":"eclipse-vertx/vert.x","slug":"408-request-timeout","errorCode":null,"errorMessage":"408 Request Timeout","messagePattern":"408 Request Timeout","errorType":"http","errorClass":null,"httpStatus":408,"severity":"warning","filePath":"vertx-core/src/main/java/io/vertx/core/http/HttpResponseExpectation.java","lineNumber":190,"sourceCode":"  /**\n   * 405 Method Not Allowed\n   */\n  HttpResponseExpectation SC_METHOD_NOT_ALLOWED = status(405);\n\n  /**\n   * 406 Not Acceptable\n   */\n  HttpResponseExpectation SC_NOT_ACCEPTABLE = status(406);\n\n  /**\n   * 407 Proxy Authentication Required\n   */\n  HttpResponseExpectation SC_PROXY_AUTHENTICATION_REQUIRED = status(407);\n\n  /**\n   * 408 Request Timeout\n   */\n  HttpResponseExpectation SC_REQUEST_TIMEOUT = status(408);\n\n  /**\n   * 409 Conflict\n   */\n  HttpResponseExpectation SC_CONFLICT = status(409);\n\n  /**\n   * 410 Gone\n   */\n  HttpResponseExpectation SC_GONE = status(410);\n\n  /**\n   * 411 Length Required\n   */\n  HttpResponseExpectation SC_LENGTH_REQUIRED = status(411);\n\n  /**\n   * 412 Precondition Failed","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/http/HttpResponseExpectation.java#L172-L208","documentation":"SC_REQUEST_TIMEOUT is a constant for HTTP 408 Request Timeout. In Vert.x, HttpResponseExpectation constants are used with HttpClientResponse/expectation validation (e.g. via `expecting()` or `Validation` helpers); when a response with status 408 is received, the expectation fails and a VertxHttpResponseException carrying '408 Request Timeout' surfaces to the caller. 408 means the server closed or rejected the request because the client did not produce a request (or complete body) within its allowed time window.","triggerScenarios":"Calling an HTTP endpoint via Vert.x HttpClient/ WebClient while using status expectations, and the remote server returns 408 because the request headers/body were sent too slowly or the connection idled before the request completed.","commonSituations":"Slow request body uploads over poor networks, client code that opens a connection and delays writing the request, intermediaries (proxies/load balancers) with short idle timeouts, retry logic that reuses an idle keep-alive connection the server already timed out.","solutions":["Retry the request on a fresh connection instead of a pooled idle one (the server may have dropped the keep-alive connection)","Reduce time between connection/open and sending the full request; write headers and body promptly","Increase the server/proxy client-header/body timeout if you legitimately send large or slow bodies","Check that any request body pump (e.g. file/stream upload) is not stalled; add progress/timeout logging","Enable client keep-alive timeout shorter than the server's so stale connections are proactively closed"],"exampleFix":"// before\nrequest.send() // reuses idle pooled connection, gets 408\n// after\nclient.request(requestOptions)\n  .onSuccess(req -> req.response()\n      .expecting(HttpResponseExpectation.SC_REQUEST_TIMEOUT.negate())\n      .onSuccess(resp -> { /* handle */ })\n      .end()); // fresh request, failed expectation handled explicitly","handlingStrategy":"retry","validationCode":"// Ensure request is sent promptly after creation\nif (!request.isComplete() /* pending body */) { /* pump body immediately or abort */ }\n// Optionally close stale pooled connections proactively:\nclient.connectionHandler(conn -> conn.exceptionHandler(err -> log.warn(\"conn reset\", err)));","typeGuard":"boolean isRequestTimeout(Throwable t) {\n  return t instanceof VertxHttpResponseException\n    && ((VertxHttpResponseException) t).getResponse().statusCode() == 408;\n}","tryCatchPattern":"if (isRequestTimeout(t)) { retryOnceOnFreshConnection(req); } else { fail(t); }","preventionTips":["Send the full request as soon as the request object is created","Keep client idle/keep-alive timeouts shorter than the server's","Avoid stalling body streams; add timeouts on body pumps","Retry idempotent requests once on a fresh connection"],"tags":["http","timeout","client","vertx"],"backgroundTag":"request-timeout","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}