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 Asio client is aware of server terminating connection via GOAWAY with error code 0 #4

Open
soumyakantiroychowdhury opened this issue Aug 19, 2022 · 1 comment

Comments

@soumyakantiroychowdhury

When a http/2 server closes the connection gracefully by sending GOAWAY frame with error code 0, how does the asio http2 client can communicate this to the upper layer? The on_error callback of the session class is not called in this scenario, which is expected.

@louygan
Copy link

louygan commented Dec 2, 2022

found issue in asio_client_session_impl.cc

according to nghttp2/examples/client.c
NGHTTP2_RST_STREAM and NGHTTP2_GOWAY should be handled.

246 static int on_frame_recv_callback(nghttp2_session *session,
247 const nghttp2_frame *frame, void *user_data) {
248 size_t i;
249 (void)user_data;
250
251 switch (frame->hd.type) {
252 case NGHTTP2_HEADERS:
253 if (frame->headers.cat == NGHTTP2_HCAT_RESPONSE) {
254 const nghttp2_nv *nva = frame->headers.nva;
255 struct Request *req;
256 req = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id);
257 if (req) {
258 printf("[INFO] C <---------------------------- S (HEADERS)\n");
259 for (i = 0; i < frame->headers.nvlen; ++i) {
260 fwrite(nva[i].name, 1, nva[i].namelen, stdout);
261 printf(": ");
262 fwrite(nva[i].value, 1, nva[i].valuelen, stdout);
263 printf("\n");
264 }
265 }
266 }
267 break;
268 case NGHTTP2_RST_STREAM:
269 printf("[INFO] C <---------------------------- S (RST_STREAM)\n");
270 break;
271 case NGHTTP2_GOAWAY:
272 printf("[INFO] C <---------------------------- S (GOAWAY)\n");
273 break;
274 }
275 return 0;
276 }

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