2017-10-13 31 views
0

我寫這在它的心臟採用此塊從外部URL收集信息查詢工具代理數據:AsyncHttpClient不使用提供

AsyncHttpClientConfig proxiedCF = new DefaultAsyncHttpClientConfig.Builder().setUserAgent(pickUserAgent()).build(); 
AsyncHttpClient asyncHttpClient = new DefaultAsyncHttpClient(proxiedCF); 
Future<Response> f = asyncHttpClient.prepareGet(url).setProxyServer(new ProxyServer.Builder(pickProxyServer(), 80)).execute(); 

它工作正常。然而,即使提供了無效的代理服務器,它仍然有效,這有點可疑,我感覺我的精心設計的代理服務器配置根本沒有使用。

我偶然發現pickProxyServer()返回一個String「1.1.1.1」,這顯然不是一個有效的Web代理。

我使用SLF4J的日誌,它看起來非常正常:

20:31:47.454 [AsyncHttpClient-7-1] DEBUG o.a.n.channel.NettyConnectListener - Using new Channel '[id: 0x03359938, L:/10.0.0.101:59775 - R:/1.1.1.1:80]' for 'GET' to '[[url removed by me]]' 
20:31:47.586 [AsyncHttpClient-7-1] DEBUG o.a.netty.handler.HttpHandler - 

Request DefaultFullHttpRequest(decodeResult: success, version: HTTP/1.1, content: EmptyByteBufBE) 
GET [[url removed by me]] HTTP/1.1 
Host: [[url removed by me]] 
Accept: */* 
User-Agent: burning_dandelion 

Response DefaultHttpResponse(decodeResult: success, version: HTTP/1.1) 
HTTP/1.1 200 OK 
Date: Fri, 13 Oct 2017 18:31:49 GMT 
Expires: Fri, 13 Oct 2017 18:31:49 GMT 
Cache-Control: private, max-age=3600 
Content-Type: text/xml; charset=ISO-8859-1 
P3P: CP="This is not a P3P policy!" 
Server: gws 
X-XSS-Protection: 1; mode=block 
X-Frame-Options: SAMEORIGIN 
Set-Cookie: 1P_JAR=2017-10-13-18; expires=Fri, 20-Oct-2017 18:31:49 GMT; path=/; domain=[[url removed by me]] 
Set-Cookie: NID=114=qiVBv02cmXYHh2RfLQbhBfESWIoaGlf3d2jlSbAdQ8yWPDsCpOeK9aYbvfq0HWsER68W1oE53jiriM_fivTc1bJi1F2sfCi0wMptKI-9U3ueVKITtFvYYZx2T0rJf1kQ; expires=Sat, 14-Apr-2018 18:31:49 GMT; path=/; domain=[[url removed by me]]; HttpOnly 
Accept-Ranges: none 
Vary: Accept-Encoding 
Transfer-Encoding: chunked 

20:31:47.587 [AsyncHttpClient-7-1] DEBUG o.a.netty.channel.ChannelManager - Adding key: ProxyPartitionKey(proxyHost=1.1.1.1, proxyPort=80, secured=false, targetHostBaseUrl=[[url removed by me]]:80 for channel [id: 0x03359938, L:/10.0.0.101:59775 - R:/1.1.1.1:80] 

有人能指出我對我的錯誤?很顯然,當一個無效代理被調用時,我想要一個I/O異常或任何類型的通知。

回答

0

好吧,這是半夜,但我找到了一些東西。當端口不是:80時,代理服務器正確使用。這對我來說是個訣竅。