05-03-2019, 11:55 AM
(This post was last modified: 05-03-2019, 12:35 PM by rsiw2000.
Edit Reason: adding more data.
)
Hello,
I´m trying to write a Lightstreamer client using C++ Builder Tokyo and TIdHTTP component.
I wrote this code based on the python client demo.
TIdHTTP is receiving data using a simple TStream descendant and I get these data on the Write method.
This is part of the connection thread, it creates the session and stay connected to receive data.
The connection returns the following headers:
When SessionId arrives, I subscribe some stocks using another TIdHTTP and stock data becomes to arrive.
Server is sending data all the time, but TIdHTTP connects and receives some data, then stops for a few minutes, then another block of data arrives, then stops again, then receive another block, a lot of times.
It seems like to be filling a buffer, precisely a 32k (32768 bytes) buffer.
When I force TIdHTTP to disconnect, remaining data arrives in the Write method.
So:
What i'm doing wrong ?
Why received data does not reaches the stream Write method immediately ?
At the python example there's no different header (no header, in fact.).
The Lightstreamer docs also does not have any reference to the need of some specific header.
I´m trying to write a Lightstreamer client using C++ Builder Tokyo and TIdHTTP component.
I wrote this code based on the python client demo.
TIdHTTP is receiving data using a simple TStream descendant and I get these data on the Write method.
This is part of the connection thread, it creates the session and stay connected to receive data.
Code:
pHTTP = new TIdHTTP(0);
pHTTP->Request->CustomHeaders->Add("Accept: */*");
pHTTP->Request->CustomHeaders->Add("Content-Type: application/x-www-form-urlencoded");
pHTTP->Request->CustomHeaders->Add("Connection: Keep-Alive");
UnicodeString params, url = L"http://push.lightstreamer.com/lightstreamer/create_session.txt";
params.sprintf(L"LS_op2=create&LS_cid=mgQkwtwdysogQz2BJ4Ji+kOj2Bg&LS_adapter_set=DEMO&LS_protocol=TLCP-2.1.0";
// parametros
params = TIdURI::ParamsEncode(params, enUTF8);
// conexão
pSSParams = new TStringStream(params);
pHTTP->Post(url, pSSParams, pClienteLS->RcvdStream);
The connection returns the following headers:
Quote:HTTP/1.0 200 OK
Server: Lightstreamer-Server/7.1.0 b4 build 1915 (Lightstreamer Server - www.lightstreamer.com) ENTERPRISE edition
Content-Type: text/enriched; charset=ISO-8859-1
Cache-Control: no-store
Cache-Control: no-transform
Cache-Control: no-cache
Pragma: no-cache
Expires: Thu, 1 Jan 1970 00:00:00 GMT
Date: Fri, 3 May 2019 12:03:13 GMT
Content-Length: 500000
Connection: Keep-Alive
x-accel-buffering: no
When SessionId arrives, I subscribe some stocks using another TIdHTTP and stock data becomes to arrive.
Server is sending data all the time, but TIdHTTP connects and receives some data, then stops for a few minutes, then another block of data arrives, then stops again, then receive another block, a lot of times.
It seems like to be filling a buffer, precisely a 32k (32768 bytes) buffer.
When I force TIdHTTP to disconnect, remaining data arrives in the Write method.
So:
What i'm doing wrong ?
Why received data does not reaches the stream Write method immediately ?
At the python example there's no different header (no header, in fact.).
The Lightstreamer docs also does not have any reference to the need of some specific header.