Jer*_*ERT 6 proxy scala scala-dispatch
我正在尝试从代理后面执行(在IntelliJ IDE或sbt命令行中)这个非常基本的调度片段:
import dispatch._
val svc = url("http://api.hostip.info/country.php")
val country = Http(svc > as.String)
println(country())
Run Code Online (Sandbox Code Playgroud)
而我所能得到的只是一个例外:
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
Run Code Online (Sandbox Code Playgroud)
我尝试没有确定的结果来设置通常的vm参数:
-Dhttp.proxyHost=_my_proxy_host_ -Dhttp.proxyPort=80
并仍然得到相同的异常.
另一方面,以下代码段运行良好:
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())
Run Code Online (Sandbox Code Playgroud)
因为它看起来不太美观,也不像scala-ish,我想知道在这种情况下它是否真的应该是我应该做的.
如果提前感谢,欢迎任何帮助.
http.proxyHost并将http.proxyPort在您设置此参数时使用:
-Dcom.ning.http.client.AsyncHttpClientConfig.useProxyProperties=true
Run Code Online (Sandbox Code Playgroud)
另外还有参数:
-Dcom.ning.http.client.AsyncHttpClientConfig.proxy.user=user
-Dcom.ning.http.client.AsyncHttpClientConfig.proxy.password=password
-Dcom.ning.http.client.AsyncHttpClientConfig.proxy.protocol=NTLM
Run Code Online (Sandbox Code Playgroud)