« More Valentine's Day | Main | Portable Desktop »

January 24, 2006

Java Socket Exceptions

I was playing around with a proxy server of my own, in Java of course, when I started getting the following exception: java.net.SocketException. The reason? Connection reset (sometimes 'by peer'). What the hell?

Just for giggles I tried the app on multiple machines on my LAN with the same results on all. Then I tried it on a different LAN, but with Verizon DSL (same as me) to see if it was my equipment. Long story short, I think it was my equipment.

The HTTP 1.1 spec (RFC 2616 [rfc.net]) states that all HTTP 1.1 servers should be able to accept absolute URIs, right? For the answer see section 5.1.2, so that's what I was passing to each host. And there was no end to the damned 'Connection reset' messages. I thought maybe it was my firewall, nope. I thought I was passing malformed headers, nope.

Then I started playing around with my request line, changing the URI and HTTP versions. Things started happening then and I was able to determine that it was because of the absolute URI handling I was getting those messages. So, like I said, I think that my problem is with my equipment, specifically my router. I have a sneaking suspicion that my router is examining HTTP requests when it NATs things and if it doesn't recognize the request as valid it will just drop the connection.

More investigation needs to be done.

Posted by Guy at January 24, 2006 1:25 AM