For a deeper look into our Elektron API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
5 1 2 7

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

python#technologyADSposting
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
80.1k 257 52 75

@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.


1675059262955.png (20.4 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

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.

Upvotes
25.1k 57 17 14

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:

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
5 1 2 7

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

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
5 1 2 7

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

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@martin.gregory

Currently, all WebSocket API examples are available on GitHub.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.