Page 5 of 8 FirstFirst ... 34567 ... LastLast
Results 41 to 50 of 80
  1. #41

    reconnect

    Hi ! And thanks for your work !

    I want my LightStreamer client to try to reconnect whatever the situation, it seems to work for now (not testing since a long time in fact), but as I don't test against my own server I have to wait for errors to happen, and being new to LightStreamer and Python I suppose I'm doing some not clever things. Can you please give me your appreciation about my code ?

    I modified your python client this way :

    Added these two methods to LSClient class : In the _handle_stream method I replaced the last line "raise IOError()" with "self.reconnect()", and the end of the _receive method is now :
    Thanks !

  2. #42
    Power Member
    Join Date
    Feb 2008
    Location
    Siracusa
    Posts
    161
    Hi epep,

    you can always test your code against a Lightstreamer version available from our site (for example, you can install a free Moderato version or a Vivace demo). After installation, please follow the instructions on how to deploy the StockList Demo Adapter.

    That said, your modifications look very good, just a couple of observations:
    1. Replacing the "raise IOError()" in the _handle_stream method is not a good idea, because a server error response while connecting is a symptom that something is not working properly, as you can read from Paragraph 4.1 of the Network Protocol Tutorial
    2. It is necessary to remove the following line:

      before invoking reconnect(), otherwise you'll run against a runtime error: it is a bug that I'm going to fix in our example


    Please let us know about your progresses.

    Thanks and Regards,
    Gianluca

  3. #43
    Quote Originally Posted by gianluca.finocchiaro View Post
    Replacing the "raise IOError()" in the _handle_stream method is not a good idea, because a server error response while connecting is a symptom that something is not working properly, as you can read from Paragraph 4.1 of the Network Protocol Tutorial
    In fact the only error I encountered for now with IG's stream server happen here, about 3 times a day, while trying to bind. I receive a SYNC ERROR about half a second after a LOOP message, before the binding is done. In this situation the reconnection work at first try.

    I understand that errors in this point should be used with care for a clean client, but for my project I believe that the only errors that can occur here are the temporary ones, which would be resolved with a later reconnection.
    Quote Originally Posted by gianluca.finocchiaro View Post
    It is necessary to remove the following line: before invoking reconnect(), otherwise you'll run against a runtime error: it is a bug that I'm going to fix in our example
    Thanks a lot ! I see the point : None has no close() method.

    This line is also worthless before calling the bind() method ?

  4. #44
    Power Member
    Join Date
    Feb 2008
    Location
    Siracusa
    Posts
    161
    Hi epep,

    Quote Originally Posted by epep View Post
    ...
    This line is also worthless before calling the bind() method ?
    yes because the bind() method replaces self._stream_connection with a newly created object: see fixed example here.

    Let me know.

  5. #45
    Ok, it works fine without the "self._stream_connection = None".

    I notice that my logging was badly formated in reconnect(), I should have written :

    About errors documented in 4.1 of the network protocol tutorial, do you agree that they should not happen after the connection is established ? I've done this at the end of the _handle_stream method : Like this, if an error occurred at the first connection, it is raised. If it encounters the bind problem from IG, it reconnects. Is it clean ?
    Last edited by epep; November 4th, 2016 at 01:26 PM.

  6. #46
    Power Member
    Join Date
    Feb 2008
    Location
    Siracusa
    Posts
    161
    Hi epep,

    Quote Originally Posted by epep View Post
    ...

    About errors documented in 4.1 of the network protocol tutorial, do you agree that they should not happen after the connection is established ? I've done this at the end of the _handle_stream method : Like this, if an error occurred at the first connection, it is raised. If it encounters the bind problem from IG, it reconnects. Is it clean ?
    In case of binding an existing session (hence _bind_counter is greater then 0), you could run against similar issues, as specified in the Paragraph 4.2 of the Network Protocol tutorial.

    Obviously you are free to implement the reconnection logic as per your requirements, but in my opinion you should trigger it only if you can be sure that a real network problem has been verified.

    Let me know,
    Gianluca
    Last edited by gianluca.finocchiaro; November 13th, 2016 at 05:46 PM. Reason: Fix typo

  7. #47
    You're right !

    It seems that IG changed something about the persistence of authentication tokens, my script get stuck trying to reconnect with invalid password … I need more intelligence here. I'll let you know as soon as I have done something good.

  8. #48
    Hi, can anyone recommend the best solution to connect to IG API using python? I've tried the trading_ig library by Femto, but can't get any data to stream - just keep getting the PROBE messages - e.g:
    DEBUG:trading_ig.lightstreamer:Received message ---> <PROBE>
    DEBUG:trading_ig.lightstreamer:PROBE message
    DEBUG:trading_ig.lightstreamer:Waiting for a new message



  9. #49
    Power Member
    Join Date
    Feb 2008
    Location
    Siracusa
    Posts
    161
    Hi strangecarr,

    by using our Python client demo, you should be able to connect to IG API for streaming, as other users of this forum have already done.
    Please have a look at previous discussions on this same thread to get more information and please get back to us for any technical details regarding the client.

    Best Regards,
    Gianluca

  10. #50
    Hi Gianluca,
    Thanks for quick reply, I tried the code of Colomboa too, which modifies the stock_list_demo script to connect to the IG API, but I only received "cannot connect to Lightstreamer server". I updated the CST and XST details. Any advice on the best way to edit the stock_list_demo to connect to IG?

 

 

Similar Threads

  1. Python Client Library for Lightstreamer
    By Alessandro in forum Client SDKs
    Replies: 1
    Last Post: December 18th, 2014, 06:15 PM
  2. how to comunicate lightstreamer server by python
    By keyan in forum Client SDKs
    Replies: 4
    Last Post: December 18th, 2014, 06:12 PM
  3. Replies: 2
    Last Post: January 5th, 2012, 09:53 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 08:09 AM.