Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Timeout issues
 Post subject: Timeout issues Post rating: 0   New post Posted: Mon 25 Jul, 2011, 02:19 

User rating: 0
Joined: Thu 23 Jun, 2011, 00:33
Posts: 2
Location: NZ
Hi,

I have written an app which uses the JForex API. Everything is working fine except that I kept getting disconnected from the server after about 10-11 hours of constant connection. I am running my app from a server which is hosted in a data warehouse. So i dont think there is a connection issue between my machine and JForex platform.

Not sure how I can fix this issue. Can some one please help me with this problem. Is there something I am missing in my code when I open the connection?

Also I have a static IP for this connection which has been emailed to be added to the safe list of IP address so I can use my live account from this server. So not really sure why I would be getting disconnected every so ofter.

Thanks in advance.


 
 Post subject: Re: Timeout issues Post rating: 0   New post Posted: Mon 25 Jul, 2011, 12:29 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We are working on this issue, as a temporary solution consider adding an ISystemListener to your IClient instance and implement code which calls IClient.reconnect() method in onDisconnect(). You can find the reconnect() example in the following fragment of Main.java of standalone API:
      client.setSystemListener(new ISystemListener() {
         private int lightReconnects = 10;

         @Override
         public void onStart(long processId) {
            LOGGER.info("Strategy started: " + processId);
         }

         @Override
         public void onStop(long processId) {
            LOGGER.info("Strategy stopped: " + processId);
            if (client.getStartedStrategies().size() == 0) {
               System.exit(0);
            }
         }

         @Override
         public void onConnect() {
            LOGGER.info("Connected");
            lightReconnects = 10;
         }

         @Override
         public void onDisconnect() {
            LOGGER.warn("Disconnected");
            if (lightReconnects > 0) {
               LOGGER.info("TRY TO RECONNECT, reconnects left: " + lightReconnects);
               client.reconnect();
               --lightReconnects;
            } else {
               try {
                  // sleep for 5 seconds before attempting to reconnect
                  Thread.sleep(5000);
               } catch (InterruptedException e) {
                  // ignore
               }
               try {
                  client.connect(jnlpUrl, userName, password);
               } catch (Exception e) {
                  LOGGER.error(e.getMessage(), e);
               }
            }
         }
      });


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com