2016-08-23 47 views
1

背景的Java繞過代理程序的apache

我使用AWS Java SDK for SQS閱讀從本地隊列中的消息。我爲本地隊列使用ElasticMQ

@Test 
public void readMessageFromQueue() { 

    AWSCredentialsProviderChain credentialsProvider = new AWSCredentialsProviderChain(new DefaultAWSCredentialsProviderChain()); 
    ClientConfiguration clientConfiguration = new ClientConfiguration(); 

    AmazonSQSClient sqsClient = new AmazonSQSClient(credentialsProvider, clientConfiguration); 
    sqsClient.setEndpoint("http://127.0.0.1:9324/queue"); 
    ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest("queue1").withMaxNumberOfMessages(10); 

    ReceiveMessageResult receiveMessageResult = sqsClient.receiveMessage(receiveMessageRequest); 
    List<Message> sqsMessages = receiveMessageResult.getMessages(); 

} 

這工作完全直到我通過代理服務器(工作)

然後我得到了504,因爲它試圖通過我的代理路線我的本地主機連接到我的互聯網。

問題

如何繞過我的代理我用Java編程本地主機?

我曾嘗試以下無濟於事

System.setProperty("NO_PROXY", "127.0.0.1"); 
System.setProperty("proxySet", "false"); 
System.setProperty("proxyHost", ""); 
System.setProperty("proxyPort", ""); 
System.setProperty("no_proxy", "127.0.0.1"); 
System.setProperty("http.no_proxy", "127.0.0.1"); 
System.setProperty("http.proxySet", "false"); 

的作品是增加127.0.0.1繞過蘋果機網絡設置代理的唯一的事情。

localhost in bypass proxy

我自己也嘗試localhost(反對127.0.0.1

什麼想法?

回答

2

您是否嘗試過設置http.nonProxyHosts

String nonProxyHosts = System.getProperty("http.nonProxyHosts"); 
nonProxyHosts = nonProxyHosts == null ? "127.0.0.1" : nonProxyHosts + "|127.0.0.1"; 
System.setProperty("http.nonProxyHosts", nonProxyHosts); 
相關問題