在Play Framework 2.2.x中设置代理选项时,WS.url失败

时间:2014-11-14 15:11:52

标签: java playframework proxy playframework-2.2 http-status-code-407

我正在使用WS对需要的代理服务器后面的服务器进行REST调用。

我尝试在application.conf中设置proxyserver和port,并在启动应用程序时设置为JVM arg。但我一直得到“错误代码:需要407代理身份验证”。

我尝试将ws.useProxyProperties设置为false和true,但它仍然不起作用。我看到这是一个常见的问题,但没有发布任何解决方法。

你有什么想法吗?

由于

1 个答案:

答案 0 :(得分:0)

我设法通过使用依赖

解决了这个问题
"com.ning" % "async-http-client" % "1.8.14"

将我的代码更改为

AsyncHttpClientConfig cf = new AsyncHttpClientConfig.Builder().setProxyServer(new 
ProxyServer(host, port, user, pwd)).build();
c = new AsyncHttpClient(cf);
AsyncHttpClient.BoundRequestBuilder req = c.prepareGet("http://api.example.com/");
// and many other parameters ...