Search code examples
javaplayframeworkproxyplayframework-2.2http-status-code-407

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


Solution

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