play-ws icon indicating copy to clipboard operation
play-ws copied to clipboard

No place to specify a socks4/5 proxy, unlike AsyncHttpClient

Open fancellu opened this issue 5 years ago • 9 comments

I can't see any place to specify that I'd like wsclient to use a socks proxy, whereas AsyncHttpClient can

https://www.javadoc.io/static/org.asynchttpclient/async-http-client/2.10.4/org/asynchttpclient/proxy/ProxyType.html

vs

https://github.com/playframework/play-ws/blob/f4108eaff2121b25ba4827121937114c415a0d88/play-ws-standalone/src/main/scala/play/api/libs/ws/WS.scala#L81

Thanks

fancellu avatar Nov 20 '19 17:11 fancellu

Here's a repo of mine, doing some socks proxy work, with sttp, various backends, even old HttpUrlConnection

https://github.com/fancellu/play-sttp-examples

fancellu avatar Nov 26 '19 23:11 fancellu

Thanks for reporting this.

I added this issue to the backlog, but it can take sometime before someone can find time to pick it.

Would you be interested in sending a PR?

octonato avatar Nov 28 '19 13:11 octonato

Sorry, I am up to my eyeballs, currently its not a big issue for me as I can use other solutions (as above)

Just found it odd/unexpected that play-ws didn't support it right now

fancellu avatar Nov 28 '19 13:11 fancellu

No worries. That is indeed odd. I guess this is not so common case otherwise it would have been reported before.

If there is some interest in the community, it will get fixed sooner. Otherwise, it's when it becomes a priority.

In any case, thanks for reporting it.

octonato avatar Nov 28 '19 14:11 octonato

There may well be another issue with ahc itself, that you might want to be aware of:

https://github.com/AsyncHttpClient/async-http-client/issues/1682

fancellu avatar Dec 09 '19 18:12 fancellu

If there is some interest in the community, it will get fixed sooner. Otherwise, it's when it becomes a priority.

Hi. Any progress on this? I would really like/need this feature. Thanks!

johnkjellberg avatar Feb 24 '20 14:02 johnkjellberg

You can pass in an already configured AHC client into Play that does have SOCKS configured:

https://github.com/playframework/playframework/blob/master/transport/client/play-ahc-ws/src/main/scala/play/api/libs/ws/ahc/AhcWSModule.scala#L220

wsargent avatar Feb 24 '20 15:02 wsargent

For the standalone client, you would do new StandaloneAhcWSClient(asyncHttpClient)

wsargent avatar Feb 24 '20 16:02 wsargent

Unfortunately AHC doesn't do socks/tor name resolution properly, so I ended up using okttp, which does

https://github.com/AsyncHttpClient/async-http-client/issues/1682

https://gist.github.com/fancellu/df6dde59249edf8401b28bbc44a78cbc

fancellu avatar May 21 '20 15:05 fancellu