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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 0 1

We cannot get items by multiple Batch Request

Hi Team,

I'm going to send request for 4000+ items. So divide items for multiple batch request like below, by reference

(_send_market_price_request is called after getting login response correctly.)

class ReutersReceiver:
    def _send_market_price_request(self):
        # get 4000+ items
        all_rics = get_ric_list()
        # each batch request has 3500 items
        MAX_LIST_LEN = 3500
        def get_req_json(rics):
            return {
                'ID': 2,
                'Domain': 'MarketPrice',
                'Key': {
                    'NameType': 'Ric',
                    'Name': rics,
                },
                'View':get_view_items_list(),
            }

        for top_num in range(0, len(all_rics), MAX_LIST_LEN):
            _rics = all_rics[top_num:top_num + MAX_LIST_LEN]
            self.web_socket_app.send(json.dumps(get_req_json(_rics)))
            time.sleep(5)

Only 3447/4678 Refresh message has be returned and as items increase the time first Update message has arrived increase, even though each batch request item size is around 55kb.

Also, the more increasing size, the worse returned Refresh/Update message.

Are there anything bad implementations or other factor?

Or what should I do if there is no simple resolution. Could you give me some workaround?


Thanks


mochizuki.y



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

@mochizuki.y

Hi,

Thank you for your participation in the forum.

Is the reply below satisfactory in answering your question?

If yes please click the 'Accept' text next to the reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

AHS

@mochizuki.y

Hi,

Please be informed that a reply has been verified as correct in answering the question, and marked as such.

Thanks,

AHS

Upvotes
Accepted
79.2k 251 52 74

@mochizuki.y

According to the code, you use the same streamID for batch requests which is incorrect.

The streamID must be unique for each stream. The following picture shows how the streamID works in a batch request.

1655194393758.png

The picture uses the streamID: 4 for a batch request which requests three items.

The server will close the batch request (streamID: 4) with the stream state: Closed and the data state: Ok. Then, the server will send unique streamIDs (5, 6, 7) for each subscribed item.

Therefore, if the application would like to send another batch stream, the streamID of the new batch request should be 8.

In your case, you use the streamId: 2 for a batch request to subscribe to 3500 items so the streamID of the next batch request should be 3503 (2+3500+1).


1655194393758.png (57.5 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.

Upvotes
1 0 0 1

@Jirapongse

Thank you for your advice. Now we have confirmed to get 4000+ items by multiple batch requests which are assigned streamID dynamically.

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.

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.