I'm trying to execute (in IntelliJ IDE or from sbt command-line) this very basic dispatch snippet from behind a proxy :
import dispatch._
val svc = url("http://api.hostip.info/country.php")
val country = Http(svc > as.String)
println(country())
and all I can get is an exception :
java.net.ConnectException: Connection timed out: no further information to
http://api.hostip.info/country.php java.util.concurrent.ExecutionException:
java.net.ConnectException: Connection timed out: no further information
to http://api.hostip.info/country.php
I tried with no conclusive result to set the usual vm parameters :
-Dhttp.proxyHost=
_my_proxy_host_ -Dhttp.proxyPort=80
and still got the same exception.
On the other hand, the following snippet does work well :
import dispatch._
val svc = url("http://api.hostip.info/country.php") setProxyServer(new com.ning.http.client.ProxyServer(myproxyhost,80))
val country = Http(svc > as.String)
println(country())
Since it does not seem quite aesthetic nor scala-ish, I wonder if it is really what I am supposed to do in such a case.
Any help would be welcome, thanks in advance.
Looks like my question wasn't very inspiring.
I did a little exercie in the pimp my library style :
Now I can write :
which is a little bit more eye pleasing and coherent regarding dispatch api style.
While it was an interesting exercise, I still don't know by now if i was originally using the api the way I was supposed to nor why setting
http.proxyHost
andhttp.proxyPort
properties didn't work since it seems to work for others.http.proxyHost
andhttp.proxyPort
will be used if you set this parameter:Additionaly there are parameters: