Shorting the timeout for socket connection

Hi everyone, i've got a client who owns a handle to a remote object. When the remote object quits, accesing it through a method invocation throws a java.net.SocketTimeoutException: Read timed out. That's fair, what's up is that it lasts about six seconds in sending it, and i would like to shorten the time it waits until it realises it can't connect. I've tried with sun.rmi.transport.connectionTimeout and sun.rmi.transport.tcp.readTimeout, and no success. Any idea?
Thanks in advance.

The "sun.rmi.transport.proxy.connectTimeout" parameter works only when HTTP is used.
We do it manually by utilizing RMI client and server socket factories and setting socket options as appropriate. For the connect timeout, there is connect(SocketAddress endpoint, int timeout) method of the Socket class. With this approach, the application has a full control over sockets used by the RMI engine.

Similar Messages

  • I suppose it is the problem with socket connection,Please help

    Hi,
    I'm trying to build a chat server in Java on Linux OS.I've created basically 2 classes in the client program.The first one shows the login window.When we enter the Login ID & password & click on the ok button,the data is sent to the server for verification.If the login is true,the second class is invoked,which displays the messenger window.This class again access the server
    for collecting the IDs of the online persons.But this statement which reads from the server causes an exception in the program.If we invoke the second class independently(ie not from 1st class) then there is no problem & the required data is read from the server.Can anyone please help me in getting this program right.I'm working on a p4 machine with JDK1.4.
    The Exceptions caused are given below
    java.net.SocketException: Connection reset by peer: Connection reset by peer
    at java.net.SocketInputStream.SocketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:119)
         at java.io.InputStreamReader$CharsetFiller.readBytes(InputStreanReader.java :339)
         at java.io.InputStreamReader$CharsetFiller.fill(InputStreamReader.java:374)
         at java.io.InputStreamReader.read(InputStreamReader.java:511)
         at java.io.BufferedReader.fill(BufferedReader.java:139)
         at java.io.BufferedReader.readLine(BufferedReader.java:299)
         at java.io.BufferedReader.readLine(BufferedReader.java:362)
         at Login.LoginData(Login.java:330)
         at Login.test(Login.java:155)
         at Login$Buttonhandler.actionPerformed(Login.java:138)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1722)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:17775)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:4141)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:253)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:261)
         at java.awt.Component.processMouseEvent(Component.java:4906)
         at java.awt.Component.processEvent(component.java:4732)
         at java.awt.Container.processEvent(Container.java:1337)
         at java.awt.component.dispatchEventImpl(Component.java:3476)
         at java.awt.Container.dispatchEventImpl(Container.java:1399)
         at java.awt.Component.dispatchEvent(Component.java:3343)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3302)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3014)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2967)
         at java.awt.Container.dispatchEventImpl(Container.java:1373)
         at java.awt.window.dispatchEventImpl(Window.java:1459)
         at java.awt.Component.dispatchEvent(Component.java:3343)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:439)
         at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:150)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:131)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
         My program looks somewhat like this :
    1st class definition:
    public class Login extends Jframe// Login is the name of the first class;
    Socket connection;
    DataOutputStream outStream;
    BufferedReader inStream;
    Frame is set up here
    public class Buttonhandler implements ActionListener
    public void actionPerformed(ActionEvent e) {
    String comm = e.getActionCommand();
    if(comm.equals("ok")) {
    check=LoginCheck(ID,paswd);
    test();
    public void test() //checks whether the login is true
    if(check)
    new Messenger(ID);// the second class is invoked
    public boolean LoginCheck(String user,String passwd)
    //Enter the Server's IP & port below
    String destination="localhost";
    int port=1234;
    try
    connection=new Socket(destination,port);
    }catch (UnknownHostException ex){
    error("Unknown host");
    catch (IOException ex){
    ex.printStackTrace ();
    error("IO error creating socket ");
    try{
    inStream = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    outStream=new DataOutputStream(connection.getOutputStream());
    }catch (IOException ex){
    error("IO error getting streams");
    ex.printStackTrace();
    System.out.println("connected to "+destination+" at port "+port+".");
    BufferedReader keyboardInput=new BufferedReader(new InputStreamReader(System.in));
    String receive=new String();
    try{
    receive=inStream.readLine();
    }catch(IOException ex){ error("Error reading from server");}
    if(receive.equals("Logintrue"))
    check=true;
    else
    check=false;
    try{
    inStream.close();
    outStream.close();
    connection.close();
    }catch (IOException ex){
    error("IO error closing socket");
    return(check);
    // second class is defined below
    public class Messenger
    Socket connect;
    DataOutputStream outStr;
    BufferedReader inStr;
    public static void main(String args[])
    { Messenger mes = new Messenger(args[0]);}
    Messenger(String strg)
    CreateWindow();
    setupEvents();
    LoginData(strg);
    fram.show();
    void setupEvents()
    fram.addWindowListener(new WindowHandler());
    login.addActionListener(new MenuItemHandler());
    quit.addActionListener(new MenuItemHandler());
    button.addActionListener(new Buttonhandle());
    public void LoginData(String name)
    //Enter the Server's IP & port below
    String dest="localhost";
    int port=1234;
    int r=0;
    String str[]=new String[40];
    try
    connect=new Socket(dest,port);
    }catch (UnknownHostException ex){
    error("Unknown host");
    catch (IOException ex){
    ex.printStackTrace ();
    error("IO error creating socket ");
    try{
    inStr = new BufferedReader(new InputStreamReader(connect.getInputStream()));
    outStr=new DataOutputStream(connect.getOutputStream());
    }catch (IOException ex){
    error("IO error getting streams");
    ex.printStackTrace();
    String codeln=new String("\n");
    try{
    outStr.flush();
    outStr.writeBytes("!@*&!@#$%^");//code for sending logged in users
    outStr.writeBytes(codeln);
    outStr.write(13);
    outStr.flush();
    String check="qkpltx";
    String receive=new String();
    try{
    while((receive=inStr.readLine())!=null) //the statement that causes the exception
    if(receive.equals(check))
    break;
    else
         str[r]=receive;
         r++;
    }catch(IOException ex){ex.printStackTrace();error("Error reading from socket");}
    catch(NullPointerException ex){ex.printStackTrace();}
    } catch (IOException ex){ex.printStackTrace();
    error("Error reading from keyboard or socket ");
    try{
    inStr.close();
    outStr.close();
    connect.close();
    }catch (IOException ex){
    error("IO error closing socket");
    for(int l=0,k=1;l<r;l=l+2,k++)
    if(!(str[l].equals(name)))
    stud[k]=" "+str[l];
    else
    k--;
    public class Buttonhandle implements ActionListener
    public void actionPerformed(ActionEvent e) {
    //chat with the selected user;
    public class MenuItemHandler implements ActionListener
    public void actionPerformed(ActionEvent e)
    String cmd=e.getActionCommand();
    if(cmd.equals("Disconnect"))
    //Disconnect from the server
    else if(cmd.equals("Change User"))
         //Disconnect from the server & call the login window
    else if(cmd.equals("View Connection Details"))
    //show connection details;
    public class WindowHandler extends WindowAdapter
    public void windowClosing(WindowEvent e){
    //Disconnect from server & then exit;
    System.exit(0);}
    I�ll be very thankful if anyone corrects the mistake for me.Please help.

    You're connecting to the server twice. After you've successfully logged in, pass the Socket to the Messenger class.
    public class Messenger {
        Socket connect;
        public static void main(String args[]) {
            Messenger mes = new Messenger(args[0]);
        Messenger(Socket s, String strg) {
            this.connect = s;
            CreateWindow();
            setupEvents();
            LoginData(strg);
            fram.show();
    }

  • 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].

  • Workplace won't give me the password for wifi connection

    My place of employment refuse to give me the password for wifi connection. Is there anyway around this?

    Nothing legal. They do add password access for a reason.

  • Just bought an ipad mini.  It recognizes my internet connection but doesn't connect.  It shows a lock.  How do I get to where I enter the password for my connection?

    Just bought an ipad mini.  Trying to set up internet connection.  It recognizes my connection but will not load.  There is a padlock shown.  How do I get to where I need to enter the password for my connection?

    On your router/modem, there will be a Wi-Fi password. If you enter that into your iPad for your connection, then your iPad will have permission to connect to that access point and then you will be able to use your internet.

  • How to extend the timeout for long running queries

    I unfortunately have a query that needs to run for 2 hours (long story) to load a year's worth of data into PowerPivot (RTM).  PowerPivot stops with an error after running for 1 hour.  I tried changing the "General Timeout" setting from 0 to 28800
    (8 hours) in the SQL conneciton settings (native client 10.0) and I also managed to get the server owner to increase the "Query Timeout" setting in the SQL Server's Connections dialog but PowerPivot still errors out after 1 hr.  
    A workaround will be to use SSIS to run the query and store the result in another database but I'd rather not do that if I don't have to.
    Error Message
    The refresh operation failed because the source data base or the table does not exist, or because you do not have access to the source
    More Details:
    OLE DB or ODBC error: Query timeout expired; HYT00.
    An error occurred while processing the 'XXXX' table.
    The operation has been cancelled.
    Is there any other place where the timeout can be set or controlled that I've missed?

    Try 
    1) Setting "ExternalCommandTimeout" in the server configuration file (msmdsrv.ini) to a multiple of seconds you want (in this case >7200, by default it is 3600(1hr)).
    2) Restart the server.
    3) Refresh the data.
    Please let me know, if this doesn't work.

  • What s the solution for ' cannt connect to iTunes Store

    I have just bought an ipad 3G with IOS6
    Most of the time,i have not been able to download Apps which are  originally from Apple or 3rd party.
    The statement prompted has always been ' Cannt connect to iTunes Store '.
    Pls advise me on this problem.
    Gin Eng

    Hi All,
    I'd like to revive this thread and ask for further clarification of why SWF reloading isn't supported in AoT builds for iOS for SWF assets that have ABC.  When we package these assets using ADT it strips the bytecode from these files and packages it within the primary application SWF so I don't think that Apple ToU compliance is an issue any longer.  I assume there must be a technical limiation in how the loaded SWF with stripped ABC is linked back up with it's bytecode after loading.
    Is this a limitation of the AIR runtime that can be worked around in the future, or something that stems from a technical limitation of how the cross-compiled code actually executes under iOS?  In otrher words, can it be fixed in a future release of AIR?
    It seems to me that the promise of using AIR is the ability to target web and iOS from the same codebase.  If you have an existing application of some complexity targeting web then it's likely loading assets on demand and reloading them later as needed (Ex. we have over 700 items in game that can be equipped on avatars and each is a separate SWF asset).  Having to extensively modify the app's asset manager for the iOS platform crates the need for divergent codebases at the core level for each platform.  It seems like this is an important flaw to address if Adobe wants to target mobile gaming.

  • OSB: Business Service Timeout for JCA Connection

    Hi,
    I am wondering if there's any way to configure timeout for a JCA connection in OSB? It's not configurable in Business Service.
    Thanks.

    Hi Anuj,
    I am using DbAdapter. As for operation, which operation are you referring to? Where do I check to verify this?
    Thanks.
    Edited by: user13298498 on May 21, 2012 11:01 PM

  • Adjusting the timeout for web services

    Dear All,
    I created a web service using se80. It's execution may be longer than 60 s. Is there a way I can adjust the timeouts of the web service, say extend it to 10 minutes?
    Thanks,
    Philon

    hi
    good
    go through this link,hope this ll help you to solveyour problem
    http://help.sap.com/saphelp_nw04/helpdata/en/1f/37813b650cdc0be10000000a114084/content.htm
    thanks
    mrutyun^

  • What is the interface for MDD connected to monitor?

    I got an used MDD 1 GHz for child, which does come with any cord or accessories. The most surprise to me is its port for connecting itself to a monitor. I cannot find an interface for connecting it to the cord of the monitor. What is the part number or where can I find the interface?
    I would appreciate any help. Thank you very much.
    Robert

    It has 3 possible connectors for a Monitor...
    ADC Apple Display Connector...
    DVI...
    VGA...
    ADC to DVI adapter...
    http://www.eworldsale.com/belkin-adc30m-to-dvi24f-cube-adapter855630844.html

  • Urgent:Need to add Timeout for getting connection

    All,
    While using DriverManager.getConnection to get the connection,I need to add Timeout in my code so if I don't get a connection with in 30 seconds,I need to say'Operation Timed out.
    I was using DriverManager Api's setLoginTimeout method to set the desired time but it doesn't work.Can somebody tell me some other way to do it.

    If I use this method then if second thread reports
    Timed out after 30 seconds and then origional thread
    gets connection after 30 seconds then it'll also
    report.I dont want a connection if 30 second time
    passes.I think if second thread reports 'timed out'
    then I won't be able to explicitly kill the origional
    thread as stop method is deprecated in Thread
    class.Can you make it clear please?You can't stop the actual thread attempting the connection.
    It will require some thought on your part to correctly wrap it.
    It might not work at all because the getConnection() method, or something in it, might be synchronized.

  • Which paramter configures the timeout for rfc call (to R/3 ) from BPM

    hi froum,
    i have a scenario, with BPM, in which theres a synchronous send to a rcf Function Module in R/3,
    now, can u tell me which paramter decides the time out for this Sync call to rfc enabled Function Module in R/3,
    i mean which paramater in SXMB_ADM or anywhere else that dictates the time period

    Check this out, RFC adapter section
    /people/michal.krawczyk2/blog/2006/06/08/xi-timeouts-timeouts-timeouts
    Regards,
    Prateek

  • How to control the timeout for StreamSocket.ConnectAsync(), and StreamSocketListener.AcceptAsync()?

        I can not file API to do this.Ray_ni

    Hi Ray,
    Here is a simple sample...
    async void btnGetData_Click(object sender, RoutedEventArgs e)
    // separated all this out so it is clearer:
    //Create a socket
    StreamSocket aSocket = new StreamSocket();
    //Cancellation token is inspected to determine if the async method should be cancelled
    CancellationTokenSource cts = new CancellationTokenSource();
    //In this case, after 2 seconds... signal cancel
    cts.CancelAfter(2000);
    //get the operation
    StreamSocketConnectOperation op = aSocket.ConnectAsync(new Windows.Networking.HostName("localhost"), "22112", SocketProtectionLevel.PlainSocket);
    //Create a task and pass the cancellation token
    Task aTask = op.StartAsTask(cts.Token);
    try
    //kick off the task and wait for a result!
    await aTask;
    catch(TaskCanceledException tcEx)
    string a = "Task Cancelled: " + tcEx.Message;
    catch(Exception theEx)
    string b = "Exception: " + theEx.Message;
    finally
    string c = "done, still might have had an exception though";
    Enjoy!
    -Jeff
    Jeff Sanders (MSFT)

  • When is the update for Cisco Connect software with OS X 10.8 Mountain Lion?

     @OfficialLinksys When will @Cisco_Support update Cisco Connect software with OS X 10.8 Mountain Lion compatibility?

    I believe all Mac users are waiting for that update but so far it is not yet available. We are yet to hear from Cisco for its official release for the software that is compatible already for Mountain Lion.

  • How to switch off the timeout for cryptsetup on boot?

    Hi,
    like the title says... I have a problem with cryptsetup having a timeout value after the update yesterday. I don't want it. How to get rid of it?
    Thank you in advance.

    tomegun wrote:in options, append: "timeout=0"
    Yes. Thank you. I found it now in the man page. This is really annoying to have a timeout there as a default setting. I did not setup any timeouts in crypttab and I thought it was a bug in some systemd stuff. Also the wiki pages are not up-to-date anymore where I've been looking first. They still refer to the old cryptsetup settings.

Maybe you are looking for

  • FAQ didn't help

    I am using Pages 1.0.2 I am using a newsletter template and somehow I managed to get a blank page in between pages 3 and 4. I can't delete it according to the FAQ directions without deleteing pages 2 and 4 also. I tried to delete the text manually, a

  • How to run the bw workspace in browser

    Hi Folks, Good Day!. I have created bw workspace in bw system powered by hana and may iknow the option how to run the workspace in browser. Please guide. Thanks, Hari

  • Error when importing CO Hierarchies from R/3 DEV to R/3 QAS

    Dear SDN, I am getting the following error when importing Cost center and cost element hierarchies from R/3 DEV to R/3 QAS... Object OSOA  0COSTCENTER_0101_HIER has not yet been imported successfully Object OSOA  0COSTELMNT_0102_HIER has not yet been

  • Loss of sound on entire computer by iTunes

    Hi, occasionally when clicking on a song within iTunes to play it my entire system volume goes down to barely audible. I've checked ALL volume settings, etc and they're all fine. It plays fine for days then this will happen and I need to reboot to ge

  • Having particles change to a bezier path

    Can someone give me an outline of how to take a particle template... (small flowers flying out of a hat), change from flying in the air to all following a bezier path that ends up being a child's cursive name. I have a great particle template spewing