JDK-4215767 : More control over timeout request is needed (well atleast it would be nice)
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.2.0,1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-02-27
  • Updated: 2009-05-27
  • Resolved: 2009-05-27
Related Reports
Duplicate :  
Description

Name: dbT83986			Date: 02/27/99


When waiting for a cgi response I find it can often be faster
just to drop the current connection and make a new one if it
hasn't loaded after a second or two.

I was unable to find what should have been a simple solution to
retry the url after only a couple of seconds had passed. I 
believe it would be in the benefit of the Java language for you
to add a feature which would allow the urls to timeout after a
given amount of time (be it longer or shorter).

I think the two best ways to approach this are:

    (1) Allow the user to specify a timeout time (sounds funny) when opening the
    connection.
        ex. openConnection(int milliseconds) would be a method in
        the URL class (and possibly the URLConnection class).

    (2) Allow the user to set a specific timeout time for the URL
    connection itself.  Therefor any other redirects or change of
    urls will already have the last timeout time to wait.
        ex. setTimeout(int milliseconds) would be a new method in
 the URLConnection class.
(Review ID: 52703)
======================================================================

Comments
EVALUATION This has been addressed in another CR (4700777). Closing.
27-05-2009

WORK AROUND Name: dbT83986 Date: 02/27/99 I first tried using the InputStreamReader to check if it was ready() but it would connect first then tell me true (maybe this can be changed, but I don't know how). The only solution I was able to find was to start a new thread and stop it if it hadn't received the first byte after a set amount of time. I was disappointed (well maybe I should say saddened) to find that adjusting the timeout can be done easily in C/C++ but not Java. Thanks for reading my suggestion, I hope you consider it. ======================================================================
11-06-2004

EVALUATION The new "unconnected sockets" API will cover some of that ground. Still, there is no API in URL, or URLConnection() that let the developer access the underlying sockets. The API changes to make this happen are significant. With merlin and the extended socket API, it will be possible for the developers to provide a protocol Handler that will use a specific timeout when connecting the socket. So, there will be some workaround. jean-christophe.collet@Eng 2000-11-10 In merlin the Sun implementation of the protocol handlers have connect and read timeouts that are controlled by the following properties :- sun.net.client.defaultConnectTimeout sun.net.client.defaultReadTimeout Post-1.4 the programmatic control of timeouts and other socket options will be examined - see 4143518. ###@###.### 2001-12-11
11-12-2001