Solved

java.net.URLConnection.connect()

Posted on 2006-07-13
9
473 Views
Last Modified: 2008-01-09
hi guys,

I'm working on a new project.

I'm trying to find out about connection timeout exception. I've set the timeout of the connection to a limit, but weblogic does not accept it. It still referred to its xml file for its timeout period. I'm trying to resolve this by testing all possibities of getting/setting a timeout period.

At my side, I tried getting my program to connect to a non-existent website, and get "unknown host" error, whcih is logical. Is there any way I can test the SocketTimeoutException error?

umm... i think my topics are pretty messy...
0
Comment
Question by:java_kevin
  • 4
  • 4
9 Comments
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17105614
How are you setting socket timeout in URLConnection?
0
 

Author Comment

by:java_kevin
ID: 17105946
URL url = new URL(targetURL);
connection = (HttpURLConnection)url.openConnection();
connection.setTimeout(300000);
try {
connection.connect();
....
}

catch (SocketTimeoutException e) {
...
}

====================

HttpURLConnection is a method that implements the abstract method from java's java.net.HttpURLConnection.
http://edocs.bea.com/wls/docs81/javadocs/weblogic/net/http/HttpURLConnection.html
0
 
LVL 35

Expert Comment

by:girionis
ID: 17106149
What version of WebLogic are you using? If >= Weblogic 9.0 then use setReadTimeout(int)
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 35

Expert Comment

by:girionis
ID: 17106154
Ok you are using 8.1, still, try to use setReadTimeout(int)
0
 

Author Comment

by:java_kevin
ID: 17135267
umm, gosh, There is a difference between WebLogic 8.1 SP2 and SP6!

SP6 seems to provide setReadTimeout, while SP2 is still using setTimeout.

And accordingly to http://e-docs.bea.com/wls/docs81/notes/resolved_sp03.html, setTimeout feature in SP2 seems buggy.

For SP2, http://e-docs.bea.com/wls/docs81/notes/resolved_sp02.html, nothign was mentioned.

Any idea where I can get API documentation for weblogic 8.1 SP2? ;)
0
 
LVL 35

Expert Comment

by:girionis
ID: 17136230
Can you upgrade to sp6?
0
 

Author Comment

by:java_kevin
ID: 17136421
No plans to do so at the moment.

But is this a bug? I mean, I can't really grasp the exact meaning it's trying to pass.

Does it mean, the calling of the method will be delayed, or it really refers to the value accepted by the method will be doubled?
0
 
LVL 35

Accepted Solution

by:
girionis earned 125 total points
ID: 17136441
Yes it's a bug in the implementation of setTimeout. It means that the time taken for the timout to occur is double. I.e. if you set the timeout to 1000, it will take 2000 before it times out. Well, if it is so, then the only thing you have to do is to set half the time out of the required amount.
0
 

Author Comment

by:java_kevin
ID: 17136481
oh.. that's... why..

alright, i'm asking the BEA side for an official confirmation of this issue, before I proceed to change the code again.

Will check back here again!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
custom annotations 9 42
iterator/ListIterator approach 17 41
maven module vs maven project 3 48
Why is enum singleton a better approach than static factory 3 25
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question