keepalive

7 posts / 0 new
Last post
LTodini
keepalive

Hi guys,
is there a way to know if the lightstreamer connection is up?

APItrader
While the connection is up

While the connection is up you should receive packets at least every five seconds, either data packets or heartbeats ("PROBE" packets). If you don't, something is wrong.

belfort
Subscribe to any price stream

Subscribe to any price stream.

The client libraries also have failure events that you can listen to.

Jim
rest api keep alive

How is it possible to check the rest api session is alive/valid?
Is there a heartbeat function that can be called every 10-20-30 sec?

Chris
rest api keep alive

Hi Jim,

Heartbeat for LS connections are discussed here: http://labs.ig.com/node/241

The REST API is stateless and doesn't really maintain a session other than to keep track of CST and X-SECURITY-TOKEN tokens and invalidating them after a certain amount of time. We currently don't provide a REST endpoint to indicate whether the security tokens are still valid. The API will return a 401 invalid token failure if the tokens have expired.

Hope that helps.

Chris

Jim
rest api keep alive

Hello Chris,

If the rest api is stateless then do not expire the token,
if you do expire the token then provide a heartbeat function, which can check the validity, so the live trading algo does not run into an authentication error. Ideally, the heartbeat function also reset the timeout/expiration period.

Regards,
Jim

Chris
rest api keep alive

Hi Jim,

The API is a stateless REST API, so a heart beat is not possible. You can login at any point and obtain new tokens. A periodic thread could run in the background hitting an endpoint looking for the 401 error code with the message for an invalid account or client token and then call the login endpoint again. So either testing that the session tokens are still valid as described or automatically login again after having held the tokens for a few hours are two possible solutions.

Hope that helps.
Chris

Log in or register to post comments