question

Upvotes
Accepted
1 0 0 1

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


#technologywebsocketsjavarefinitiv-realtime-optimisedrefinitiv-realtime-sdk
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hello @yoavm

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?


If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.

Thanks,


AHS

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,
AHS

Upvote
Accepted
79.2k 251 52 74

@yoavm

Thank you for reaching out to us.

To connect to to RTO, please refer to the ex113_MP_SessionMgmt or ex450_MP_QueryServiceDiscovery examples.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks,

I do the same as the example, just that it takes the config from the command line arguments.

In my example, which configuration is missing?

Upvotes
79.2k 251 52 74

@yoavm

The "Host" configuration is incorrect.

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

The ex450_MP_QueryServiceDiscovery example gets the Host and Port from the service discovery.

1704684681275.png

Please compare your code with the ex450_MP_QueryServiceDiscovery example.

First, please try to run the ex450_MP_QueryServiceDiscovery example to make sure that you can connect to the server properly.


1704684681275.png (13.3 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.