Jump to content
Dante

LightStreamer Login Problems

Recommended Posts

Hello,

I'm having some problems with logging into lightStreamer. The error I'm getting is "User/password check failed"

Currently, I'm using  NodeJS to attempt to get data from the lightstreamer API but I have been unable to do so. Based on the posts from others and the Forex documentation, here is what I have checked for:

  • Forex uses 5.1.2 of lightstreamer server so I had to use an older version of the Node JS client to be compatible ( version  6.1.4 specifically) 
  • The username is the one we use for the REST API
  • The password is the one that is requested upon login to the rest API.
  • I'm able to login to the REST API without any problems. 

I'm I missing anything here? Please take a look at my snippet of code and let me know if anything stands out.

Thanks

var ls = require("lightstreamer-client");

var lsClient = new ls.LightstreamerClient("https://push.cityindex.com", "STREAMINGALL");
lsClient.connectionDetails.setUser = "<Username>";
lsClient.connectionDetails.setPassword = "<Password Hash>";
lsClient.connect();

marketId = "401484317";

var testSubscription = new ls.Subscription("MERGE", ["PRICE." + marketId], ["MarketId", "TickDate", "Bid"]);
testSubscription.setDataAdapter("PRICES");
//testSubscription.setItems(["PRICES.PRICE" + marketId]);
testSubscription.setRequestedSnapshot("yes");
lsClient.subscribe(testSubscription);

lsClient.addListener({
    onStatusChange: function (newStatus) {
        console.log(newStatus);
    },

    onServerError: function (errorCode, errorMessage) {
        console.log(errorCode);
        console.log(errorMessage);
    }

});

 

Share this post


Link to post

Hi Physicsman,

My apologies for the confusion. I'm aware that the password is the Session ID, that is what I was referring to when I wrote <Password Hash> in the code. The response from the server after logging in to the REST API is a hash string (I think your documentation calls it a random string).  I should have done a better job explaining it. To my understanding, the same session ID that is used in the REST API while the session is active, should also be used for light streamer. Is that correct?

If I'm correct do you know of anything else I could be missing?

Thanks,

Dante

Share this post


Link to post

Hi Dante,

Thank you for the clarification. To confirm, you are using the Node.Js adapter SDK version downloaded from https://lightstreamer.com/download/#ls5? This is the version that is compatible with the older Lightstreamer 5.1.2 that we are using. 

Do you use the Chrome Postman API extension for your API development testing? I'd like to see if your account is able to connect to the LS server so then we can narrow down the issue to your code. If you can't connect using Postman then we know the issue is probably not in your code.

If you could try something similar to the following screenshot to test connection but using your account credentials and sessionID as password. If it connects, and you see the Loading... message and then appears to hang, that actually means you have a successful connection. What is happening is you've opened a streaming connection to the server and the connection is being kept open by the server, which is why your request appears to hang.

image.png

Share this post


Link to post

Hello Physicsman

I actually got my lightstreamer client from NPM here: (https://www.npmjs.com/package/lightstreamer-client/v/6.1.4).  I did not realize that the official website also had the library as well, that is very good to know.

I'm starting to think there is a problem with my account. I followed your instructions for using postman and now it's complaining about adapters. Attached is a screenshot.

Thanks

image.thumb.png.84ca5dc70824aa7d1ee927b878eab9d1.png

Share this post


Link to post

Hi,

Are you using a demo / test account or a Live real money account?

ONLY if you have a demo  / test account, please send me a private message with your account login credentials and I can investigate further with that account.

Many thanks, PM

Share this post


Link to post

Hi Dante,

Many thanks for sending across the account details. I think we're making progress. I've double checked your account using 2 separate methods and can connect to LS without any problems. 

First check is in Postman, I perform a login to the REST API with the account credentials and receive back the SessionID. I take that SessionID and use that along with your username to authenticate and login to LS. I successfully connect an open a streaming connection to the server. 

The second check to see if your account can connect to LS, is to login on our web platform and see if it can subscribe to LS and receive live streaming prices. All of our platforms use our API so if your account is fine it will connect and receive prices on our platforms (through the API). I confirmed it was working this way too.

Immediately prior to the attempt at authenticating with LS in your code, did you login to the REST API and retrieve a valid SessionID? I think you might be receiving the "user/password failed" error message because the SessionID you are using is no longer valid. 

Kind Regards, PM

Share this post


Link to post

Hello Physicsman

It Looks like you are correct its not a login problem. The session ID that I'm using was not the problem either. Typically when I'm testing for lightstreamer the session ID is only a minute or two old. The documentation says it should be good for a minimum of 20 mins as I recall. The reason why it failed to connect in the last post is that I did not use the POST method I used GET. After changing it to POST the postman app was able to connect.

So it appears to be something wrong with my code (snippet on  the original post). I think that maybe the URL might have something to do with it. Interestingly each time change the URL, enter a valid username and password and nothing else I get a different result in my code.

URL: https://push.cityindex.com/lightstreamer

CONNECTING
DISCONNECTED:WILL-RETRY

URL:  https://push.cityindex.com

CONNECTING
DISCONNECTED
1
User/password check failed

 

Does anything standout to you in the original code that would prevent a successful connect to Light streamer and the streaming of prices?

Thanks

image.thumb.png.2071c1e8336288903d5ddf1f2c96a4c1.png

Share this post


Link to post

Hi Dante,

I looked at the Lightstreamer Node.js API documentation for the connectionDetails class at: https://lightstreamer.com/api/ls-nodejs-client/latest/ConnectionDetails.html

From reading that, your code lines for setUser and setPassword should be as follows:

lsClient.connectionDetails.setUser("DMxxxx");
lsClient.connectionDetails.setPassword("xxxxx"); 
lsClient.connect();

Let us know if that fixes the issue for you.

Kind Regards, PM

Share this post


Link to post

Hi Physicsman,

Thank you for the response, I can't believe I did not notice something as simple as parentheses instead of equals. After I made the change, the Stream connected immediately and I started getting live data.

Thank you so much for your time,

Dante   

Share this post


Link to post

Similar to the code given by Dante in the original question above, can I get some sample code of How to get streaming market prices? I am having a hard time using Lightstreamer. Would be very helpful. I am using Python but any sample code would be useful. Thank you!

Share this post


Link to post

Hello Physicsman,

I'm having the same issue. I'm using demo credentials with Postman. I tried all the things you went through to investigate the problem. I logged in to forex using the demo username and password. It seems to subscribe fine to me. But I get "ERROR 1 User/password check failed". I don't know what I'm doing wrong. Below are the requests I did on Postman:

 

get_session.PNG

trial_connection_ls.PNG

Share this post


Link to post

Hi Nat,

Please send me a private message with the credentials to the DEMO account you are using. I can then investigate further using that account directly.

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
×