RTO - connecting to websocket with provided SDK

Hi, I'm trying to use the provided SDK for RTO websockets consumer, but I'm unable to connect.

This does work when I'm using another service without the SDK, so credentials do work.

This is the code I'm trying to use real-time-streaming-consumer-example.

Here is the implementation:

@Service
public class WebSocketsManager {

private WebsocketMessageConsumer websocketMessageConsumer; // this implements OmmConsumerClient.

@PostConstruct
public void connect() {

OmmConsumerConfig config = EmaFactory.createOmmConsumerConfig();
Map configDb = EmaFactory.createMap();

serviceDiscovery = EmaFactory.createServiceEndpointDiscovery(null, "https://api.refinitiv.com/auth/oauth2/v2/token", "https://api.refinitiv.com/streaming/pricing/v1/")
connect(configDb)
consumer = EmaFactory.createOmmConsumer(config.clientId("user").clientSecret("secret..").config(configDb)

consumer.registerClient(EmaFactory.createReqMsg().serviceName("ELEKTRON_DD").name("IBM.N"), appClient);

}

public void connect(Map configDb) {

OmmConsumer consumer = null;
try {
Map elementMap = EmaFactory.createMap();
ElementList elementList = EmaFactory.createElementList();
ElementList innerElementList = EmaFactory.createElementList();

innerElementList.add(EmaFactory.createElementEntry().ascii("Channel", "Channel_1"));


// Use FileDictionary instead of ChannelDictionary as WebSocket connection has issue to download dictionary from Refinitiv Data Platform
innerElementList.add(EmaFactory.createElementEntry().ascii("Dictionary", "Dictionary_1"));

elementMap.add(EmaFactory.createMapEntry().keyAscii("Consumer_1", MapEntry.MapAction.ADD, innerElementList));
innerElementList.clear();

elementList.add(EmaFactory.createElementEntry().map("ConsumerList", elementMap));
elementMap.clear();

configDb.add(EmaFactory.createMapEntry().keyAscii("ConsumerGroup", MapEntry.MapAction.ADD, elementList));
elementList.clear();

innerElementList.add(EmaFactory.createElementEntry().ascii("ChannelType", "ChannelType::RSSL_ENCRYPTED"));


innerElementList.add(EmaFactory.createElementEntry().ascii("EncryptedProtocolType", "EncryptedProtocolType::RSSL_WEBSOCKET"));
innerElementList.add(EmaFactory.createElementEntry().ascii("WsProtocols", "tr_json2"));


innerElementList.add(EmaFactory.createElementEntry().ascii("Host", "https://api.refinitiv.com/auth/oauth2/v2/token"));
// innerElementList.add(EmaFactory.createElementEntry().ascii("Port", ""));
innerElementList.add(EmaFactory.createElementEntry().intValue("EnableSessionManagement", 1));

elementMap.add(EmaFactory.createMapEntry().keyAscii("Channel_1", MapEntry.MapAction.ADD, innerElementList));
innerElementList.clear();

elementList.add(EmaFactory.createElementEntry().map("ChannelList", elementMap));
elementMap.clear();

configDb.add(EmaFactory.createMapEntry().keyAscii("ChannelGroup", MapEntry.MapAction.ADD, elementList));
elementList.clear();



elementMap.add(EmaFactory.createMapEntry().keyAscii("Dictionary_1", MapEntry.MapAction.ADD, innerElementList));
innerElementList.clear();

elementList.add(EmaFactory.createElementEntry().map("DictionaryList", elementMap));
elementMap.clear();

configDb.add(EmaFactory.createMapEntry().keyAscii("DictionaryGroup", MapEntry.MapAction.ADD, elementList));
elementList.clear();


} catch (OmmException e) {
log.error(e.getMessage());
} finally {
if (consumer != null) consumer.uninitialize();
}




And this is the error I get:

    ClientName: ChannelCallbackClient
Severity: Warning
Text: Received ChannelDownReconnecting event on channel Channel
RsslReactor @564d9ec2
RsslChannel @ac3739d
Error Id 0
Internal sysError 0
Error Location Reactor.processWorkerEvent
Error text Error initializing channel: errorId=-1 text=Connection refused

What am I doing wrong / missing?

Thanks


Best Answer

Answers