开发者

Unable to make OkHttpClient call

I have a library in which request is happening. Library is using Okhttp-4.9.3. I dont have control on the client builder. When I checked the class file from the library below is the code

protected OkHttpClient getHttpClient() {
    if (okHttpClient == null) {
      okHttpClient = new OkHttpClient();
    }

    Authenticator proxyAuthenticator = (route, response) -> {
      String credential = Credentials.basic(System.getProperty(HTTP_PROXY_USER), System.getProperty(HTTP_PROXY_PASS));
      return response.request().newBuilder()
        .header(HEADER_PROXY_AUTH, credential)
        .build();
    };

    return okHttpC开发者_JAVA百科lient.newBuilder()
      .addInterceptor(new RetryInterceptor(retryCount))
      .connectTimeout(timeout, timeoutUnit)
      .writeTimeout(timeout, timeoutUnit)
      .readTimeout(timeout, timeoutUnit)
      .proxyAuthenticator(proxyAuthenticator)
      .build();
  }

I set System.setProperty(HTTP_PROXY_USER, "TestUser"), System.setProperty(HTTP_PROXY_PASS, "TestPassword")

When I make the request, I am receiving 'java.net.ProtocolException: Too many follow-up requests: 21'

I have below questions. Any help or suggestions I would really appreciate it

  1. It is not expecting proxyHostName and port. How does this work with only credentials. Is there any parameter within System that sets this.
  2. If the error is not related to proxy authentication, then what is the parameter for redirects
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜