Disconnecting

Disconnect messages in strategies are suitable for informational purposes only. Disconnect message from the server occurs because of network issues.

To monitor connection status in the strategy the following code can be used in the onMessage method:

if(message.getType()== IMessage.Type.CONNECTION_STATUS) {
     // Some code here
}

If standalone JForex API application is used, use the IClient.setSystemListener method for setting a listener to receive disconnects. When the disconnect() method of the listener is called, the strategy has to try calling reconnect one time. If it receives a disconnect message again without getting a connected() method call, it has to try calling IClient.connect which will try to proceed full reconnecting with re-authentication. The reconnect() method is faster, but programmers can skip it and always call connect().

In the platform, there is no need for disconnects management. The platform manages disconnects and reconnects.

The information on this web site is provided only as general information, which may be incomplete or outdated. Click here for full disclaimer.