For a deeper look into our Elektron API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 0 1

API problem at KR-Mirae Aseet Daewoo

Hi.

One of client has API issue and I am not familiar with API.. Could anyone check and give guide?


While configuring with Sample, client had the issue (below is sample and client's comment)

-------------------------------------------------------------------------------------------------------

try {
// Connect to Refinitiv Data Platform and authenticate (using our username and password)
authJson = getAuthenticationInfo(null); => Token created(New)
if (authJson == null)
System.exit(1);

// Determine when the access token expires. We will re-authenticate before then.
int expireTime = Integer.parseInt(authJson.getString("expires_in")); => Looks expired Token every 10mins
server = String.format("wss://%s:%s/WebSocket", hostname, port);
System.out.println("Connecting to WebSocket " + server + " ...");
ws = connect(); => WebSocket connects, Refinitiv data could be retrieved

while(true) {
// Continue using current token until 90% of initial time before it expires.

// The value 900 means 90% of expireTime in milliseconds
Thread.sleep(expireTime * 900); => 600*900=540000ms=5400sec=90min, sleep for 90min

While this period, socket was closed and connection was terminated due to Token was expired (Deleted 'sleep' because of this issue)

// Connect to Refinitiv Data Platform and re-authenticate, using the refresh token provided in the previous response
authJson = getAuthenticationInfo(authJson); => Verifying Token(Looks checking existing Toketn) but, no changed. Aslo, due time was not reduced. Looks meaningless to check
if (authJson == null)
System.exit(1);

// If expiration time returned by refresh request is less then initial expiration time,
// re-authenticate using password
int refreshingExpireTime = Integer.parseInt(authJson.getString("expires_in"));
if (refreshingExpireTime != expireTime) { => Always 600=600, In short, do not go 'if' query
System.out.println("expire time changed from " + expireTime + " sec to " + refreshingExpireTime +
" sec; retry with password");
authJson = getAuthenticationInfo(null);
if (authJson == null)
System.exit(1);
expireTime = Integer.parseInt(authJson.getString("expires_in"));
}

// Send the updated access token over the WebSocket.
sendLoginRequest(ws, authJson.getString("access_token"), false); => Login Failed : Login rejected. Already Pending login. Error happened
}
} catch (IOException e) {
e.printStackTrace();
} catch (WebSocketException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}

-------------------------------------------------------------------------------------------------------

So, client asked below

"Client original query"

Related with previou isuse, they modified by themselves, so, when failed login, if tihs is caused by expiring, it forcely re-create token.

> But, in result, Token is re-created every 10 mins with message token has expired.

> And they found Websocket also closed continuously.

> So, they checked by "WebSocket.getState()", if it is not OPEN, connect newly by ws = connect();

> And if do this, below issue happened again.

b

Need to check why token is expired, why WebSocket is disconnected.


And for this, guided "
https://community.developers.refinitiv.com/questions/80491/rto-disconnect-with-ema-java.html " to set logs for detail information


And now, client asked again below.

1. Create the logging.properties file with the following content in the working directory

"What is working directory? Directory which is .java file located? or Directory which is lib files imprted?"

2. Add the XmlTraceToStdout configuration to the Consumer in the EmaConfig.xml. The following example adds the XmlTraceToStdout configuration to the Consumer_4 which is used to connect to RTO.

"Where is EmaConfig.xml file located?"

"As below Sample, called java by importing lib. Dont't use this .xml"

(Sample1) https://github.com/Refinitiv/websocket-api/tree/master/Applications/Examples/RDP


In short,

Solution for : Authentication server did not contail "active" in responseo

is best and if need more information, could help how to set below?

"And now, client asked again below.

1. Create the logging.properties file with the following content in the working directory

"What is working directory? Directory which is .java file located? or Directory which is lib files imprted?"

2. Add the XmlTraceToStdout configuration to the Consumer in the EmaConfig.xml. The following example adds the XmlTraceToStdout configuration to the Consumer_4 which is used to connect to RTO.

"Where is EmaConfig.xml file located?"

"As below Sample, called java by importing lib. Dont't use this .xml"

(Sample1) https://github.com/Refinitiv/websocket-api/tree/master/Applications/Examples/RDP"


Many Thanks.


api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
11.5k 16 7 10

Hello @junggil.park1

Based on the given information, the client is using the WebSocket API, not the RTSDK/EMA Java API, and the code is based on the RTO WebSocket API - MarketPriceRdpGwServiceDiscovery example. If so, the application does not use the EmaConfig.xml and the logging.properties files. The application needs to log all HTTP Rest and WebSocket JSON messages by itself.

Please be informed that the RTO uses RDP authentication. The authentication token (access token) is a short-lived token that always expires every "expires_in" seconds. When the RDP access token expires, the RTO WebSocket server cuts the connection. You can keep the WebSocket connection alive via the following steps:

  1. Re-authenticate with the RDP using a refresh token before token expiration to get a new token
  2. Re-issue login request to the RTO WebSocket server with a new access token before token expiration to keep session open.

The other important thing is you need to send a Pong message back to the server if the server sends a Ping message to the application. These ping-pong messages act as a heartbeat mechanism between the client and server. I suggest the client runs the RTO MarketPriceGrdpGwServiceDiscovery example (https://github.com/Refinitiv/websocket-api/blob/master/Applications/Examples/RDP/java/MarketPriceRdpGwServiceDiscovery.java) "as is" to see the RDP/RTO behavior in detail.

Additionally, the client can find more detail regarding the RTO Token behavior from the following resources:




icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea