Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 495
  • Last Modified:

java.net.URLConnection.connect()

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
java_kevin
Asked:
java_kevin
  • 4
  • 4
1 Solution
 
Ajay-SinghCommented:
How are you setting socket timeout in URLConnection?
0
 
java_kevinAuthor Commented:
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
 
girionisCommented:
What version of WebLogic are you using? If >= Weblogic 9.0 then use setReadTimeout(int)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
girionisCommented:
Ok you are using 8.1, still, try to use setReadTimeout(int)
0
 
java_kevinAuthor Commented:
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
 
girionisCommented:
Can you upgrade to sp6?
0
 
java_kevinAuthor Commented:
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
 
girionisCommented:
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
 
java_kevinAuthor Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now