0

I am trying to build a lightstreamer client for Matlab. There do exist a couple of libraries for platforms like JAVA, Python, .Net etc. But unfortunately not Matlab. However, it turns out that most of these client implementations use the very same text-mode protocol for lightstreamer which is pretty basic HTTP requesting.

I figured out how to establish/close a lightstreamer session. I get the sessionId and I can use this id to subscribe to the data I want to stream. But although I do get a valid response for the subscription call, there is no data pushed.

I use the urlead2 function and the response seems fine:

 [output,extras]      = urlread2([lightstream_url,'/lightstreamer/control.txt'],'POST',body,headers);

allHeaders =

      Response: {'HTTP/1.1 200 OK'}
        Server: {'Lightstreamer'}
  Content_Type: {'text/plain; charset=iso-8859-1'}
 Cache_Control: {'no-store'  'no-cache'}
        Pragma: {'no-cache'}
       Expires: {'Thu, 1 Jan 1970 00:00:00 GMT'}
          Date: {'Wed, 8 Apr 2015 11:15:02 GMT'}
Content_Length: {'4'}

status =

value: 200
  msg: 'OK'

isGood =

 1

output =

OK

It is correct that the response body contains "OK ", this is documented (documentation, page 20ff.), but there is supposed to be the stream data itself as well, isn't it?

So how do I get the actual data?

flimm
  • 39
  • 2
  • I found out that using the whole URL query in a browser leads to the following lightstream response error: "SYNC ERROR". Maybe this gives a hint? – flimm Apr 08 '15 at 16:47
  • right after answering I realized you might already be watching the correct response for the data stream, if so, might it be there is simply no data flowing? Did you ask for a snapshot? Are you in control of the server? – Mone Apr 09 '15 at 11:18

2 Answers2

1

Somewhere in your code you should have a create_session.txt/bind_session.txt request, otherwise you should not have a valid session id that is required to obtain an OK answer from a control.txt request (e.g. the following generates the SYNC ERROR, that means that the server does not recognize the specified session: http://push.lightstreamer.com/lightstreamer/control.txt?LS_op=add&LS_session=invalid )

The data stream is not received on the control.txt response, that OK response simply means "OK I have added the subscription to your session". The data stream is received on the create_session.txt/bind_session.txt response. Sections 4.1 and 4.2 + section 4.5 on the document you linked should explain how the data is received

Mone
  • 74
  • 3
  • The suggestion with the 'bind session' might be the answer. I actually thought it is directly done using control.txt . The documentation is a bit misleading, I thought it has a similar behaviour as the screen command in unix. I will try out and post the answer. Thank you very much! – flimm Apr 09 '15 at 15:00
1

I've found that opening a polling connection by setting LS_polling=true works fine without needing a listner. urlread2 hangs if you leave LS_polling as the default of false.

  1. Create the session with /lightstreamer/create_session.txt
  2. Request a subscription with /lightstreamer/control.txt
  3. Repeatedly poll the connection to get the data with
    /lightstreamer/bind_session.txt

The return from urlread2 will look something like this:

d =

OK
SessionId:S9b09da8ebd6b835aT5316913
ControlAddress:apd119a.marketdatasystems.com
KeepaliveMillis:1000
MaxBandwidth:0.0
RequestLimit:50000

1,1|10162.00|0.00|0.00
2,2|10686.8|TRADEABLE|0.5524861
2,13|1202.6|CLOSED|0.5714285
2,14|5900.51|CLOSED|0.5714285
...

LOOP 1000