I’ve been dealing with this for a while now trying to figure out why, when using my online accounting software, users sporadically get a StatusCodeException when sending requests to the server. I finally this week figured out what was going on; glassfish was dropping the connection or sending bad responses occasionally because it doesn’t behave in the was that the mod_proxy modules of these webservers expect it to.
Originally I was running lighttpd and I was thinking this might be a bug in lighttpd, so I eventually switched to apache. Once I was running apache I got a much more verbose error – instead of just a plan 500 or 502 status code I got a message. I googled that error message plus glassfish and found the solution.
I thought I’d share it here so that future searchers who are using lighttpd or apache will have more places to find the answer.
To fix the issue, add:
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
To your apache httpd.conf. I don’t know what the equivalent fix for lighttpd is, if there is any.
From this fix, it appears that glassfish is misbehaving in some way in relation to being behind a proxy, but I don’t what way that is and I’m just glad I fixed this mysterious problem!
If any of you readers have more information about this issue, please comment!

September 5, 2008 at 11:57 am |
For those having this problem, it looks like this isn’t the only fix required, since I’m still getting those errors. Another avenue I’m trying is changing the HTTP listener settings in glassfish so it won’t timeout apache’s connections.
September 22, 2008 at 12:22 pm |
Did changing the listener settings help or are you still getting proxy errors.
September 22, 2008 at 12:26 pm |
I am still getting proxy errors, occasionally.
October 7, 2008 at 11:37 am |
We were getting those errors and were able to recreate them reliably which lead us to the issue with the Reciever Buffer on the Http service for glassfish. We bumped it up to 8192 bytes and now all the errors are gone. Hope this helps.
October 7, 2008 at 1:36 pm |
Thanks, I’ll give that a try!
October 7, 2008 at 1:39 pm |
Hmm, it looks like my receiver buffer was already set to 8192. Maybe I’ll bump it up a bit more.
October 7, 2008 at 1:42 pm |
Oh wait – the receive buffer is also set in the connection pool, got it. Hopefully the problem will go away now … thanks for the tip!
November 9, 2008 at 4:47 pm |
Since the above fixes didn’t really do it, I’ve also been adding parameters to my ProxyPass directive; currently it looks like this:
ProxyPass “http://aux:8080/app” min=1 max=250 ttl=300 smax=32 retry=0
Someone somewhere had suggested that retry=0 helps … we’ll see. It seems like all this tweaking has greatly reduced the number of errors I’m seeing, but not eliminated them (my app emails me and dumps an event into our analytics whenever that error occurs).
December 19, 2008 at 4:45 am |
I have exactly the same symptoms – is there a definitive medicine finally ?
December 19, 2008 at 4:49 am |
I wish there was.
My current workaround is to automatically retry the requests. I have made a GWT generator which generates a wrapper for a service; the wrapper automatically retries the call when it gets certain status codes. You can get this from the Kiyaa! project:
http://code.google.com/p/kiyaa
December 19, 2008 at 4:51 am |
I wish there was.
My current workaround is to automatically retry the requests. I have made a GWT generator which generates a wrapper for a service; the wrapper automatically retries the call when it gets certain status codes. You can get this from the Kiyaa! project:
http://code.google.com/p/kiyaa
However, the changes to the buffer size and keepalive settings above are helpful also.