在代理后面使用分派0.9.5? [英] use dispatch 0.9.5 behind proxy?

查看:88
本文介绍了在代理后面使用分派0.9.5?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试(从IntelliJ IDE或从sbt命令行)从代理后面执行此非常基本的调度代码段:

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

我尝试没有确定的结果来设置通常的vm参数: -Dhttp.proxyHost= _my_proxy_host_ -Dhttp.proxyPort=80 仍然有同样的例外.

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.

推荐答案

http.proxyHosthttp.proxyPort:

-Dcom.ning.http.client.AsyncHttpClientConfig.useProxyProperties=true

此外还有参数:

-Dcom.ning.http.client.AsyncHttpClientConfig.proxy.user=user
-Dcom.ning.http.client.AsyncHttpClientConfig.proxy.password=password
-Dcom.ning.http.client.AsyncHttpClientConfig.proxy.protocol=NTLM

这篇关于在代理后面使用分派0.9.5?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆