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.

How can i connect Live account from jforex SDK 3 without Pin captcha?
 Post subject: How can i connect Live account from jforex SDK 3 without Pin captcha? Post rating: 0   New post Posted: Mon 14 May, 2018, 22:04 
User avatar

User rating: 0
Joined: Mon 24 Apr, 2017, 17:08
Posts: 1
Location: Italy, Bari
Hello, check this code:
package singlejartest;

import com.dukascopy.api.Instrument;
import com.dukascopy.api.system.ClientFactory;
import com.dukascopy.api.system.IClient;
import com.dukascopy.api.system.ISystemListener;
import java.util.HashSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Set;

/**
 * This small program demonstrates how to initialize Dukascopy client and start a strategy
 */
public class Main {
    private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);

   // private static String jnlpUrl = "https://platform.dukascopy.com/demo/jforex.jnlp";
    private static String jnlpUrl = "https://platform.dukascopy.com/live/jforex.jnlp";
    private static String userName = "myuser";
    private static String password = "mypassword";   
    private static String environment = "LIVE";

    private static IClient client;

    private static int lightReconnects = 3;

    public static void main(String[] args) throws Exception {
        //get the instance of the IClient interface
        client = ClientFactory.getDefaultInstance();

        setSystemListener();
        tryToConnect();
        subscribeToInstruments();

        LOGGER.info("Starting strategy");
//        client.startStrategy(new MA_Play());
        client.startStrategy(new miaStrategy());
        //now it's running
    }

    private static void setSystemListener() {
        //set the listener that will receive system events
        client.setSystemListener(new ISystemListener() {

           @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 = 3;
         }

         @Override
         public void onDisconnect() {
                tryToReconnect();
         }
        });
    }

    private static void tryToConnect() throws Exception {
        LOGGER.info("Connecting...");
        //connect to the server using jnlp, user name and password
        System.setProperty("jnlp.client.mode", environment);
        client.connect(jnlpUrl, userName, password);
       

        //wait for it to connect
        int i = 10; //wait max ten seconds
        while (i > 0 && !client.isConnected()) {
            Thread.sleep(1000);
            i--;
        }
        if (!client.isConnected()) {
            LOGGER.error("Failed to connect Dukascopy servers");
            System.exit(1);
        }
    }

    private static void tryToReconnect() {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                if (lightReconnects > 0) {
                    client.reconnect();
                    --lightReconnects;
                } else {
                    do {
                        try {
                            Thread.sleep(60 * 1000);
                        } catch (InterruptedException e) {
                        }
                        try {
                            if(client.isConnected()) {
                                break;
                            }
                             client.connect(jnlpUrl, userName, password);
                           

                        } catch (Exception e) {
                            LOGGER.error(e.getMessage(), e);
                        }
                    } while(!client.isConnected());
                }
            }
        };
        new Thread(runnable).start();
    }

    private static void subscribeToInstruments() {
        Set<Instrument> instruments = new HashSet<>();
        instruments.add(Instrument.EURUSD);
        LOGGER.info("Subscribing instruments...");
        client.setSubscribedInstruments(instruments);
    }
}



i have this output:
Building JForex-3-SDK 3.3.11


AuthServerResponse [response=Auth failed, responseCode=801, headerFields={Transfer-Encoding=[chunked], null=[HTTP/1.1 801], CF-RAY=[41b01e2c3ead0e2a-MXP], Server=[cloudflare], Connection=[keep-alive], Pragma=[no-cache], Last-Modified=[Mon, 14 May 2018 20:29:36 GMT], StatusCode=[801], Date=[Mon, 14 May 2018 20:29:36 GMT], StatusMessage=[Auth failed], Cache-Control=[no-cache, must-revalidate, no-store, max-age=0], Access-Control-Allow-Credentials=[true], Set-Cookie=[__cfduid=dc298ad65cf37b2ad05f8a26aa36a8bc31526329776; expires=Tue, 14-May-19 20:29:36 GMT; path=/; domain=.dukascopy.com; HttpOnly], Expires=[Thu, 01 Jan 1970 00:00:00 GMT], Content-Language=[en], Expect-CT=[max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"], Content-Type=[text/html;charset=UTF-8]}]
   at com.dukascopy.auth.client.transport.http.HttpAuthTransport.makeServerRequest(HttpAuthTransport.java:109)
   at com.dukascopy.auth.client.protocol.AbstractSRPClientProtocol.performStep1(AbstractSRPClientProtocol.java:171)
   at com.dukascopy.auth.client.SRPAuthClient.step1(SRPAuthClient.java:213)
   at com.dukascopy.auth.client.SRPAuthClient.authenticate(SRPAuthClient.java:62)
   at com.dukascopy.api.impl.connect.AuthorizationClient.getAPIsAndTicketUsingLogin_SRP6(AuthorizationClient.java:964)
   at com.dukascopy.api.impl.connect.AuthorizationClient.getAPIsAndTicketUsingLogin_SRP6(AuthorizationClient.java:783)
   at com.dukascopy.api.impl.connect.DCClientImpl.authenticate(DCClientImpl.java:557)
   at com.dukascopy.api.impl.connect.DCClientImpl.connect(DCClientImpl.java:339)
   at com.dukascopy.api.impl.connect.DCClientImpl.connect(DCClientImpl.java:329)
   at singlejartest.Main.tryToConnect(Main.java:107)
   at singlejartest.Main.main(Main.java:64)
Exception in thread "main" com.dukascopy.api.system.JFAuthenticationException: Incorrect username or password
2018-05-14 22:29:37.655 DEBUG DCClientImpl -
   at com.dukascopy.api.impl.connect.DCClientImpl.authenticate(DCClientImpl.java:603)
   at com.dukascopy.api.impl.connect.DCClientImpl.connect(DCClientImpl.java:339)
   at com.dukascopy.api.impl.connect.DCClientImpl.connect(DCClientImpl.java:329)
   at singlejartest.Main.tryToConnect(Main.java:107)
   at singlejartest.Main.main(Main.java:64)



 
 Post subject: Re: How can i connect Live account from jforex SDK 3 without Pin captcha? Post rating: 0   New post Posted: Thu 17 May, 2018, 16:35 
Visual JForex expert at Dukascopy
User avatar

User rating:
Joined: Mon 22 Apr, 2013, 11:30
Posts: 604
Location: UkraineUkraine
Hello.

Please check the manual for Live authorization.
https://www.dukascopy.com/wiki/en/devel ... /live-mode


 

Jump to:  

cron
  © 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