Jump to content
  • 0

Java Streaming API Demo Not Returning Prices


lalittanna

Question

I'm trying to get price feed on demo account through the streaming API but its returning this server error: lightstreamer.session|pool-2-thread-1|Disconnected. Cause: 65 - Unsupported protocol version: 2.5.0

Maven dependency used:

<dependency>
  <groupId>com.lightstreamer</groupId>
  <artifactId>ls-javase-client</artifactId>
  <version>5.1.0</version>
</dependency>

Code: 
 

LightstreamerClient client = new LightstreamerClient("https://demo-apd.marketdatasystems.com", "DEMO");
ConsoleLoggerProvider mylog = new ConsoleLoggerProvider(ConsoleLogLevel.INFO);
LightstreamerClient.setLoggerProvider(mylog);
client.connectionDetails.setUser("<userId>");
client.connectionDetails.setPassword("CST-" + "389b6319947f6799bdcfbdf3fd2b5098f90dcdd8dd4ae655b4829b6047b035CC01116" + "|XST-" + "671c982d9852360a9af293fe9043fe7c86493e1eafa92b286e1dab7bd1029aCD01116");
client.connectionDetails.setAdapterSet("DEFAULT");
client.addListener(new ClientListener() {
    @Override
    public void onListenEnd() {
        System.out.println("Listening ended");
    }

    @Override
    public void onListenStart() {
        System.out.println("Listening started");
    }

    @Override
    public void onServerError(int i, @NotNull String s) {
        System.out.println("Server error: " + s);
    }

    @Override
    public void onStatusChange(@NotNull String s) {
        System.out.println("Status change: " + s);
    }

    @Override
    public void onPropertyChange(@NotNull String s) {
        System.out.println("Property change: " + s);
    }
});
String[] items = { "CS.D.EURGBP.CFD.IP" };
String[] fields = { "BID","OFFER" };
Subscription sub = new Subscription("MERGE",items,fields);
sub.setDataAdapter("QUOTE_ADAPTER");
sub.setRequestedSnapshot("yes");
sub.addListener(new SubscriptionListener() {
    @Override
    public void onClearSnapshot(String itemName, int itemPos) {
        System.out.println("Server has cleared the current status of the chat");
    }

    @Override
    public void onCommandSecondLevelItemLostUpdates(int lostUpdates, String key) {
        //not on this subscription
    }

    @Override
    public void onCommandSecondLevelSubscriptionError(int code, String message, String key) {
        //not on this subscription
    }

    @Override
    public void onEndOfSnapshot(String arg0, int arg1) {
        System.out.println("Snapshot is now fully received, from now on only real-time messages will be received");
    }

    @Override
    public void onItemLostUpdates(String itemName, int itemPos, int lostUpdates) {
        System.out.println(lostUpdates + " messages were lost");
    }

    @Override
    public void onItemUpdate(ItemUpdate update) {

        System.out.println("====UPDATE====> " + update.getItemName());
        System.out.println(update.getValue("BID"));
        System.out.println(update.getValue("OFFER"));

        System.out.println("<====UPDATE====");
    }

    @Override
    public void onListenEnd() {
        System.out.println("Stop listeneing to subscription events");
    }

    @Override
    public void onListenStart() {
        System.out.println("Start listeneing to subscription events");
    }

    @Override
    public void onSubscription() {
        System.out.println("Now subscribed to the chat item, messages will now start coming in");
    }

    @Override
    public void onSubscriptionError(int code, String message) {
        System.out.println("Cannot subscribe because of error " + code + ": " + message);
    }

    @Override
    public void onUnsubscription() {
        System.out.println("Now unsubscribed from chat item, no more messages will be received");
    }

    @Override
    public void onRealMaxFrequency(String frequency) {
        System.out.println("Frequency is " + frequency);
    }

});
client.subscribe(sub);
client.connect();
Link to comment

3 answers to this question

Recommended Posts

  • 0
11 hours ago, lalittanna said:

I'm trying to get price feed on demo account through the streaming API but its returning this server error: lightstreamer.session|pool-2-thread-1|Disconnected. Cause: 65 - Unsupported protocol version: 2.5.0

Maven dependency used:

<dependency>
  <groupId>com.lightstreamer</groupId>
  <artifactId>ls-javase-client</artifactId>
  <version>5.1.0</version>
</dependency>

Code: 
 

LightstreamerClient client = new LightstreamerClient("https://demo-apd.marketdatasystems.com", "DEMO");
ConsoleLoggerProvider mylog = new ConsoleLoggerProvider(ConsoleLogLevel.INFO);
LightstreamerClient.setLoggerProvider(mylog);
client.connectionDetails.setUser("<userId>");
client.connectionDetails.setPassword("CST-" + "389b6319947f6799bdcfbdf3fd2b5098f90dcdd8dd4ae655b4829b6047b035CC01116" + "|XST-" + "671c982d9852360a9af293fe9043fe7c86493e1eafa92b286e1dab7bd1029aCD01116");
client.connectionDetails.setAdapterSet("DEFAULT");
client.addListener(new ClientListener() {
    @Override
    public void onListenEnd() {
        System.out.println("Listening ended");
    }

    @Override
    public void onListenStart() {
        System.out.println("Listening started");
    }

    @Override
    public void onServerError(int i, @NotNull String s) {
        System.out.println("Server error: " + s);
    }

    @Override
    public void onStatusChange(@NotNull String s) {
        System.out.println("Status change: " + s);
    }

    @Override
    public void onPropertyChange(@NotNull String s) {
        System.out.println("Property change: " + s);
    }
});
String[] items = { "CS.D.EURGBP.CFD.IP" };
String[] fields = { "BID","OFFER" };
Subscription sub = new Subscription("MERGE",items,fields);
sub.setDataAdapter("QUOTE_ADAPTER");
sub.setRequestedSnapshot("yes");
sub.addListener(new SubscriptionListener() {
    @Override
    public void onClearSnapshot(String itemName, int itemPos) {
        System.out.println("Server has cleared the current status of the chat");
    }

    @Override
    public void onCommandSecondLevelItemLostUpdates(int lostUpdates, String key) {
        //not on this subscription
    }

    @Override
    public void onCommandSecondLevelSubscriptionError(int code, String message, String key) {
        //not on this subscription
    }

    @Override
    public void onEndOfSnapshot(String arg0, int arg1) {
        System.out.println("Snapshot is now fully received, from now on only real-time messages will be received");
    }

    @Override
    public void onItemLostUpdates(String itemName, int itemPos, int lostUpdates) {
        System.out.println(lostUpdates + " messages were lost");
    }

    @Override
    public void onItemUpdate(ItemUpdate update) {

        System.out.println("====UPDATE====> " + update.getItemName());
        System.out.println(update.getValue("BID"));
        System.out.println(update.getValue("OFFER"));

        System.out.println("<====UPDATE====");
    }

    @Override
    public void onListenEnd() {
        System.out.println("Stop listeneing to subscription events");
    }

    @Override
    public void onListenStart() {
        System.out.println("Start listeneing to subscription events");
    }

    @Override
    public void onSubscription() {
        System.out.println("Now subscribed to the chat item, messages will now start coming in");
    }

    @Override
    public void onSubscriptionError(int code, String message) {
        System.out.println("Cannot subscribe because of error " + code + ": " + message);
    }

    @Override
    public void onUnsubscription() {
        System.out.println("Now unsubscribed from chat item, no more messages will be received");
    }

    @Override
    public void onRealMaxFrequency(String frequency) {
        System.out.println("Frequency is " + frequency);
    }

});
client.subscribe(sub);
client.connect();

Dear @lalittanna,

Thank you for reaching out! I apologize for any inconvenience, but we do not offer programming support. However, you can test the API using our API companion at this link: API Companion

Thanks,

KoketsoIG 

- KoketsoIG

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • image.png

  • Posts

    • Hi KoketsoIG, Thank you for the clarification on that. Cheers
    • Dear @millennium_falcon, Hey there! Thank you for reaching out. Just a heads-up, you can only have one API key for each environment, either live or demo. No third API key can be created.  Thanks, KoketsoIG
    • To clarify my understanding. From my Usecase, I have three separate programs all operating interdependently from one another. A program to subscribe to tic data on a number of Epics via the LightStream API, another to grab historic on a number of Epics via the REST API, and finally another to manage positions via the REST API. I need to do this on my demo account initially to get API code stabilized. The IG website specifically says that I need separate API key for each distinct program connecting to IG over REST or LightStream. So in my understanding it looks like I need three API keys all for the demo account. Am I missing something or have I misunderstood how to use these API keys? I am aware of the API request limits and this is why I assumed you need a key per program. Currently I have one API key for the demo account and cannot seem to add more keys to the demo account? I have looked at the FAQ and cannot see an answer for my query.
×
×
  • Create New...
us