English 中文(简体)
Groovy: 由于未设定代理文件而超时( Java. net. Connect Explition)
原标题:Groovy: Timeout due to proxy not being set (java.net.ConnectException)
  • 时间:2012-05-25 11:30:59
  •  标签:
  • groovy
  • proxy

我想用格罗维脚本访问网页,但是我支持代理。

这里有一个失败的测试脚本...

println "Google page is..."
println  http://www.google.com .toURL().text

在这里输出...

>groovy proxytester.groovy 
Google page is... 
Caught: java.net.ConnectException: Connection timed out: connect
   at checker.run(proxytester.groovy:2)

<强> 如何在 Groovy 设置代理服务器信息?

最佳回答

或者,从格罗维内部自己:

System.properties << [  http.proxyHost : proxyHost ,  http.proxyPort : port  ]
问题回答

代理信息可以设置为 JVM, 通过在 grooovy 命令线上通过参数, eg...

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\可以\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

这个脚本然后起作用了...

println "Google page is..."
println  http://www.google.com .toURL().text

在这里,结果...

Google page is
<!doctype html><html itemscope itemtype="http://schema.org/WebPage"><head><meta
http-equiv="content-type.....

更多信息见"http://docs.oracle.com/javase/6/docs/technotets/guides/net/proxies.html" rel=“no follow” > Oracle docs





相关问题
How to change firefox proxy from webdriver?

how can I access Firefox proxy settings from Python Webdriver and change them to make Firefox use modified proxy settings without needing to restart it?

Regex Proxy Server

I control access via a proxy server and run some regex on every request. For prototype I have used curl, regex and php. Obviously this will not put up with any serious load. Can anyone suggest and ...

Specify a Proxy in config vs code for a WSE/SOAP web service

Is there a way to specify a WSE3 proxy in the config file instead of code. I figured out how to get it working in code as follows: valservice.Proxy = new System.Net.WebProxy("http://10.192.xx.xx:...

Accessing a git repository via ssh behind a firewall

I would like to access (clone/push/pull) a private (via ssh) git repository while behind a corporate firewall that only allows http proxy access. I have written a robust Java (daemon) program (based ...

Set proxy data for an app

I have a few .NET apps which use the HttpWebRequest. My gut says i can create a config or manifest file and set the proxy data in there and .NET will automatically load it. But i dont know if that ...

热门标签