2016-08-23 48 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); 
相关问题