url.openConnection() and timeouts

P

Paul Taylor

Hi,

If my internet connection is down then the openConnection() call takes too
long to time out:

url.openConnection();

I have tried setting:

-Dsun.net.client.defaultConnectTimeout=2000
-Dsun.net.client.defaultReadTimeout=2000

on the command line and it doesn't affect the timeout. Also tried setting
them with the System.setProperty function call but this also doesn't work.

My openConnection() call is in a seperate thread which I have tried
interrupting but this also doesn't work!

I am beginning to think that after searching the internet that maybe that
the openConnection function isn't of much use. It is easy to use, but
only if I could somehow control the thing? Could someone please give me
some pointers, maybe answer one or more of the following questions:

(1) Can openConnect() be stopped somehow?
(2) Should defaultConnectTimeout and defaultReadTimeout work? or am I
doing something wrong here?
(3) Do I need to forget about openConnect() and do something else?

Regards,

Paul Taylor.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top