Dante 1 Report post Posted January 20, 2019 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
Physicsman 25 Report post Posted January 21, 2019 Hi Dante, One small correction, when authenticating with Lighstreamer, the password is the Session ID received when logging into the REST part of the API. The relevant page of the API documentation is: http://docs.labs.cityindex.com/#Getting Started/CIAPI Arky.htm%3FTocPath%3DGetting%20Started|_____1 Kind Regards, PM Share this post Link to post
Dante 1 Report post Posted January 21, 2019 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
Physicsman 25 Report post Posted January 22, 2019 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. Share this post Link to post
Dante 1 Report post Posted January 22, 2019 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 Share this post Link to post
Physicsman 25 Report post Posted January 22, 2019 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
Dante 1 Report post Posted January 22, 2019 Hello again, The account in question is a demo account. I have messaged you the user name and password as requested. Thanks Share this post Link to post
Physicsman 25 Report post Posted January 23, 2019 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
Dante 1 Report post Posted January 23, 2019 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 Share this post Link to post
Physicsman 25 Report post Posted January 23, 2019 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
Dante 1 Report post Posted January 24, 2019 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 1 Physicsman reacted to this Share this post Link to post
Amruta 0 Report post Posted July 31, 2019 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
Physicsman 25 Report post Posted August 14, 2019 Hi, Lightstreamer have a blog article walking a user through using Python at the following link: http://blog.lightstreamer.com/2015/01/a-python-client-example-for_14.html. Kind Regards, PM Share this post Link to post
natnael0 0 Report post Posted November 3, 2019 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: Share this post Link to post
Physicsman 25 Report post Posted November 4, 2019 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