VMware vSphere

 View Only
  • 1.  Timeout in groovy http request

    Posted Feb 12, 2009 11:52 AM
    If I do http request from groovy templates by defining new URL class and fetch content, is it possible change default timeout values.

    Here's example of groovy snippet:

    def url = new URL("http://myserver.foo.com/test")
    def content = url.getText()

    This works ok if server is available or if request gives any kind of error. However, if this connection timeouts it's totally messing my alert templates. Eventually HQ template engine will notice that there is long running methods, but it will take too much time. I just want to ensure that template is ran within 10 seconds.

    If somebody wants to know why I'm trying to do http request from alert template, here's short answer. I have a external(wiki) knowledge base to store alert documentation. Here I'm just trying to include some documentation to emails what HQ is sending to users.

    This is kind of groovy problem. Does anybody know any workaround for this issue?


  • 2.  RE: Timeout in groovy http request
    Best Answer

    Posted Feb 12, 2009 05:45 PM
    Hi Janne,

    I don't know of a way to set the timeout there.. I guess that's the price you pay for convenience when using those Groovy shortcut methods.

    You may just have to do it the old fashioned way. As an alternative, HQ does ship with commons-httpclient, so you could also use that if you need more fine grained control over the parameters & connection settings.

    -Ryan


  • 3.  RE: Timeout in groovy http request

    Posted Feb 12, 2009 06:29 PM
    Thanks Ryan, that's it. The most simplest solution you can get. :)

    Sometimes when you walk on the left side of the road, you totally forget that there's right side where you can jump. Gosh, how blind a man can be. OK, sometimes I also forget that java and groovy are like old couple, they're living on the same house but has separate bedrooms ;)


  • 4.  RE: Timeout in groovy http request

    Posted Feb 27, 2009 08:11 PM
    Too funny. Love the analogy.

    Charles