Common Exceptions
Many exceptions should be self explanatory. However here are some common
exceptions that can be thrown by HTTPClient (they're all subclasses of
java.io.IOException) and for which the true cause might not be obvious.
- java.net.SocketException: Connection refused
- (connecting to the local host) The server is not running (nobody
is listening on the specified port).
- java.net.SocketException: Invalid argument
- (connecting to a different host) The server is not running (nobody
is listening on the specified port).
- (connecting to a different host) The host is not reachable.
- java.net.UnknownHostException: host
- The host name host could not be translated to an IP-address.
This most often occurs if you are behind a corporate firewall and the
system is set up such that you can't resolve names of hosts outside the
firewall. In most of these cases you need to be going through a proxy
anyway, so configure the HTTPClient to use the proxy.
- java.net.SocketException: Connection reset by peer
- The server abrubtly aborted the connection. The reason could be almost
anything. Check that you are sending the appropriate request (method,
headers, etc) and that there is indeed an http server listening at the
specified host and port.
- java.net.SocketException: Malformed reply from SOCKS server
- The SOCKS server refused the connection.
- The SOCKS server is running version 5; the JDK currently only
supports version 4.
If you have any further exceptions that you think should be listed here,
please let me know.
Ronald Tschalär / 6. May 2001 /
ronald@innovation.ch.