简体   繁体   中英

Lightstreamer Client for Matlab

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?

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 (eg 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM