我正在使用带有身份验证的代理运行一些异步 GET 请求。执行 HTTPS 请求时,我总是在 2 个成功的异步请求后遇到异常:java.lang.IllegalArgumentException: Auth scheme may not be null
在没有代理的情况下执行 GET 请求或使用 http 而不是 https 时,从未发生异常。
来自Apache HttpAsyncClient 示例的示例
HttpHost proxy = new HttpHost("proxyname", 3128);
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(proxy), new UsernamePasswordCredentials("proxyuser", "proxypass"));
CloseableHttpAsyncClient httpClient = HttpAsyncClients.custom().setDefaultCredentialsProvider(credsProvider).build();
httpClient.start();
RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
for (int i = 0; i < 3; i++) {
HttpGet httpGet = new HttpGet(url);
httpGet.setConfig(config);
httpClient.execute(httpGet, new FutureCallback<HttpResponse>() {
public void failed(Exception ex) {
ex.printStackTrace(); // Exception occures here afther …Run Code Online (Sandbox Code Playgroud)