Post / receive Acks on the same channel for ADS websocket in Python

Hi - I can connected to an ads and off-stream post successfully. Im trying to send a lot of data, so i use a while True loop after receiving the login response to listen to a queue and post.

However this means that the on_message function is never accessed to receive the Acks to the posts.


Do you have any example of how I could achieve this please? (I'm using the Refinitiv examples as a base to connect to the ADS websocket)

Thanks

Martin

Best Answer

  • @martin.gregory

    Thanks for reaching out to us.

    You need to send post messages outside the on_message function.

    You can refer to the market_price_posting.py example on GitHub.

    The example shows how to send post messages in the main thread outside the on_message function.

    1675059262955.png

    I hope that this information is of help.

Answers

  • Hello @martin.gregory

    While my colleague already gave you a clear answer, the other WebSocket API Posting resource that might helps you are the following:

  • HI both - thank you very much. I can swap between processing the the incoming Acks and posting but if I'm posting a lot of data this becomes very slow. What I would like to achieve if possible is to concurrently listen for messages coming in whilst continuosuly posting the data that I would like to send to the ads


    Thanks

    Martin

  • Update - I believe I need to somehow run async functions to post and run on_message simultaneously within the websocket connection. Do you have examples to achieve this please?

    Thanks

    Martin

  • @martin.gregory

    Currently, all WebSocket API examples are available on GitHub.

  • Just an update. I managed to both listen and post concurrently, by starting the posting process in a new separate thread to the login thread, and using queue to pass messages between the 2 threads.


    Thanks all for your answers.