Why am I receiving a "onConnectError" even though I was able to obtain a token?

I am trying to comsume ric with RTO websocket (java). I made some improvements, but they were not sufficient, as I am still encountering the following error. For some reason, I cannot progress beyond obtaining the token. On the Fiddler side, I can only see the process up to the point where the token is retrieved. Do you have any advice for this situation? Why do I get this error but bellow code blog runs for my request.
/**
* Called when an error occurs while attempting to connect the WebSocket.
*/
public void onConnectError(WebSocket websocket, WebSocketException e)
{
System.out.println(DateTimeStamp.getCurrentTime() + " Connect error for " + _name + ":" + e);
reconnect(websocket, false);
}
Also, Are there any examples of consuming Ric using HTTP requests instead of WebSocket? What advantages does WebSocket provide in this regard? After all, I won't be continuously receiving data; I'll only connect briefly to receive data at certain times of the day. Would WebSocket or a Java example that creates an HTTP request be more advantageous for me?
Best Answer
-
Hello @SelcukYAPICI
I am really sorry. It is my mistake. The "NameType" must be outside the "Elements" property, not the "Key" property. It means your first WebSocket JSON login request message is already valid structure, except the empty position which is a required field for the RTO/RTDS server.
{
"ID": 1,
"Domain": "Login",
"Key": {
"NameType": "AuthnToken",
"Elements": {
"AuthenticationToken": "xtsaHGRsDvQ9yy7ZUumjG5oWrtuo",
"Position": "",
"ApplicationId": "256"
}
}
}I can replicate the issue by sending an empty string with the position on the MarketPriceRdpGwClientCredAuth.java example.
You need to input non-empty position in the "<IP Address>/<Hostname>" or just "IP Adress" string format as follows:
"Position": "192.168.99.999"
"Position":"192.168.99.999/WIN-XXXX"
If you cannot get those values from the machine, you can put "127.0.0.1/net" string instead.
0
Answers
-
Hello @SelcukYAPICI,
From the logs that you have provided, I can see that your requests are being sent through the proxy server. While, your application can successfully get an authentication token, the secure websocket request is blocked. Either your proxy isn't setup to pass wss traffic, or there is a configuration issue.
I would recommend that you run your application without a debugging proxy and see if there are still connection issues.
0 -
Hi @Gurpreet,
As you mentioned, I commented out the code that enabled the requests to pass through the proxy. The logs that appear in the console are as attached below. As far as I can see, there hasn't been any change. What do you recommend?
0 -
The app is still trying to connect to wss://127.0.0.1:443/WebSocket. Since you are trying to connect to RTO, you should either use service discovery, or type in the hostname of the streaming server that is enabled for your ID.
Try to use this service discovery example without modification. It should automatically discover the right streaming server to initiate wss connection.
0 -
Hello @Gurpreet ,
As you mentioned, I followed the instructions and got a new class file. I didn't change anything inside the file. I only added the following code to run the class.
// MainClass'ın main metodunu çağırma
String[] newArgs = {
"--port", "443",
"--clientid", "GE-***********",
"--clientsecret", "****************************",
"--position", "",
"--ric", "/TRI.N",
"--service", "ELEKTRON_DD",
"--scope", "trapi.streaming.pricing.read",
"--region", "us-east-1"
};
args = newArgs;I am sending the result output as an attachment. I have only one issue left. I still couldn't receive the RIC value I sent. Where might my mistake be? Can you assist me with this?new 14.txt
0 -
I am sorry, I forget to mention. Also, I changed below code for connecting with clientid and clientsecret.
public static String clientid = "GE-***********";
public static String clientsecret = "******************************";I don't change hostname variable.
public static String port = "443";
public static String port2 = "443";
public static String hostName = "";
public static String hostName2 = "";0 -
Hello @wasin.w,
To avoid mistakes, I took the code you specified and only made the changes mentioned above, such as license information and starting the code in the main method. I didn't change anything else. In the end, the result didn't change. As you mentioned, it keeps placing "NameType" inside "Key". However, I'm not doing any processing here.
Then, to move "NameType" outside of "Key" as you suggested, I made the following changes.
/**
* Generate a login request from command line data (or defaults) and send
* Used for both the initial login and subsequent logins that send updated access tokens.
* @param authToken
* @throws JSONException
*/
private void sendLoginRequest(boolean isFirstLogin) throws JSONException {
// String loginJsonString = "{\"ID\":1,\"Domain\":\"Login\",\"Key\":{\"Elements\":{\"ApplicationId\":\"\",\"Position\":\"\",\"AuthenticationToken\":\"\"},\"NameType\":\"AuthnToken\"}}";
String loginJsonString = "{\"ID\":1,\"Domain\":\"Login\",\"NameType\":\"AuthnToken\",\"Key\":{\"Elements\":{\"ApplicationId\":\"\",\"Position\":\"\",\"AuthenticationToken\":\"\"}}}";
JSONObject loginJson = new JSONObject(loginJsonString);
loginJson.getJSONObject("Key").getJSONObject("Elements").put("AuthenticationToken", _authToken);
loginJson.getJSONObject("Key").getJSONObject("Elements").put("ApplicationId", appId);
loginJson.getJSONObject("Key").getJSONObject("Elements").put("Position", position);
_websocket.sendText(loginJson.toString());
System.out.println(DateTimeStamp.getCurrentTime() + " SENT on " + _name + ": \n" + loginJson.toString(2));
}Yes, it did move "NameType" outside of "Key", but this time it gave the following error. I’m sharing the outputs of both classes in the attachment.
0 -
Thanks @wasin.w and @Gurpreet,
First, I cancelled all the variable assignments at the beginning of the class.
public class MarketPriceRdpGwClientCredAuth {
public static String port = "443";
public static String port2 = "443";
public static String hostName = "";
public static String hostName2 = "";
public static String clientid = "";
public static String clientsecret = "";
public static String position = "";
public static String appId = "256";
public static String authUrl = "https://api.refinitiv.com/auth/oauth2/v2/token";
public static String discoveryUrl = "https://api.refinitiv.com/streaming/pricing/v1/";
public static String ric = "/TRI.N";
public static String service = "ELEKTRON_DD";
public static String scope = "trapi.streaming.pricing.read";
public static JSONObject authJson = null;
public static JSONObject serviceJson = null;
public static List<String> hostList = new LinkedList<String>();
public static List<String> backupHostList = new LinkedList<String>();
public static WebSocketFactory websocketFactory = new WebSocketFactory();
public static WebSocketSession webSocketSession1 = null;
public static WebSocketSession webSocketSession2 = null;
public static boolean hotstandby = false;
public static String region = "us-east-1";Then, I reorganized the parameters for calling the main function as follows. The position helped me a lot in this regard.
....
CommandLineParser parser = new DefaultParser();
HelpFormatter formatter = new HelpFormatter();
CommandLine cmd;
// MainClass'ın main metodunu çağırma
String[] newArgs = {
"--port", "443",
"--port", "127.0.0.1",
"--clientid", "GE-**********",
"--clientsecret", "*************",
"--position", "127.0.0.1/net",
"--ric", "/TRI.N",
"--service", "ELEKTRON_DD",
"--scope", "trapi.streaming.pricing.read",
"--region", "us-east-1",
"--app_id", "256"
};
args = newArgs;
...Thus, the issue was resolved. I can now consume the rics with RTO via Websocket."
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
- 688 Datastream
- 1.4K DSS
- 625 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
- 558 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
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 276 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 23 RDMS
- 1.9K Refinitiv Data Platform
- 695 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
- 105 UPA
- 194 TREP Infrastructure
- 229 TRKD
- 918 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 92 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛