Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

reconnect() / connect() issue
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=16&t=57704
Page 1 of 1

Author:  ftasso [ Thu 12 Aug, 2021, 15:14 ]
Post subject:  reconnect() / connect() issue

Hello Support,
I have problem during connection lost.
I checked my code many times and I didn't found any difference then the implementation suggested in the SDK.
Sometimes connection is recovered within the 3 tryes made by calling reconnect(), after this phase I call the connect() routine and starts a infinite loop without have a recovered connection.
This accours using both demo and real account.
Please take a look at the attached log

Attachments:
JForex_connection_problem.xlsx [74.51 KiB]
Downloaded 345 times

Author:  ftasso [ Mon 13 Sep, 2021, 10:22 ]
Post subject:  Re: reconnect() / connect() issue

Hello Support,
can you please suggest something? I still have the problem.

Thank you,
Fabrizio

Author:  API Support [ Mon 27 Sep, 2021, 14:09 ]
Post subject:  Re: reconnect() / connect() issue

Greetings.

Do you have delay between connection attempts?
Looks like authorization is failed because of previous disconnect request.

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();
}

Regards.

Author:  ftasso [ Tue 28 Sep, 2021, 11:02 ]
Post subject:  Re: reconnect() / connect() issue

Hello,
I found the problem.
My application have two client instances, the first is IClient and the second is ITesterClient: IClient for running my strategies and ITesterClient for test.
I don't know if this is a correct practice.
Anyway the anomalous reconnection appear if I have connected the IClient instance (the first instance started) and not the ITesterClient instance (this make connection only at the first backtesting).
In this case works only the IClient.reconnect() call then the IClient.connect() fails with the reason AUTHORIZATION_FAILED.

Regards,
Fabrizio

  Page 1 of 1