Java以编程方式绕过代理apache
背景 我正在使用从本地队列读取消息。我正在为我的本地队列使用Java以编程方式绕过代理apache,java,apache,amazon-web-services,proxy,Java,Apache,Amazon Web Services,Proxy,背景 我正在使用从本地队列读取消息。我正在为我的本地队列使用 @Test public void readMessageFromQueue() { AWSCredentialsProviderChain credentialsProvider = new AWSCredentialsProviderChain(new DefaultAWSCredentialsProviderChain()); ClientConfiguration clientConfiguration =
@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();
}
唯一有效的方法是在Mac网络设置中添加127.0.0.1
以绕过代理
我也尝试过localhost
(反对127.0.0.1
)
有什么想法吗?你试过设置http.nonproxy主机吗
非常感谢您的接受,为我带来了两枚徽章。不幸的是,你没有太多的内容我可以表达我的感激之情。但是,每当你有另一个重要问题时,就给我留个便条;-)
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");
String nonProxyHosts = System.getProperty("http.nonProxyHosts");
nonProxyHosts = nonProxyHosts == null ? "127.0.0.1" : nonProxyHosts + "|127.0.0.1";
System.setProperty("http.nonProxyHosts", nonProxyHosts);