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 to solve this connection error when making the connection to the Dukascopy trading server?
 Post subject: how to solve this connection error when making the connection to the Dukascopy trading server? Post rating: 0   New post Posted: Thu 13 Jan, 2022, 13:06 

User rating: 0
Joined: Sat 12 Sep, 2020, 11:10
Posts: 3
Location: ChinaChina
I am trying to login to the Dukascopy trading server using the Demo accoout.Relativelly,it is the demo server of Dukascopy.The server address is "https://platform.dukascopy.com/demo/jforex.jnlp".But during the connection,some timeout error occurs.

here is my code,I am using IDEA for java develpment :

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

private static final String jnlpUrl = "https://platform.dukascopy.com/demo/jforex.jnlp";
private static final String userName = "myname";
private static final String password = "mypasswd";

private static final String proxyHost = "127.0.0.1";
private static final String proxyPort = "1234";

private static IClient client;

private static int lightReconnects = 3;

public static void main(String[] args) throws Exception {

System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", proxyHost);
System.setProperty("http.proxyPort", proxyPort);

//get the instance of the IClient interface
client = ClientFactory.getDefaultInstance();

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

LOGGER.info("Starting strategy");
//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
client.connect(jnlpUrl, userName, password);

//wait for it to connect
int i = 100; //wait max 100 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);
}
}




here is the error :
2022-01-13 19:55:29.348 INFO Main - Connecting...
2022-01-13 19:55:31.271 INFO AuthorizationClient - environment(jnlp.client.mode)=DEMO, platformInstanceId=null
2022-01-13 19:55:31.318 INFO AuthorizationClient - Auth step 1 request [6DFE0780E1AD2737473A98E8CC09591E4255D1C7]
2022-01-13 19:55:31.328 DEBUG AuthorizationClient - >> [https://login.dukascopy.com/authorization-1/demo/auth?munus=srp_api&passus=1&sermo=4bd4a27c-97b5-42b4-a60c-b1f395d44bd5&putent_genus=0&appello=6DFE0780E1AD2737473A98E8CC09591E4255D1C7&obsecro_id=239f9b37-1b2f-472d-9703-a8e405c3a54d&srp_versio=1]
2022-01-13 19:55:42.743 ERROR AuthorizationClient - Connect timed out
java.net.SocketTimeoutException: Connect timed out
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:2035)
at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:2030)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:554)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:2029)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1597)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1577)
at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:527)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:308)
at com.dukascopy.auth.client.transport.http.HttpAuthTransport.makeServerRequest(HttpAuthTransport.java:82)
at com.dukascopy.auth.client.protocol.AbstractSRPClientProtocol.performStep1(AbstractSRPClientProtocol.java:175)
at com.dukascopy.auth.client.SRPAuthClient.step1(SRPAuthClient.java:220)
at com.dukascopy.auth.client.SRPAuthClient.authenticate(SRPAuthClient.java:65)
at com.dukascopy.api.impl.connect.AuthorizationClient.getAPIsAndTicketUsingLogin_SRP6(AuthorizationClient.java:1141)
at com.dukascopy.api.impl.connect.AuthorizationClient.getAPIsAndTicketUsingLogin_SRP6(AuthorizationClient.java:958)
at com.dukascopy.api.impl.connect.DCClientImpl.authenticate(DCClientImpl.java:559)
at com.dukascopy.api.impl.connect.DCClientImpl.connect(DCClientImpl.java:340)
at com.dukascopy.api.impl.connect.DCClientImpl.connect(DCClientImpl.java:330)
at myForex.main.tryToConnect(main.java:88)
at myForex.main.main(main.java:47)
Caused by: java.net.SocketTimeoutException: Connect timed out
at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:546)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:333)
at java.base/java.net.Socket.connect(Socket.java:645)
at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:290)
at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:177)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:497)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:600)
at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:265)
at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:379)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:189)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1232)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1120)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:175)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1653)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1577)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(HttpURLConnection.java:3229)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getHeaderFields(HttpsURLConnectionImpl.java:253)
at com.dukascopy.auth.client.transport.http.HttpAuthTransport.makeServerRequest(HttpAuthTransport.java:81)
... 10 more
.
.
.
.

I don't know how to solve the "java.net.SocketTimeoutException: Connect timed out" error.

The JForex SDK indicates "ERROR AuthorizationClient - Connect timed out".I am trying to find a time out param in the IClient class for extending the timeout value and I can not find one.

so I am asking for help! Can this error be solved?


 
 Post subject: Re: how to solve this connection error when making the connection to the Dukascopy trading server? Post rating: 0   New post Posted: Sun 16 Jan, 2022, 02:46 

User rating: 0
Joined: Sat 12 Sep, 2020, 11:10
Posts: 3
Location: ChinaChina
After days of figuring it out , I finally get a way to solve this error.

First of all, it occured because of the ssl certificates.

Secondly, it is no need to download the certificates individually. But another error appear,if your JDK is JDK 8.

Thirdly, jusr update the JDK to the latest version. And there no more error.The world is so quiet.

I think that mayber a bug in the low JDK version,at least lower than JDK 8.


 

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