Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can we know the max of streams allowed on the server #104

Open
posilva opened this issue Feb 3, 2017 · 2 comments
Open

How can we know the max of streams allowed on the server #104

posilva opened this issue Feb 3, 2017 · 2 comments

Comments

@posilva
Copy link

posilva commented Feb 3, 2017

Hi,

using the h2_client how can I know the max number of concurrent streams allowed on the server.
I can see in the code that the received "SETTINGS" frame saves the other endpoint max concurrent streams in the local connection.

I would like to check the max streams allowed and then when I am sending split the requests in up max streams size request chunks.

Example:

I have to send 1000 requests so, I will check the max streams (100) so I will split the requests in 10 chunks and send and receive the streams until send the 1000 without exceed the max limit on the server (will cause a {ok, {error, 7}} on chatterbox server if we put a limit in the MCS).

Some guidance would be nice

Cheers

@efine
Copy link
Contributor

efine commented Apr 17, 2017

You could do it like this:

Streams = h2_connection:get_streams(H2Pid),
MCS = (Streams#stream_set.mine)#peer_subset.max_active.

Streams would look something like this:

#stream_set{type = client,
            mine = #peer_subset{max_active = 1000,active_count = 0, ...

I wouldn't do it very frequently, though, because get_streams/1 is a sync event and polling a lot will block the gen_fsm while in progress.

A better way (IMHO) to do it would be to add code to chatterbox to send an event when receiving a frame from the server, and pull the MCS out of that. Or wait until you get the {error, 7} return and stop sending.

Honestly, I'm not sure what is a good way of achieving efficient batching in APNS with chatterbox.

@efine
Copy link
Contributor

efine commented Apr 18, 2017

I didn't notice there was a specific accessor you can use to get MCS. This code avoids needing to know the internals:

StreamSet = h2_connection:get_streams(H2Pid),
MCS = h2_stream_set:my_max_active(StreamSet).

EDIT: Duh, I added this accessor to my fork. Sorry. I will offer it as a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants