作者:妮子爱笨蛋 | 来源:互联网 | 2023-08-09 20:16
httpclient添加正向代理设置,程序报错:org.apache.http.conn.UnsupportedSchemeException:http protocolisnot
httpclient 添加正向代理设置,程序报错:
org.apache.http.conn.UnsupportedSchemeException: http protocol is not supported
HttpPost httpPost = new HttpPost(serviceUrl);// 目标服务器
httpPost.addHeader("Content-type","application/json; charset=utf-8");
httpPost.setHeader("Accept", "application/json");
HttpHost proxy = new HttpHost(WalletConfig.PROXY_HOSTNAME, Integer.valueOf(WalletConfig.PROXY_PORT), WalletConfig.PROXY_PROTOCOL_TYPE);// 代理服务器
RequestConfig cOnfig= RequestConfig.custom().setProxy(proxy).build();
httpPost.setConfig(config);//设置代理配置
查了一天多,最后发现是运维配置代理协议类型的时候,在properties配置文件里面把 http 后面多加个空格,空格,空格,然后程序执行的时候就报了org.apache.http.conn.UnsupportedSchemeException: http protocol is not supported 的异常。然后把http后面的空格去掉问题就解决了(程序里面还是要加上去空格啊)。。。。。。