Create "AuthorizationAgent" returns "AuthorizationConnection.CONNECTION_DOWN" state
Hi, I am writing some DACS API tests by following the java examples. Each test case creates a daemon connection, does something, then close the connection. All tests pass if I run them manually. But only the first test works if I run them together in a group. I did a lot debugging and found starting from the second test case, the agent.daemonConnectionState() is always "CONNECTION_DOWN" immediately after calling "createAuthorizationAgent". So the while loop checking for State "CONNECTION_PENDING" never gets executed. I feel like I might miss something when closing the daemonConnection of the first test case so the second tests (and others) never work. Interestingly, if I add a delay, then State will become "CONNECTION_PENDING". But we don't think this is a proper fix. Here is the snippet from my second test case. Thanks
// Create AuthorizationAgent
authorizationAgent = authorizationSystem.createAuthorizationAgent(_authorizationAgentName,true);
//The following line print the State is equal to "CONNECTION_DOWN"
//logger.info("Demon connection state is " + authorizationAgent.daemonConnectionState().toString());
//Thread.sleep(50) --> however if this delay is enabled, then the following State would work
while (authorizationAgent.daemonConnectionState() != AuthorizationConnection.CONNECTION_PENDING) {
try {
if (authorizationAgent.daemonConnectionState() == AuthorizationConnection.CONNECTION_UP) {
logger.info("Demon connection state is UP: " + authorizationAgent.daemonConnectionState().toString() );
}
else if (authorizationAgent.daemonConnectionState() == AuthorizationConnection.CONNECTION_DOWN) {
logger.info("Demon connection state is DOWN: " + authorizationAgent.daemonConnectionState().toString());
}
else if (authorizationAgent.daemonConnectionState() == AuthorizationConnection.CONNECTION_PENDING) {
logger.info("Demon connection state is CONNECTION_PENDING: " + authorizationAgent.daemonConnectionState().toString());
}
else {
logger.info("Demon connection state is UNKNOWN: " + authorizationAgent.daemonConnectionState().toString());
}
Thread.sleep(1);
}
Best Answer
-
Hello @tsun,
You should be able to reconnect when it's broken, just not repeatedly and unlimited number of times. When the connection is up, you should be able to issue requests. To test this capability, you can use the subscription test example from SDK, modifying it like so (just for the capability test):
for(int i = 0; i < 10; i++) { //tight loop
DacsSubscribeClient client = null;
try {
client = new DacsSubscribeClient(daemonHost, serviceName, name, position, application, usage, reqtype);
client.openDaemonConnection("DACS", "dacsSubscribeClient", true);
client.login();
// Wait for processing event queue dispatching.
client.waitForCallBackEvent(waitTime);
client.checkSubscribePermission(itemName, peList, enableOndemand);
// Again, wait for processing event queue dispatching.
client.waitForCallBackEvent(waitTime);
client.logout();
} catch (Exception ex) {
// Other unexpected exception occurs.
System.err.print("DacsSubscribeClient failed ");
if (ex.getMessage() != null && ex.getMessage().trim().length() != 0) {
System.err.print(ex.getMessage()); }
System.out.println();
} finally {
if (client != null) {
client.closeDaemonConnection(true);
}
}The result you should get is that you will be able to reconnect when DACS is ready, not in a tight loop, similar to mine:
Output:
[host:port] Daemon connection state is UP
[] Daemon connection opened
[] radmin logged in
[] Subscriber has been logged in
[] radmin allowed subscription access to item IBM.N
[] radmin logged out
[] Daemon connection closed
[] Daemon connection state is DOWN
[] Daemon connection closed
[] Daemon connection state is UP
[] Daemon connection opened
[] radmin logged in
[] Subscriber has been logged in
[] radmin allowed subscription access to item IBM.N
[] radmin logged out
[] Daemon connection closed
[] Daemon connection state is DOWN
[] Daemon connection closed
[] Acquire AuthorizationSystem failed
[] Daemon connection state is DOWN
[] Daemon connection closed
[] Daemon connection state is DOWN
[] Daemon connection closed
[] Daemon connection state is DOWN
[] Daemon connection closed
[] Daemon connection state is UP
[] Daemon connection opened
[] radmin logged in
[] Subscriber has been logged in
[] radmin allowed subscription access to item IBM.N
[] radmin logged out
[] Daemon connection closedPlease note, we do not recommend reconnecting repeatedly without the need, this modification can be is for the development and test phase, the way to verify the reconnect working.
0
Answers
-
Hello @tsun,
You should be able to create connection to daemon, issue request, tear it down, then repeat. There can not be unlimited number of those connections, still there should be more then one permitted by DACs to complete before they start to fail.
I am just wondering, instead, can you issue the requests without creating and destroying the connection? That would be more efficient, I modified the Java subscribe example from the toolkit to make repeated checkSubscribePermission() calls:
client.login();
for(int i = 0; i < 1000; i++) {
// Wait for processing event queue dispatching.
client.waitForCallBackEvent(waitTime);
client.checkSubscribePermission(itemName, peList, enableOndemand);
// Again, wait for processing event queue dispatching.
client.waitForCallBackEvent(waitTime);
}
client.logout();it resulted in positive responses
...
allowed subscription access to item IBM.N
allowed subscription access to item IBM.N
allowed subscription access to item IBM.N
...Calls do not have to be the same, just simpler to create multiples this way.
0 -
Thanks. It's fine to keep the only connection open in our unit tests, but the real concerns is what happens if the connection is broken, and we cannot re-connect in the real time fashion for our production? Could you please finding out what we should expect in term of connection STATE check whenever we are in the need to re-connect? Seems to us CONNECTION_DOWN is always returned first during the re-creating.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 690 Datastream
- 1.4K DSS
- 629 Eikon COM
- 5.2K Eikon Data APIs
- 11 Electronic Trading
- 1 Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 255 ETA
- 559 WebSocket API
- 39 FX Venues
- 15 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 25 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 279 Open PermID
- 45 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 23 RDMS
- 2K Refinitiv Data Platform
- 716 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 106 UPA
- 194 TREP Infrastructure
- 229 TRKD
- 918 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 95 Workspace SDK
- 11 Element Framework
- 5 Grid
- 19 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛