0

I have implemented an application in C language which communicates with Amazon AVS cloud using nghttp2 and openssl. I can get a response up to 65535 bytes only. If a response is greater than 65535 bytes than application can't receive the rest data and stuck forever to receive the response. As mention earlier, I am using the nghttp2 library for HTTP/2 connection.

Is there any configuration needs to set to get data size more than 65535 bytes from AVS cloud? Please help.

jww
  • 97,681
  • 90
  • 411
  • 885
  • 1
    Please provide us with some sample code that demonstrates your problem. – bta Oct 27 '17 at 17:05
  • 1
    Please show the relevant code. Since Stack Overflow hides the Close reason from you: *Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve).* – jww Oct 27 '17 at 21:43

2 Answers2

0

The fact that you can only receive 65535 bytes smells a lot like you are not handling HTTP/2 flow control properly.

I don't know enough of the nghttp2 library to tell you what you have to do to make sure the flow control is correctly handled, but either you are not using the nghttp2 API properly (for example, you forgot to notify a callback), or you don't call a nghttp2 API that handles flow control that you must call.

For reference you can read about flow control in the specification.

Community
  • 1
  • 1
sbordet
  • 16,856
  • 1
  • 50
  • 45
  • Exactly. It's important for the client to manage its own flow control window as well. After receiving data, you must at some point emit a WINDOW_UPDATE frame in order to inform the server you can receive more data on your connection, otherwise the initial window (with a default of 65535 bytes) will be consumed! – Brad K. Oct 28 '17 at 21:38
  • Take a look at nghttp2's `nghttp2_submit_window_update` method – Brad K. Oct 28 '17 at 21:42
  • Thanks for your response. I have tried with "nghttp2_submit_window_update" but still not able to receive data more than 65535 bytes. – Palak Joshi Oct 31 '17 at 10:20
  • I have used "nghttp2_submit_window_update" function in "on_data_chunk_recv_callback" callback function. I have observed that sometimes this function call get fail with Flow control Error and sometimes it get succeed but the limit of data size (65535) does not increase. – Palak Joshi Nov 01 '17 at 17:35
  • Below are the list of callback functions registered for nghttp2: nghttp2_session_callbacks_set_send_callback(), nghttp2_session_callbacks_set_recv_callback(), nghttp2_session_callbacks_set_on_frame_send_callback(), nghttp2_session_callbacks_set_on_header_callback(), nghttp2_session_callbacks_set_on_stream_close_callback(), nghttp2_session_callbacks_set_on_data_chunk_recv_callback(), nghttp2_session_callbacks_set_data_source_read_length_callback(). – Palak Joshi Nov 01 '17 at 17:35
  • You may want to take a look at the `curl` source code to see how it uses `nghttp2` for HTTP/2. `curl` handles flow control properly, so they surely have an example of how to use the `nghttp2` APIs correctly. For example, look [here](https://github.com/curl/curl/blob/master/lib/http2.c). – sbordet Nov 01 '17 at 22:10
  • I have used the same logic and callbacks for my code as given in curl library but still not able to receive. – Palak Joshi Nov 03 '17 at 14:40
  • Well, I doubt AWS has deployed a broken server, so it must be something in your client. If you use `curl` instead of your client, does it work ? If you use another HTTP/2 client, does it work ? If the other clients work, then it's something in your client. – sbordet Nov 03 '17 at 18:23
0

I was also facing the same issue, and as a quick workaround, I disabled nghttp2's auto window update via nghttp2_option_set_no_auto_window_update(option, 1) API while opening the session and called

nghttp2_session_consume(session, stream_id, len); nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, stream_id, len); nghttp2_session_send(session);

from data chunk recv callback after I am done processing one chunk of data. I am still not sure why keeping auto window update feature of nghttp2 enabled doesn't work.

Amit Sheth
  • 23
  • 1
  • 3