Inability to control initial timeout in Socket Factory

Hello,
We have built our own RMI socket factory where we want to control the timeout of the sockets created there. This is our code
    public Socket createSocket(String host, int port) throws IOException {
            Socket socket = new Socket(host, port);
            socket.setSoTimeout(requestTimeout);
            return socket;
    }Due to spurious heavy loads on our server, we need to operate with timeout values up to 100 seconds.
However, we find that it is impossible to control the initial socket creation timeout. We observe this thought the lack of giving the the desired timeout parameter. Thus, the socket times out in the default 10 seconds in this initial call, not waiting the desired 100s before making the exception.
Creating the socket through first creating a default socket and afterwards binding it like this
Socket socket = new Socket();
socket.setSoTimeout(socketTimout);
socket.bind(new InetAddress(host,port));did not seem to do the trick in this setting either (neither did replacing bind with connect).
What is the reason for this shortcoming in the API? Any workarounds?
Best regards,
Helge Fredriksen

You want:
Socket socket = new Socket();
socket.connect(host,port,connectTimeout);
socket.setSoTimeout(readTimeout);
return socket;Socket.setSoTimeout only sets the read timeout. Also be aware that with the timed connect shown above you can usually only reduce the timeout, not increase it, from its default.

Similar Messages

  • TimesTen environment variables that control TAF timeouts

    Hi
    I am some questions.
    I read the following contents in the TimesTen 7.0 manual .
    There are two TimesTen environment variables that control TAF timeouts:
    o TT_ORA_FAILOVER_TIMEOUT: TAF timeout in minutes for the user application
    (SWT cache groups, cache groups with the propagate option, and cache
    groups using the passthrough feature). The default is 5 minutes.
    o TT_ORA_FAILOVER_TIMEOUT: TAF timeout in minutes for the
    replication agent (for AWT cache groups). The default is 5 hours.
    How do I set one of these variables TT_ORA_FAILOVER_TIMEOUT , TT_ORA_FAILOVER_TIMEOUT ?
    Thank you very much.

    Hopefully you are now on a 11.2.n release or planning to be.  These settings are now part of the ttCaacheConfig callable procedure.
    Sorry I've not seen hwo they would be set in 7.0.
    Steve

  • Intermittent inability to control

    I have been experiencing the inability to control my Xserve (headless) on my ethernet LAN, but this occurs only once in a while. Other times it works fine. I have several other computers (all Mac) on the LAN and never have had problems controlling them.
    Oddly, when this issue occurs, I can still "observe" the Xserve, altho the observation is essentially a freeze frame: I can even affect things on the desktop, but I have to exit the screen then pull it up again to observe what I've done! Usually a reboot solves it, but what a pain.
    Strange, eh? Any help appreciated.
    Lost count   Mac OS X (10.4.4)  

    Well, I'm having a worse problem with this... I am looking at the login window of my G5 downstairs, and it is visually frozen. Everything functions, but nothing changes the display. If I change the quality of the display with the slider, or even just click the slider; or if I change full screen to part of screen, or naything like that - it updates, but is still frozen. However, for me - /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/k ickstart doesn't work either; merely restarts it, my client reconects, gets one frame, and is visually frozen again. This is dang near impossible to work with... Any ideas?

  • Tutorial for socket factory

    hi.. anybody knows where I can get a good tutorial about socket factories and server socket factories??.. thanks for the help..

    can anybody tell me how to use a socket factory to create sockets which work with firewalls/proxy servers ??

  • Determing the socket factory currently used

    Hi all,
    On the server side, there are 2 different socket factories being used:
    SSL server/client socket factory on port 3000
    server/client socket factory on port 1099
    When a request comes in, can we determine the type of socket factory being used?
    Thanks in advance.

    Not really. Here you go:
    import java.rmi.AccessException;
    import java.rmi.NotBoundException;
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    import java.rmi.registry.LocateRegistry;
    import java.rmi.registry.Registry;
    import javax.rmi.ssl.SslRMIClientSocketFactory;
    import javax.rmi.ssl.SslRMIServerSocketFactory;
    public class ReadOnlyRegistry
         extends sun.rmi.registry.RegistryImpl
         // NB DO NOT SPECIFY THIS, otherwise the default Registry stub is incompatible with this
         // remote object.
         // implements Registry
         private Registry     delegate;
          * Creates a new instance of ReadOnlyRegistry.
          * @param plaintextPort Plaintext port number: Only list() and lookup() are permitted via this port.
          * @param sslPort SSL port number: all operations are permitted via this port. This
          * registry is constructed with default SslRMIClientSocketFactory and SslRMIServerSocketFactory.
          * All the conditions for using a default SSLContext and these factories are therefore
          * required, specifically the system properties:
          * <ul>
          *<li>javax.net.keyStore
          *<li>javax.net.keyStoreType
          *<li>javax.net.keyStorePassword
          *<li>javax.net.trustStore
          *<li>javax.net.trustStoreType
          * </ul>to be set correctly.
          * @exception RemoteException Exception constructing either Registry.
         public ReadOnlyRegistry(int plaintextPort, int sslPort) throws RemoteException
              super(plaintextPort);
              // Construct the SSL delegate.
              // Note that as LocateRegistry.createRegistry() reutnrs the remote object, not a stub,
              // we will talk to the delegate directly via local method invocation, not via RMI/SSL.
              this.delegate = LocateRegistry.createRegistry(sslPort, new SslRMIClientSocketFactory(), new SslRMIServerSocketFactory());
         public void     bind(String name, Remote object) throws RemoteException
              throw new AccessException("bind not allowed via plaintext port");
         public String[] list() throws RemoteException
              return delegate.list();
         public Remote lookup(String name) throws RemoteException, NotBoundException
              return delegate.lookup(name);
         public void rebind(String str, Remote remote) throws RemoteException
              throw new AccessException("rebind not allowed via plaintext port");
         public void unbind(String name) throws RemoteException, NotBoundException
              throw new AccessException("unbind not allowed via plaintext port");
    }Message was edited by:
    ejp

  • Controlling the timeout period when synchonizing with cluster

    I see a message when my server starts up:
              "Waiting to synchronize with other running members of MyCluster."
              When the other servers in the cluster aren't up, the server waits to time out before continuing with startup (default 30 seconds or so?). Is there a way to control the timeout period?
              Thanks,
              Jim

    This can be specified in the console under:
              Environment -> Clusters -> "MyCluster"
              You have to click the "Advanced" link to get access to the advanced cluster settings. The name of the property is: "Member Warmup Timeout".
              If you would like to change it programatically, the relevant MBean attribute is : "ClusterMBean.MemberWarmupTimeSeconds"

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

  • Set timeout on socket?

    If i want to set timeout on a clientsocket how do i do?
    I know you use setsotimeout, but i don't know how
    Can someone post a short samplecode?
    Thanks!
    (something like this but with timeout)
    Socket MyClient;
    try {
    MyClient = new Socket("Machine name", PortNumber);
    catch (IOException e) {
    System.out.println(e);
    }

    Can you stop saying TRIPPLE POSTING BLA BLA BLA and
    help me instead?
    Stop multiposting and cross posting you fool.
    I have said like 100 times i DON'T get it, it would
    be nice if you posted some sample code so i can see
    what i have been doing wrong.
    Post your code and we can see where you have gone wrong. Please use your original thread for this.

  • Setting initial timeout for login

    I am using FORM based authentication for my portal. Default installation appears
    to restrict the time a user is authenticated very shortly. Where can I change
    this setting and what should I put if it is in the web.xml or weblogic.xml?
    Thanks!
    Eric

    Peter-
    I basically have a setup similar to the e2ePortalProject in samples, e2ePortal.
    I have a default installation and haven't changed any session timeouts, etc.
    If it is an idle time issue, where could that be changed to a longer duration?
    What I am experiencing is logging in, doing some browsing in a portal, checking
    some code/making changes behind the scenes or looking at some paperwork and then
    navigating, or attempting to navigate. I am not sure of the average time I take
    to get back, but it is in the neighborhood of around 30 seconds.
    Eric
    "Peter" <PeterB> wrote:
    >
    "Eric Ballou" <[email protected]> wrote in message
    news:3f33ef82$[email protected]..
    I am using FORM based authentication for my portal. Default installationappears
    to restrict the time a user is authenticated very shortly. Where canI
    change
    this setting and what should I put if it is in the web.xml orweblogic.xml?
    Thanks!
    Could you provide more information on the problem? It is hard to tell
    what
    is going wrong without more
    info.
    One engineer suggested it might be the result of a keep-alive session
    where
    the idle time
    for a connection with no traffic has expired

  • How can I add logic control with timeout in OSB?

    In the proxy service, when I try to call business service, the business service may timeout, how can I add logic with this? Like, I can set the timeout to 20 seconds, if more than 20 seconds, then do something else. But I just want this service can set to 20 seconds, others may different. Is that possible? Thanks.

    There is a Read Timeout and Connection Timeout setting in the Business service configuration.
    You can change the default values and test.Inside the error handler you can choose to do something else after you 20 seconds.
    Test and let us know if it works.

  • How to set the default NetworkInterface for the default socket factory?

    Hi,
    I would like to know how to set the default network interface used by the JVM. I saw that you can specify the network interface when creating a socket. But my problem is that I dont want to change every socket creation in the application and even worse some partner's libraries wich I dont have access to code also create sockets. So is there a way to specify to the JVM wich interface to use by default? I didn't saw any System.properties to set this and my googling fishing didn't return anything usefull.
    Thanks

    By default it will use whichever one the routing tables tell it will give the shortest path to the destination. For globabl changes, adjust your routing tables. You can't do this from Java, you have to use whatever OS tools are to hand.

  • 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)

  • Control Initial Volume Level?

    How can I control the audio volume level during the first few seconds before the theme menu is displayed? I found that I can adjust the audio volume during the display of the menu itself, but the lead-in volume is much louder and I haven't found any way to adjust it. If it matters, I'm using the "Marquee" theme. Thanks for any suggestions.

    WIth additional searching I found another post on this topic from some months ago. I tried increasing the iMovie audio level. I'm burning another DVD now to see if that helps.

  • Problem with socket factory in RMI over SSL in proxy setup

    Hi
    The following is the setup I have;
    1. I have an application in which the server is running in https mode and I have exported my remote objects using ServerSocketFactory and ClientSocketFactory which will create SSLServerSocket and SSLSocket respectively.
    2. When I run my connect a client to this server and invoke some method on any of the remote objects, I get the following exception:
    java.lang.NullPointerException
    at sun.rmi.transport.tcp.TCPConnection.getOutputStream(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
    at sun.rmi.server.UnicastRef.invoke(Unknown Source)
    at com.acme.ems.server.app.main.TestSumImpl_Stub.addOne(Unknown Source)
    at com.acme.ems.client.app.tools.EMSHaSftpSettings.okButtonActionPerformed(EMSHaSftpSettings.java:216)
    at com.acme.ems.client.app.tools.EMSHaSftpSettings.access$000(EMSHaSftpSettings.java:28)
    at com.acme.ems.client.app.tools.EMSHaSftpSettings$1.actionPerformed(EMSHaSftpSettings.java:183)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.Dialog$1.run(Unknown Source)
    at java.awt.Dialog$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.Dialog.show(Unknown Source)
    at com.acme.ems.client.utility.BasicDialog.showContainerInsideDialog(BasicDialog.java:103)
    at com.acme.ems.client.app.tools.EMSHaSftpSettings.init(EMSHaSftpSettings.java:322)
    at com.adventnet.nms.util.ConsumeKnownEvents.showTheFrame(ConsumeKnownEvents.java:197)
    at com.adventnet.nms.util.ConsumeKnownEvents.actionPerformed(ConsumeKnownEvents.java:103)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.AbstractButton.doClick(Unknown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    My understanding is, when invoking remote object's method from the client, a the clientSocketFactory implementation will be called and an SSLSocket will be created for communication between remote server and client. In this case,my guess is somehow the createSocket() method of the clientSocketFactory is returning Null.The question is why?????Any help soon is appreciated.
    Note that , we are doing this in a proxy set-up.

    I've made a similer post.
    I was able to get it working by doing the following
    Make sure to add and equals to your RMISocketFactory's
    something at least this
    public boolean equals(Object obj)
    return obj != null && obj.getClass() == this.getClass();
    I had to enable the follong cypher suite SSL_DH_anon_WITH_RC4_128_MD5
    but this leads to a possible man in the middle attack.
    I posted to try and get that resolved. (see ssl lockup on handshake)

  • How to customize RMI socket factory

    Hello all,
    I'm trying to follow the instructions of an article published in JavaWorld, regarding data compression: http://www.javaworld.com/javaworld/javaqa/2001-12/01-qa-1207-ziprmi.html
    I'm getting a "no current ZIP entry" exception when running my client application.
    java.rmi.RemoteException: ; nested exception is:
    java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
    java.util.zip.ZipException: no current ZIP entry
    at com.foo.rmi.RMICSSClient.info(RMICSSClient.java:111)
    at com.foo.ServiceTest.test(ServiceTest.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest(TestCase.java:164)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:120)
    at junit.framework.TestSuite.runTest(TestSuite.java:228)
    at junit.framework.TestSuite.run(TestSuite.java:223)
    at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Caused by: java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
    java.util.zip.ZipException: no current ZIP entry
    at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
    at sun.rmi.server.UnicastRef.invoke(Unknown Source)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
    at $Proxy0.info(Unknown Source)
    at com.foo.rmi.RMICSSClient.info(RMICSSClient.java:89)
    ... 20 more
    Caused by: java.util.zip.ZipException: no current ZIP entry
    at java.util.zip.ZipOutputStream.write(Unknown Source)
    at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
    at java.io.BufferedOutputStream.flush(Unknown Source)
    at java.io.DataOutputStream.flush(Unknown Source)
    ... 27 more
    Can someone please assist me solving this problem?
    Thanks,
    Barak.

    I don't believe the code given in that article can possibly work. You have to call ZipOutputStream.finish() at some point for anything to be received at all, and when driven by RMI there is no well-defined point from the ZipSocket's point of view for that to be done.
    I would avoid compression altogether. It places an extra load on the client CPU, which is OK, but also on the server CPU, which is not OK. It adds latency to the calls. It saves 50% of the data space if you're lucky. You'd have to have remarkably large object parameters and results for it to be a genuine win.

Maybe you are looking for