How to set TimeOut in URL

Hi everyone,
" URL u = new URL(url);
InputStream is = u.openStream();
BufferedReader dis = new BufferedReader(new InputStreamReader(is)); "
My problem is,
1. if host is down,my program waits for dafult time to connect
2. After connecting to server, there 's some problem to get response from Host.
my program wait for response long time.
I want to change these two timeout. Also, i 'm using jdk1.3.if it's 1.5 i can use setConnectTimeout method .
If u have solution, please revert to me.
Thanks
JaiGanesh.R

http://coding.derkeiler.com/Archive/Java/comp.lang.java.programmer/2004-01/3271.html

Similar Messages

  • Set timeout for URL connection in java1.4

    hi
    I want to set timeout for URL connection in java 1.4..
    java 5.0 provides with a setTimeout(int ) method but how should it be done in 1.4 environment
    Thanks in advance
    sneha

    sun.net.client.defaultConnectTimeout (default: -1)
    sun.net.client.defaultReadTimeout (default: -1)
    See the [Networking Properties|http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html].

  • How to set user friendly URL in ApEx with OHS 11g ?

    Hi,
    How to set user friendly URL in ApEx with OHS 11g ?
    I want change the link http://190.148.xxx.xxx:8080/pls/apex to something like http://xxx.com.
    I dont want to use iFrame solution. Please suggest any other method to acheive the same.
    Thanks & Regards,
    Ranu

    Hi all
    Iam using apex 4.0 -oracle 11g with OHS on linux os
    I need to change my apex url http://x.x.x.x:xxxx/apex to http://x.com
    What are the settings i need to do.
    If any one knows please share the solution with me
    Thanks & In advance

  • How to set timeout during call oci api

    hi all :
    in my program i use OCIInitialize and OCIEnvInit to connect oracle 10g ,but sometime the db does not return ,whether ok or error , at the same time i use sqlplus to connect db ,it is the same .
    so i want to set timeout in my program , does oracle support set timeout in the such scene , if support ,how can i do ?
    thanks a lot
    Message was edited by:
    user549861

    print code :
    if(OCIInitialize(OCI_THREADED ,0, 0, 0, 0)!=OCI_SUCCESS)
         return -1;
         if(OCIEnvInit( (OCIEnv **) &(p_env), OCI_DEFAULT, 0, 0 )!=OCI_SUCCESS)
         return -1;
    if (OCIHandleAlloc ((dvoid *)p_env, (dvoid **)&p_srv,
    OCI_HTYPE_SERVER, 0, (dvoid **) 0)!=OCI_SUCCESS)
         return -1;
         if(OCIHandleAlloc(p_env, (dvoid **) & (p_err), OCI_HTYPE_ERROR, 0, 0)!=OCI_SUCCESS)
         return -1;
    if (OCIServerAttach (p_srv, p_err, (text *)strNodeName,
    strlen (strNodeName), OCI_DEFAULT)!=OCI_SUCCESS)
         return -1;
         if(OCIHandleAlloc(p_env, (dvoid **) & (p_svc), OCI_HTYPE_SVCCTX, 0, 0)!=OCI_SUCCESS)
         return -1;
         if (OCIHandleAlloc ((dvoid *)p_env, (dvoid **)&p_ses,
    OCI_HTYPE_SESSION, 0, (dvoid **) 0)!=OCI_SUCCESS)
         return -1;
         if (OCIAttrSet ((dvoid *)p_svc, OCI_HTYPE_SVCCTX,
    (dvoid *)p_srv, (ub4) 0, OCI_ATTR_SERVER, p_err)!=OCI_SUCCESS)
         return -1;
         if (OCIAttrSet ((dvoid *)p_ses, OCI_HTYPE_SESSION,
    (dvoid *)strUserName, (ub4)strlen(strUserName),
    OCI_ATTR_USERNAME, p_err)!=OCI_SUCCESS)
         return -1;
    if (OCIAttrSet ((dvoid *)p_ses, OCI_HTYPE_SESSION,
    (dvoid *)strPasswd, (ub4)strlen(strPasswd),
    OCI_ATTR_PASSWORD, p_err)!=OCI_SUCCESS)
         return -1;
    if (OCISessionBegin (p_svc, p_err, p_ses,
    OCI_CRED_RDBMS, OCI_DEFAULT)!=OCI_SUCCESS)
         return -1;
    if (OCIAttrSet ( (dvoid *)p_svc, OCI_HTYPE_SVCCTX,
    (dvoid *)p_ses, (ub4) 0, OCI_ATTR_SESSION, p_err)!=OCI_SUCCESS)
         return -1;
    how can i set timeout in the these code

  • How to set  'Background Daemon URL' IN CONFIGURATION TAB ?

    Hi All,
    While running background job shuduling, i am getting following error :
    <b>PLEASE SET 'Background Daemon URL' IN CONFIGURATION TAB.</b>
    I have the url, but where to set it in configuration tab ?
    Regards,
    Anubha

    Christian,
    This URL http://<servername>:port/webdynpro/dispatcher/virsa/ccappcomp/BgJobStart?debug=1 allows you to view the entries in a given table. You can not insert information here, as you've already noticed. You will need to get your database admin involved. They will need to make these entries for you directly at the db level. Once the db has entered the required values you will then be able to validate that the values are there by pointing to this URL and checking table virsa_cc_config.
    Hope this helps
    Edit: Updated to the URL in this message to reflect the correct one.
    Message was edited by:
            Michael Penn

  • How to set TimeOut period in Portal

    Hi,
    I am running a report in the portal which is taking more than 1 min to display the results. After this one min the page is getting timedout. Can any one please let me know how to administrate the timeout interval. I found this link
    http://help.sap.com/saphelp_nw2004s/helpdata/en/b7/60b54066ea8531e10000000a1550b0/frameset.htm
    but where in the portalapp.xml should I set the parameter "com.sap.portal.page.PageTimeout".
    Thanks,
    Sudhir

    Hi Sudhir
    This link will help you:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/b7/60b54066ea8531e10000000a1550b0/frameset.htm
    Maybe you could consider changing the page properties to increase the cache validity.
    Check the following thread for more details:
    iView Session Timeout
    Cheers.
    Please award points for helpful answers.

  • How to set timeout when BPEL Invokes EBS API in 10G

    I am invoking a EBS API through Oracle Applications Adapter in my BPEL, During the execution of my BPEL Process, if my EBS API call takes more than 10s, i want it to timeout. Can you please let me know how can i achieve it. I tried using the <property name="timeout">10</property> <property name="optSoapShortcut">false</property> in the partnerlink defintion, but it didnt help.

    Thanks Arik and vijay for your response,
    syncMaxWaitTime needs to be set at the domain level, then it would timeout all the services that are deployed on my environment. Property transaction-timeout and syncMaxWaitTime will not resolve the issue, because i need to achieve the timeout for a particular service only (Sorry, I should have mentioned in the problem statement that i need to implement the timeout for a specific service).
    I tried the PartnerLink timeout property along with optSoapShortcut but timeout is not happening.
    If you could provide me any other alternative solutions that would help me to timeout the call to EBS using a Oracle Applications Adapter in BPEL 10g Invoke activity.
    Wish you a belated Happy Christmas and advanced New Year wishes.
    Regards,
    Sivananda
    Edited by: 978071 on Dec 26, 2012 2:43 AM
    Edited by: 978071 on Dec 26, 2012 2:44 AM

  • How to set two FMS URLs in Adobe Flash Media Live Encoder

    Hello Folks,
    Just wondering if anyone can give me any details on how I can set two Flash Media Server URLs on Adobe Flash Media Live Encoder to share one camera but stream it to two servers.
    Thank you.

    Put both URL's in the two FMS url's fields, primary/backup (its just naming, the "primary" and "backup", it could be named FMS1 and FMS2 as well)...
    Same stream name...

  • How to set item via URL only when that item is null

    From application A, I am attempting to set an application-level item of Application B via the URL to Application B. I only want the application-level item of Application B to be set when it the item is null. If it is not null, I don't want the application-level item to be set to something else.
    I can't think of a way to do this from within Application B after the URL takes the user to Application B and I can't think of a way to do it from within Application A before the URL is invoked. The URL in Application A is part of a List (Shared Component) so it is not clear to me how to use PL/SQL to dynamically tell the URL to include or not include the assignment of the application-level item in the URL call.
    Am I missing something obvious?

    You could pass the value into a different item in application B. A before-header page process in the target page could then perform the transfer of the sent item into another item if that other item is null.
    Scott

  • How to set the destination URL of a HtmlCommandLink component

    How can I please set by code the URL which will be opened when I click on an HtmlCommandLink or HtmlOutputLink .
    I couldn't find the associated method.
    Thanks in advance.

    Thanks for your reply .But I didn't foud the method allowing to set the url attribute to the component.
    But now my problem is resolved.I used the com.sun.webui.jsf.component.Hyperlink component.And it has method named setUrl making what I want.
    Thanks.

  • TCP Client Server - how to set timeout and bandwidth option

    Hi Friends,
    I am writing a simple TCP based client-server app and I would like the connection to be dropped after a certain time of inactivity and also I would like to control the connection's bandwidth. I would appreciate if someone can throw some pointers as to how this can be done.
    I have tried this so far, for Timeout I am trying to do this:
    sock.setSoTimeout(10000);But I think this is not the right way as this will disconnect the server from all client connections I guess. I think the better way would be to write a timer or something for each connection but I don't know how...
    Any help?

    Micks80 wrote:
    Hi Friends,
    I am writing a simple TCP based client-server app and I would like the connection to be dropped after a certain time of inactivity and also I would like to control the connection's bandwidth. I would appreciate if someone can throw some pointers as to how this can be done.
    I have tried this so far, for Timeout I am trying to do this:
    sock.setSoTimeout(10000);But I think this is not the right way as this will disconnect the server from all client connections I guess.Wrong in a couple of ways.
    1) That doesn`t disconnect anything. It causes a read that reaches that time in blocking to be unblocked and an exception (java.net.SocketTimeoutException) is thrown. The Socket is still just fine and can be used (all other things being equal). At any rate you then decide what you want to do after a timeout. One possibility is to close the socket because to you that timeout means it is abandoned.
    2) setSoTimeout of ServerSocket applies to the accept* method. setSoTimeout of Socket applies to reads from that sockets input stream. Neither of those apply anything to all connections.
    I think the better way would be to write a timer or something for each connection No setSoTimeout is correct. You will also then need to actually attempt to read something for that timeout exception to ever be thrown.
    As far as the bandwidth question goes, you will need to define your goals better. Please do not just restate "control bandwidth" because that is not actually a very specific goal. Do you want to limnit the bandwidth used at one time (tricky) or do you want to limit the total bandwidth used. Either way requires some work but they are different things.

  • How to set timeout

    hi all,
    i have a method that should be executed in a certain time...
    void method(String param){
    return result; // if result is not there after 2 minutes, throw an exception ??
    how can i do that?
    regards

    If you look at URLConnection, it has facilities for doing thing
    Or you could use my TimeOut class
    http://forums.sun.com/thread.jspa?threadID=5315374

  • Can some one give me clear answer how to set timeouts on URLConnection ?

    I am amazed why Sun did not specify a simple method like setReadTimeout
    on URLConnection or provide a way to get refernce to the underlying socket objet. By default the timeout is infinite!
    I am using JDK 1.4 and these appraoches:
    -Dsun.net.client.defaultConnectTimeout=<value in milliseconds>
    -Dsun.net.client.defaultReadTimeout=<value in milliseconds>
    also don't work.
    I do not have access to Socket object. Please help.
    I am using URLConnection in my client application on HTTPS and doing heavy load form POST processing. I tried
    Sockets as well but they don't work. URLConnection works perfectly fine except for the timeouts nightmare.

    OK this might sound crazy but you may have been onto it right from the start. I was having the exact same (frustrating) problem with the URLConnection waiting forever on a dead server and no way to terminate it. I tried something like what you said in your first post:
    System.setProperty("sun.net.client.defaultReadTimeout", "10000");
    and it worked. I played around with the number and it it was apparent to the naked eye that it was working (if you can believe that...).
    Of course, I'm using JDK 1.4.1_01 by now, so this might be different now.
    ttfn.

  • How to set the returned url contents

    I have a pageflow which talks to a remote servlet and get back the results and now i need to display the contents in <iframe>, Let me know how to pass the values back to the JSP

    Hello  Chao-Yi Wu,
    I don't have a real solution for you - just a few comments:
    1. At
            Try
                val = oDataTable.GetValue(0, 0)
            Catch ex As Exception
            End Try
    I would add
            Try
                if oDataTable Is Nothing Then Exit Sub ' If the User cancels the CFL
                val = oDataTable.GetValue(0, 0)
            Catch ex As Exception
            End Try
    2. At
       If pVal.ColUID = "col_0" Then
    I would make the branch by the pVal.ChooseFromListUID instead of the ColUID
    and the 2nd not with "Else" but with "Else If ....."
    3. It may work with EditText.String/Value of a cell but I never do that because of performance-reasons.
    I always do it the same way as you in principle - I don't really know what the problem is.
    4. Maybe some unique indexes on your table (although this should give an error at the update and not at CFL when "the unique-law is broken"...)?
    Sorry - that's all for the moment.
    Cheers,
    Roland

  • How to set HttpURLConnection timeout while reading a stream?

    I want it got time out if the connection if lose while i read a stream from URL
    try {
         int timeout = 700;
         HttpURLConnection connection = (HttpURLConnection) downloadURl.openConnection();
         connection.setConnectTimeout(timeout);
         connection.setRequestProperty("Range","bytes=" + downloaded + "-");
         connection.connect();
         if (connection.getResponseCode() / 100 != 2) {
              error();
         int contentLength = connection.getContentLength();
         if (contentLength < 1) {
              error();
         if (status == DOWNLOADING){
              if (size == -1) {
                   size = contentLength;
              file = new RandomAccessFile(saveTmpName+".tmp", "rw");
              file.seek(downloaded);
         byte buffer[];
         stream = connection.getInputStream();
    connection.setReadTimeout(timeout);
         while (status == DOWNLOADING) { 
              if (size - downloaded > MAX_BUFFER_SIZE) {
                   buffer = new byte[MAX_BUFFER_SIZE];
              } else {
                   buffer = new byte[(int)(size - downloaded)];
              int read = stream.read(buffer); // how to set timeout while it is reading stream
              if (read <= 0)
                   break;
              file.write(buffer, 0, read);
              downloaded += read;
         if (status == DOWNLOADING) {
              status = COMPLETE;
    } catch (SocketTimeoutException  e) {
         error();
    } catch (IllegalArgumentException e) {
         error();
    } catch (Exception e) {
         error();
    } finally {
         if (file != null) {
              try {
                   file.close();
              } catch (Exception e) {}
         if (stream != null) {
              try {
                   stream.close();
              } catch (Exception e) {}
    }I try to set "setReadTimeout()" but is still not through timeout Exception

    ejp wrote:
    Because, there's no FTP client command that allows to do such thing.Socket.setSoTimeout().I agree with you on this one but the OP is talking about the FTPClient API from Apache.
    To the OP,
    BTW, I have reread the Javadoc about the [*API*|http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html] : indeed, there's no setTimeout method, but there is a setDataTimeout method : +Sets the timeout in milliseconds to use when reading from the data connection+ .

Maybe you are looking for