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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 0 1 1

Snapshot request: "Request Rejected: Cannot request new item on open stream"

I am retrieving around 20000 rics as a batch from the websocket api. due to the fact, that the message size is limited, I need to request the items in individual requests of 2000 rics each.

I am not really sure when I can send a new request to the websocket api, e.g. if I send the second request too fast, I get the error "Cannot request new item on open stream".

  {
    "Type": "Status",
    "State": {
      "Stream": "Closed",
      "Data": "Suspect",
      "Text": "Request Rejected: Cannot request new item on open stream.",
      "Code": "AlreadyOpen"
    },

I tried to wait for the Status message, and then send a new request, but this doesnt work.

[{
  "Type": "Status",
  "State": {
    "Stream": "Closed",
    "Data": "Ok",
    "Text": "Processed 2000 total items from Batch Request.  2000 Ok."
  },
  "ID": 2
}]
treprdp-apiwebsocketsrrto
icon clock
10 |1500

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

1 Answer

Upvotes
Accepted
9.7k 49 38 60

Hi @peter.reinhardt,

When you send a request to retrieve data you must ensure the "ID" is unique. In your case, when you sent your first batch, you likely used "ID": 2 which is fine. However, you can't reuse the same ID. You must ensure the ID you use is beyond the batch size you requested. For example, if you use "ID": 2 for your first batch of 2000 RICs. EMA will create 2000 ID fields for you, i.e 3, 4, 5, ...2002. When you make your next batch request, you must ensure you start beyond the next allocated ID, i.e. 2003.

Try a small batch first to test.

Nick

icon clock
10 |1500

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

this was exactly the issue. thanks

Click below to post an Idea Post Idea