Beware "grails set-proxy" and http client call

Steve Dalton's picture

Just a quick gotcha we found today. Took us a while to work it out and we ended up fixing it on a hunch, so thought we would share here.

We are using Grails 1.2.1 on a client site and had used "grails set-proxy" to allow us to download grails plugins. Our application made a http client connection using the built in groovy new URL(url).openStream() to another web service (also Grails application). Anyway when running the application in dev mode the client application was failing on the openStream() call with a http status code 503. The meaning of this status code is:

The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response.

We had no idea what was going on, the code had worked before. On a hunch we removed the proxy configuration and Voila! it worked again. This confused me a bit as:

1. I thought grails set-proxy was only for the grails runtime and not the internal tomcat server?
2. The 503 message was very confusing - didn't seem to describe what was really happening, although this was possibly the way our Microsoft proxy server was interpreting the request.

Anyone else experienced this. Is this a bug?

Comments

The proxy is set using system

The proxy is set using system properties (see http://java.sun.com/javase/6/docs/technotes/guides/net/properties.html). As Tomcat runs in-process, it uses the same system properties, which in turn are picked up by HttpUrlConnection (and possibly other HTTP client libs).

HTH,

Wolfgang