Dukascopy
 
 
Wiki JStore Search Login

JFOREX-3312 Unable to connect to another account
 Post subject: JFOREX-3312 Unable to connect to another account Post rating: 0   New post Posted: Mon 03 Oct, 2011, 09:40 

User rating: -
These are my 2 methods for connect and disconnect. When i connect to account, disconnect and try to connect to different account platform connects to first account.

How can i connect to another account after i connected to some account? There is no disconnect method in Client.

public void connect() throws JFAuthenticationException, JFVersionException, Exception {
        if (this.isConnected()) {
            return;
        }

        this.dcClient = ClientFactory.getDefaultInstance();
        System.err.println("Dclogin " + dCLogin + " passwd" + dCPassword);
        dcClient.connect(jnlpUrl, dCLogin, dCPassword);

        int i = 10; //wait max ten seconds
        while (i > 0 && !dcClient.isConnected()) {
            Thread.sleep(1000);
            i--;
        }
        if (!dcClient.isConnected()) {
            throw new Exception("Can not connect to client. Time expired.");
        }

        Set<Instrument> setOfInstruments = new HashSet<Instrument>();
            setOfInstruments.add(Instrument.EURUSD);
            setOfInstruments.add(Instrument.NZDJPY);


            dcClient.setSubscribedInstruments(setOfInstruments);


        this.emptyStrategy = new EmptyStrategy();
        long id = dcClient.startStrategy(this.emptyStrategy);
       
        this.emptyStrategy.setId(id);
    }

public void disconnect() throws InterruptedException, Exception {
        if (!this.dcClient.getStartedStrategies().isEmpty()) {
            //stop all the strategies
        }
        this.dcClient.stopStrategy(this.emptyStrategy.getId());

        int i = 10; //wait max ten seconds
        while (i > 0 && !dcClient.isConnected()) {
            Thread.sleep(1000);
            i--;
        }

        if (!this.dcClient.getStartedStrategies().isEmpty()) {
            throw new Exception("Can not stop strategies. Time expired.");
        }
        this.dcClient = null;
        System.gc();

    }


 
 Post subject: Re: Unable to connect to another account Post rating: 0   New post Posted: Tue 04 Oct, 2011, 08:06 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
At the current implementation disconnect happens on process within which the IClient is connected. Thus, in order to connect to another account in either case you have to start a new process (i.e. java application). See if you find this example helpful:
viewtopic.php?f=65&t=35436&p=45925#p45925


 
 Post subject: Re: JFOREX-3312 Unable to connect to another account Post rating: 0   New post Posted: Wed 30 Nov, 2011, 17:05 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
2.6.51


 

Jump to:  

  © 1998-2024 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