【问题标题】:How to increase timeout while making a REST call from a Java jersey client?从 Java jersey 客户端进行 REST 调用时如何增加超时?
【发布时间】:2016-09-01 12:00:03
【问题描述】:

我正在进行一个 REST 调用,大约需要 2 或 3 分钟才能响应,但我遇到了连接超时异常。如何增加正在进行的 REST 调用的超时时间。

这里是代码sn-p,

    Client restClient = Client.create();
    WebResource webResource = restClient.resource(requestURL);
    ClientResponse response =  webResource.accept("application/json").header("Authorization", authStringEnc)
                .get(ClientResponse.class);
        if (response.getStatus() != 200)
        {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

请帮我解决这个问题。

【问题讨论】:

标签: java rest jersey-client connection-timeout


【解决方案1】:

或者您可以更改请求标头,例如:

连接:保持活动保持活动:超时= set_your_desired_time 限制

【讨论】:

  • @dwarakeshtp 如果这对你有用,你能接受这个作为答案吗?以便对其他人有所帮助
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-21
  • 2015-11-14
  • 1970-01-01
  • 2017-02-01
  • 1970-01-01
  • 2023-03-31
相关资源
最近更新 更多