W3C home > Mailing lists > Public > www-jigsaw@w3.org > March to April 2001

HttpURLConnection and GET requests - please help

From: Ronen Lazar <RonenL@gilian.com>
Date: Tue, 13 Mar 2001 11:53:25 -0500 (EST)
Message-ID: <1797E7C8F378D411A1CE00D0B77E59CE2A7CAB@gilian-mail>
To: "'www-jigsaw@w3.org'" <www-jigsaw@w3.org>
Hi all,

I'm trying to use the HttpURLConnection in order issue "GET" HTTP requests.
So I created a derived class of it (only set the constructor to be public),
and set the stream handler factory to generate an instance of it each time
an "http" call is being made, with calling url.openConnection(...).
This works just fine when working with existing urls. The problem is that
when requesting non-existing urls, the connection with the web-server
doesn't seem to close correctly, and it gets stuck after calling
getInputStream() (in the 6th "GET" request). I.e. after 5 GET requests to
non-existing file, the 6th will stuck after the call to getInputStream.

When checking what's going on with "netstat", I see 5 sockets to the server
in "CLOSE_WAIT" status.
I thought maybe it has something to do with the max concurrent users
allowed, so I tried to call HttpManager.getManager().setMaxConnections(...)
with number bigger than 5 (after calling openConnection()), but it didn't

Can you help on this urgent one, please?
Thanks a lot,

my code:
public class MyHttpURLConnection extends
	public CGJHttpURLConnection(URL u) throws IOException

	public void setMaxConn (int connections)

public class MyURLStreamHandlerFactory extends Object implements
	public URLStreamHandler createURLStreamHandler(String protocol)
		if (protocol.equalsIgnoreCase("http")){
			return new URLStreamHandler(){
				protected URLConnection openConnection(URL
u) throws IOException
						return new
MyHttpURLConnection (u);
					} catch (IOException e){
						throw e;

// the executing class:
public class GetTest
	private static URL url_obj = null;

	public static void main (String args[])
		try {
			url_obj = new URL ("http", "www.somesite.com", 80,
			for (int i = 0; i < 6; i++){ // on the last
iteration, it will stuck
		} catch( Exception e ) {

	private static void get ()
			org.w3c.www.protocol.http.HttpURLConnection con = 
(org.w3c.www.protocol.http.HttpURLConnection)url_obj.openConnection ();
			OutputStream out = con.getOutputStream();

			InputStream in = con.getInputStream();	
			System.out.println ("code =
		} catch (java.net.MalformedURLException e){
		} catch (java.net.ProtocolException e){
		} catch (java.io.IOException e){
Received on Tuesday, 13 March 2001 12:02:33 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:25:37 UTC