Friday, 3 December 2010

Look below

One of my favourite HTTP-related protocols is Hessian. It's elegant, binary, free and the client lib is small. After overcoming some issues OpenJDK was having with classloading, I was stuck with one particularly strange problem:

Caused by: com.caucho.hessian.io.HessianProtocolException: '
' is an unknown code

Debugging an applet is a nasty enterprise. There's no real way to hook into the instance running inside the browser, logging is tricky and OpenJDK still doesn't come around with a decent console, so I've got to work with starting Firefox from the console (where I got the stack trace from).

So what does the exception mean? Hessian might be a binary protocol, but still goes through HTTP. So pulling out a packet sniffer and having a look at the response, it becomes clear what happened: The response is not a binary stream from the server side, but looks rather like the index page. Obviously, the server didn't recognise the session ID and responded with a login. And the first character of that page? A line feed. That would be the one from the exception...

1 comment: