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.