Not getting response when message is sent successfully

It has been some time now working on integration of Refinitiv WebSocket's API and our core banking system, so far I am able to connect to the WebSocket without issues, I can as well send messages successfully, the challenge I am having is that, after I sent the message, I want to be able to log the response as we get response when testing with postman, I am not able to get that response, I find this weird because if we have an error on our request payload(Message) I am able to get that response logged and the error message of why the request does not go through. Can you maybe help me out on this? Below is the code snipet;
const connectWebSocket = async () => {
const protocol = process.env.RDP_WEBSOCKET_PROTOCOL;
const server = process.env.RDP_WEBSOCKET_SERVER;
const port = process.env.RDP_WEBSOCKET_PORT;
const securityProtocol = process.env.RDP_SEC_PROTOCOL;
try {
const RDP_WEB_SOCKET_URL = `${protocol}://${server}:${port}/WebSocket`;
const wsUrl = RDP_WEB_SOCKET_URL;
const service = process.env.REALTIME_SERVICE;
const message = {
ID: 4,
Streaming: false,
Key: {
Service: service,
Name: "LSL=",
},
};
const ws = new WebSocket(wsUrl, securityProtocol);
ws.on("open", () => {
console.log("WebSocket connection established.");
// Send your message as JSON
ws.send(JSON.stringify(message), () => {
console.log("Message sent to WebSocket server:", JSON.stringify(message));
});
});
ws.on("message", (data) => {
const message = data.toString();
try {
const parsedMessage = JSON.parse(message);
console.log("Received message from server:", parsedMessage);
} catch (error) {
console.error("Error parsing message:", error);
}
});
ws.on("close", (code, reason) => {
console.log(
`WebSocket connection closed with code ${code}. Reason: ${reason}`
);
});
ws.on("error", (error) => {
console.error("WebSocket error:", error);
});
} catch (error) {
console.error(
"Error occurred while establishing WebSocket connection:",
error
);
}
};
Best Answer
-
Hello @folokolereko
Thank you for reaching out to us. I have checked your code. I cannot find any code that sends Login message to the WebSocket server.
### Your Code ###
- Establish a WebSocket connection to ADS server.
- Establish a WebSocket connection success (OnOpen callback triggered).
- Send a snapshot request to the ADS.
Basically, the Real-Time WebSocket connection workflow is as follows:
- Establish a WebSocket connection to ADS server.
- Establish a WebSocket connection success (OnOpen callback triggered).
- Send a JSON Login request to the ADS.
- The ADS server sends a Refresh response message for the Login request back to the application.
- Once the application receive a Login Refresh response message, the application can start sending item request messages to ADS.
You can find more detail about the WebSocket API workflow from the WebSocket API tutorial page. page.
0
Answers
-
Additionally, there is the WebSocket API - deployed RTDS examples available on the GitHub repository.
Even though it uses JavaScript and different coding style, but you could apply the message flow logic to your application.
0 -
0
Categories
- All Categories
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 684 Datastream
- 1.4K DSS
- 613 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 248 ETA
- 552 WebSocket API
- 37 FX Venues
- 14 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
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 632 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
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 191 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 85 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛