/** * Configures the amount of time in milliseconds after which if the request does not return any data within the timeout * period an {@link java.util.concurrent.TimeoutException} fails the request. * <p> * Setting zero or a negative <code>value</code> disables the timeout. * @param value The quantity of time in milliseconds. * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.client.HttpRequest<T> timeout(long value) { delegate.timeout(value); return this; }
/** * Configures the amount of time in milliseconds after which if the request does not return any data within the timeout * period an {@link java.util.concurrent.TimeoutException} fails the request. * <p> * Setting zero or a negative <code>value</code> disables the timeout. * @param value The quantity of time in milliseconds. * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.client.HttpRequest<T> timeout(long value) { delegate.timeout(value); return this; }
private void getNow(RoutingContext ctx) { count++; final WebClient client = WebClient.create(vertx); client.get(80, HTTP_NOW, "/") .timeout(5000) .as(BodyCodec.jsonObject()) .send(ar -> { if (ar.succeeded()) { HttpResponse<JsonObject> response = ar.result(); JsonObject body = response.body(); String now = body.getJsonObject("now").getString("rfc2822"); ctx.response().end(now + " " + String.format(RESPONSE_STRING_FORMAT, HOSTNAME, count)); } else { ctx.response().setStatusCode(503).end(ar.cause().getMessage()); } }); }
rq.timeout(timeoutMs);
/** * Get all info about messaging client (stdOut, stdErr, code, isRunning) * * @param uuid client id * @return * @throws InterruptedException * @throws ExecutionException * @throws TimeoutException */ public JsonObject getClientInfo(String uuid) throws InterruptedException, ExecutionException, TimeoutException { CompletableFuture<JsonObject> responsePromise = new CompletableFuture<>(); JsonObject request = new JsonObject(); request.put("id", uuid); client.get(endpoint.getPort(), endpoint.getHost(), "") .as(BodyCodec.jsonObject()) .timeout(120000) .sendJson(request, ar -> responseHandler(ar, responsePromise, HttpURLConnection.HTTP_OK, "Error getting messaging clients info")); return responsePromise.get(150000, TimeUnit.SECONDS); }
/** * Stop messaging client and get all informations about them (stdOut, stdErr, code, isRunning) * * @param uuid client id * @return * @throws InterruptedException * @throws ExecutionException * @throws TimeoutException */ public JsonObject stopClient(String uuid) throws InterruptedException, ExecutionException, TimeoutException { CompletableFuture<JsonObject> responsePromise = new CompletableFuture<>(); JsonObject request = new JsonObject(); request.put("id", uuid); client.delete(endpoint.getPort(), endpoint.getHost(), "") .as(BodyCodec.jsonObject()) .timeout(120000) .sendJson(request, ar -> responseHandler(ar, responsePromise, HttpURLConnection.HTTP_OK, "Error removing messaging clients")); return responsePromise.get(150000, TimeUnit.SECONDS); }
ar.result().get("/") .as(BodyCodec.jsonArray()) .timeout(5000) .send(res -> { if (res.succeeded()) {
@Override public void handle(HttpContext context) { context.request() .timeout(configuration.getRequestTimeout()) .putHeader(HttpHeaders.ACCEPT, CONTENT_TYPE) .putHeader(HttpHeaders.ACCEPT_CHARSET, StandardCharsets.UTF_8.name()); // Basic authentication if (authorizationHeader != null) { context.request().putHeader(HttpHeaders.AUTHORIZATION, authorizationHeader); } context.next(); } });
@Test public void testTimeout() throws Exception { AtomicInteger count = new AtomicInteger(); server.requestHandler(req -> count.incrementAndGet()); startServer(); HttpRequest<Buffer> get = client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath"); get.timeout(50).send(onFailure(err -> { assertTrue(err instanceof TimeoutException); testComplete(); })); await(); }
if (service != null) { for (VxApiServerURLInfo urlinfo : service) { webClient.requestAbs(serOptions.getMethod(), urlinfo.getUrl()).timeout(serOptions.getTimeOut()).send(res -> { if (res.succeeded()) { int statusCode = res.result().statusCode();
request.timeout(30000);
request.timeout(30000);
loadParam(rct, requestPath, headers, queryParams, bodyParams); HttpRequest<Buffer> request = webClient.requestAbs(serOptions.getMethod(), requestPath).timeout(serOptions.getTimeOut()); request.headers().addAll(headers); request.queryParams().addAll(queryParams);