Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CGI Timeout - how might HttpURLConnection be doing a retry?

3 views
Skip to first unread message

Lori D

unread,
Apr 1, 2002, 4:21:21 PM4/1/02
to
I have a small java program:
import java.net.*;
import java.io.*;

public class TimeoutTest {
public static void main(String[] args) throws Exception {
URL tt = new URL("http://myhost/cgi-bin/mycgi");
HttpURLConnection ttc = (HttpURLConnection) tt.openConnection();

int code = ttc.getResponseCode();
System.out.println("response code: " + code);

}
}

The http server and cgi it references purposefully demonstrates a cgi
timeout on Apache 1.3.4 (reproduced problem using Apache 1.3.24). When
running the above program, in the apache access_log I see two invocations
of mycgi at Timeout+1 seconds apart. After the second mycgi invocation
times out, I get the following stack trace:

Exception in thread "main" java.net.SocketException: Unexpected end of file from
server
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:557)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:555)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:465)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:145
)
at TimeoutTest.main(TimeoutTest.java:14)

Using truss, I traced the http server side events to see the read of the
GET from the socket that looks like the following, and have confirmed
that it happens twice.

26245: getsockname(3, 0xFFBEF7A8, 0xFFBEF7BC, 1) = 0
26245: setsockopt(3, 6, 1, 0xFFBEF70C, 4, 1) = 0
26245: read(3, " G E T / c g i - b i n".., 4096) = 164

Is there anything happening "behind the scenes" in java resulting in the URL
I am sending a GET request for to be sent twice? Or, should I be concentrating
on what is happenning on the http server side? Is there possibly a
Retry-After coming down that java is handling for me, but within a tolerance?

A bit more information:
When going to the URL using I.E. - I see the cgi run twice on most platforms.
When going to the URL using Netscape 6.1 - I see the cgi run an unlimited
number of times (I stopped it after 14 times)
after to be

0 new messages