Jump to content
mikemedved

Trying out lightstreamer connection to forex.com

Recommended Posts

I am trying out Lightstreamer connection - in C# using the Lightstreamer PCL C# code.

 

Code: (sUsername and sPass are set to user name and password that work fine when logging into AdvantageTrader)

 

            var client = new LSClient();
            var info = new ConnectionInfo();
            info.PushServerUrl = "https://push.cityindex.com/";  // tried "https://pushpreprod.cityindextest9.co.uk"; as well, same result
            info.User = sUserName;
            info.Password = sPass;
            info.Adapter = "STREAMINGALL";
            client.OpenConnection(info, listen);

 

Am getting exception:  "User/password check failed"

 

help?
 

Share this post


Link to post

Hi,

 

When subscribing to the real time price streams, the Session ID is used as the password. (Your username remains the username you normally use.)

 

A Session token is created by submitting your account credentials (UserName and Password) together with API Key to the LogOn service method.

 

 

That should resolve the UN/PW check failure message.

 

Cordially,

PM!

Share this post


Link to post

Hi,

Quick check - are you using a demo account or a Live account? If it is a demo account, are you able to login to any of the trading platforms with it? It's possible that your demo account has expired as demo accounts are time limited.

Kind Regards,PM

Share this post


Link to post

Yes it's a demo account, it's a new demo account of about less than a week old - never used this account for streaming, it does work when logging into the trading platform.

And in fact, it even works in the application at all API connections where I actually get a valid Session Key, but at the streaming with LightStreamer Client (using my username and password-sessionToken) it doesn't work.

Here is my code if it can help (probably not helpful because it's exact same I used with another account a week/2 ago and it worked then):

ConnectionInfo connectionInfo = new ConnectionInfo
    {
        PushServerUrl = "https://push.cityindex.com", // "https://pushpreprod.cityindextest9.co.uk", // tried both urls
        Adapter = "STREAMINGALL" // "CITYINDEXSTREAMINGDEFAULTPRICES"
    };

    connectionInfo.User = username; // tried both - my 'username' and 'username code'
    connectionInfo.Password = password; // SessionToken

LSClient lightStreamClient = new LSClient();
lightStreamClient.OpenConnection(connectionInfo, new MyConnectionListener());

Here you can take a look at my Visual Studio debugger properties:
ConnectionInfo:
https://t.me/attatchments/4
exception:
https://t.me/attatchments/5

Share this post


Link to post

Hi,

I've asked our API team to look into it.

From my checks Lightstreamer is working normally, and you stated that you can see prices working when you login with your account to a trading platform. Our trading platforms use the same API so your account is working at least on our platforms.

I'll post a reply as soon as I receive one from the team. Thank you for your patience.

Kind Regards, PM

Share this post


Link to post

Hi Again,

Our devs have asked if you could send me a PM with your demo account credentials as they are going to investigate your exact case/account.

Additionally, when it was working last week were you using the Live or Preprod URL? When accounts are created, they will be created for one environment and will only work with that environment. A Live account won't work with Preprod or vice versa so we need to investigate in the correct environment for your account. 

Many thanks, PM

Share this post


Link to post

UPDATE:

The reason was, in my application I was Authorizing the Session twice, Once at the start of the application where I save the returned SessionToken into a variable, then I Authorize again without replacing the variable with the newly returned SessionToken, so when I connected using the already revoked SessionToken, it failed.

 

Thanks for all your help!

Share this post


Link to post

Hi, I'm trying out Lightstreamer connection in Java using ls-client from the Lightstreamer 5.1.2 (Legacy) package.

Here is my code:

LSClient lsc = new LSClient();
ConnectionInfo ci = new ConnectionInfo();
ci.adapter = "STREAMINGALL";
ci.pushServerUrl = "https://push.cityindex.com";  // tried "https://push1.cityindex.com" but it doesn't work too
ci.password = sessionId;
ci.user = username;
lsc.openConnection(ci, connectionListener);

But every time my session doesn't open (connectionListener.onSessionStarted gets false). Here is my log (connectionListener just logs events):

Connection Established...
Session Started: false

On my Demo account at webtrading2.forex.com I get all chart and broker prices. Don't know if it's important but here are logs from Chrome Developer's Tool Console about lightstreamer connections:

WebSocket connection to 'wss://push.cityindex.com/lightstreamer' failed: WebSocket is closed before the connection is established.
CONNECTED:STREAM-SENSING
WebSocket connection to 'wss://push1.cityindex.com/lightstreamer' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET
CONNECTED:HTTP-STREAMING

 

Share this post


Link to post

Hi,

I took a look at the Lightstreamer Network Protocol focument for the LS 5.1.2 package that you are using: Lightstreamer Network Protocol. This version of the client doesn't appear to support Websockets If I'm reading the file correctly.

You could ask on the Lightstreamer forum at https://forums.lightstreamer.com/ to see if you can obtain further information.

Kind Regards, PM

Share this post


Link to post

But how does webtrading2.forex.com get prices from your lightstreamer server? 

And in my code I use default openConnection method (which works on HTTP, if I'm not mistaken). You said in other topics that your server only works with LS 5.1.2 client, so there should be some way to connect to it.

Share this post


Link to post

We use HTTP(S) TCP to connect to the streaming servers. 

WebSocket is a different TCP than HTTP. If I interpreted the Lighstreamer documentation correctly, LS 5.1.2. only supports HTTP(S) and that is why your WebSockets connection is failing. 

Kind Regards, PM    

Share this post


Link to post

Sorry, I guess I didn't clearly express my issue. Logs about Websockets failing has nothing to do with my application, these messages are from webtrading2.forex.com and I just thought they can be useful.

My problem is that I can't open session with LS server in my Java application.

Share this post


Link to post

Hi Vitjaz,

Apologies for the confusion - we understand the problem now.

@MayerSpitz: Thank you for the helpful suggestion about the LS Java library. 

Following on from that, @Vitjaz do you have code lines that are performing the subscription to market prices as an example? 

Kind Regards, PM 

Share this post


Link to post

 

Mayerspitz, thanks, I tried it, but had the same result as here:

 

@Physicsman I finally solve the problem. I'll leave here working subscription, just in case somebody will need it. I still don't understand why I get "false" on starting session connection but I guess it was correct behavior.

ExtendedTableInfo sub = new ExtendedTableInfo(new String[]{"PRICE."+marketId}, "MERGE",
                    new String[]{"MarketId", "TickDate", "Bid", "Offer", "Price", "High", "Low", "Change", "Direction", "Delta", "ImpliedVolatility", "AuditId", "StatusSummary"}, true);
sub.setDataAdapter("PRICES");
lsc.subscribeItems(sub, handyTableListener);

 

Share this post


Link to post

 Hi,

I'm using the LightStreamer.DotNet.Client from NUGET to connect but receive the error 'Requested Adapter Set not available'.  This may be a very silly question, but can I use the NUGET package to connect to https://push.cityindex.com without installing the full Lightstreamer server, or do I also need to run the Lightstreamer server (nssm_x64.exe) locally on my machine to make the connection.  I am running windows 10.  Currently, I am not running the Lightstreamer server locally for my understanding is that I would be connecting to the one at https://push.cityindex.com.

Also, I have been attempting my test while the market is closed (e.g. on Saturday) - could this error be related to the fact that there is no data to stream given that the market is closed?

My Connection code in C# is as follows:

ConnectionInfo info = new ConnectionInfo();
info.PushServerUrl = "https://push.cityindex.com"
info.User = sUserName;
info.Password = sSessionId;
info.Adapter = "STREAMINGCALL"

LSClient client = new LSClient();
client.OpenConnection(info, listener); <-- receives 'Requested Adapter Set not available'.

Ultimately, I am trying to get the live pricing stream connected.  Any help would be appreciated.  Do you know of a link that shows a C# example of getting the LightStreamer connected using the nuget package to receive price updates?

Regards.

Share this post


Link to post

Hi,

I've just checked and it NUGET is downloading the latest Lightstreamer .NET client for LS version 7. However, our servers are still using the older LS 5.1.2 version, which is incompatible with the latest LS 7 client.

Please download the .NET client SDK for LS 5 from https://lightstreamer.com/download/#ls5 and this should resolve the error message you are seeing.

Kind Regards, PM 

Share this post


Link to post

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
×