简体   繁体   中英

WS.url fails when proxy options are set in Play Framework 2.2.x

I am using WS to make a REST call to a server behind a proxy that required.

I tried to set proxyserver and port in application.conf and as JVM arg when I launch the application. But I keep getting "Error Code: 407 Proxy Authentication Required".

I tried to set ws.useProxyProperties at false and true, but it still doesn't work. I saw that it is a common problem, but no workaround has been published.

Do you have any idea?

Thanks

I managed to resolve this issue by using the dependancy

"com.ning" % "async-http-client" % "1.8.14"

And changing my code to

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 ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM