0

Hello i try to understand this lib and i have a python source here https://github.com/ig-python/ig-markets-api-python-library/blob/master/trading_ig/lightstreamer.py on line 187 I'm able to add LS_op2 or set LS_container but I have problems on doing this on the js version.

the first message i want is:

LS_op2=create&LS_phase=5701&LS_cause=new.api&LS_polling=true&LS_polling_millis=0&LS_idle_millis=0&LS_cid=pcYgxn8m8 feOojy*****f3g2.pz479mDv&LS_adapter_set=DEMO&LS_container=lsc&

but i get only

LS_phase=3201&LS_cause=new.nullresp&LS_polling=true&LS_polling_millis=0&LS_idle_millis=0&LS_cid=pcYgxn*** feOojyA1U661i3g2.pz47Af6k&LS_adapter_set=DEMO&

Maybe someone have a idea, here is my source, thanks.

  <html>
<head>
    <script src="https://unpkg.com/lightstreamer-client-web@8.0.3/lightstreamer.min.js"></script>
    <script>
        document.addEventListener("DOMContentLoaded", function(event) {
            var client = new LightstreamerClient("https://push.lightstreamer.com","DEMO");

            client.connect();
            var sub = new Subscription("MERGE",["item1","item2","item3"],["stock_name","last_price"]);
            sub.setDataAdapter("QUOTE_ADAPTER");
            sub.setRequestedSnapshot("yes");

            sub.addListener({
                onItemUpdate: function(obj) {
                   console.log(obj.getValue("stock_name") + ": " + obj.getValue("last_price"));
                }
            });
            client.subscribe(sub);
        });

    </script>
</head>
<body>
</body>
</html>
StefanBD
  • 334
  • 3
  • 14

1 Answers1

0

If the question is why Lightstreamer javascript SDK 8.0.3 library creates a different request, it is because the python code provided as reference (which doesn't lean on any SDK library) uses an earlier version of the communication protocol. Anyway, the request issued by the javascript library is supposed to work.

  • i did some research and seems the server i want to connect use some "own" implementation i tryet sg-zertifikate.de, i successfully get the session but i dont get a connection to the ws – StefanBD Jan 21 '22 at 19:07
  • Your example was for the demo server at push.ligthtstreamer.com. Different servers will use different names for Adapter Set, items, fields, and Data Adapter, which can be chosen freely. – Dario from LS Jan 27 '22 at 08:12
  • An established session works either on a websocket connection or through http streaming. So, if you have evidence that the session was established, this should be enough to proceed. What evidence do you have that you don't get a connection to the ws? – Dario from LS Jan 27 '22 at 09:02
  • I've checked the connection tab in firefox web console and even on other tests i used Charles to monitor connection. warrantspushserver.societegenerale.com/lightstreamer is the server i want to connect, I've modded and set the arguments in the lib so that it fits the arguments they want. The create_session.js is fine but after this LS will not build up a connection to the Wss. Source where i want grab quotes is https://www.sg-zertifikate.de/product-details/SF6YUE – StefanBD Jan 28 '22 at 09:21
  • The Question is now only from theoretical way, I wrote with SG, and they don't like that I grab the data, but its interests me where my problem was – StefanBD Jan 28 '22 at 09:30
  • The implementor can refuse your request to create a session for several reasons other than the submitted credentials. But you say that you provide your correct credentials and the create_session request receives a successful answer? What follows depends on your client code. Since the client shown earlier (8.0.3) doesn't issue create_session.js, now you are probably using an older client. Old clients used old techniques to communicate with the Server, some of which are no longer supported by the browsers. So it is difficult to trace what happened. – Dario from LS Jan 31 '22 at 14:19
  • this is kind of old but on researching i have found my thread today, my problem was resulted in having a old server version so i had to use not the current v8 version with this now the data are flowing – StefanBD Oct 18 '22 at 20:18
  • Hi @StefanBD I'm trying to connect to SG lightstreamer server too using python, I have the following error: WARN |lightstreamer.session|Thread-3 (_hx_local_2)|Websocket suspended ERROR|lightstreamer.session|Thread-3 (_hx_local_2)|Retrying connection. Cause: Websocket transport not available ERROR|lightstreamer.session|Thread-3 (_hx_local_2)|Disconnected. Cause: 67 - LS_cid parameter missing Do you know how to solve it, I'm using ProxyIcomAdapter as adapterSet, mode="MERGE" items (inin.market codes), fields ['BID', 'BIDTIME', 'ASK'] and data adapter DEFAULT – david.t_92 Jan 15 '23 at 11:54
  • hi @david.t_92 i had no success with a python version but seems like u have set the LS_cid param. I recommend u using webconsole and look which data is beeing send and compare it with ur python request – StefanBD Jan 15 '23 at 21:14
  • Just in case, note that now there is an official Python client SDK (https://pypi.org/project/lightstreamer-client-lib/1.0.1/); however, it requires Server version 7.3, so it may not be applicable to your scenario. – Dario from LS Jan 16 '23 at 13:09
  • Otherwise, if you are setting up a client that works directly at protocol level (i.e. it is not based on any of the available client SDK libraries), you should refer to the TLCP protocol specifications. If you refer to version 2.0.0 (https://lightstreamer.com/tlcp-2.0.0), then you can talk to any Lightstreamer Server since version 6.1. – Dario from LS Jan 16 '23 at 13:21
  • Thanks a lot for all the responses, I was trying to connect using the library that @DariofromLS show me, maybe the version could be the problem. It is possible seeing this version in the webconsole?, I saw the following parameters: Sec-WebSocket-Version: 13 (This is only security version?), Sec-WebSocket-Protocol: js.lightstreamer.com and inside thet websocket request there is not any version specification – david.t_92 Jan 16 '23 at 18:41
  • @StefanBD Could you share you javascript code (Just the connection part would be ok) if not just share the parameters you are using (adapterSet, mode, items, fields and dataAdapter) and also JS lightstreamer library/version that you are using Thanks a lot – david.t_92 Jan 16 '23 at 18:42
  • @david.t_92 its not the javascript code only its more the lib u must use. u need Lightstreamer Version 6.2.7 build 1679.2 https://www.npmjs.com/package/lightstreamer-client/v/6.2.7 with this the normal connection works var client = new Ls.LightstreamerClient("https://warrantspushserver.societegenerale.com", "ProxyIcomAdapter"); client.connect(); client.subscribe(sub); – StefanBD Jan 16 '23 at 19:51
  • Thank you @StefanBD, the problem was because of the Lightstreamer version in python library. I've created a script in nodejs that converts Lightstreamer to Websocket in this way I from python y call the NodeJs, NodeJS makes the request using Lightstreamer and the real time values are retruned to python throw websocket. Thanks a lot! – david.t_92 Jan 17 '23 at 13:00