Support for events sent by a server with Netty HTTP2 implementation

I am using Netty version 4.1-Beta6.

I want to support a use case where an HTTP2 server should be able to send events to an HTTP2 client in an existing connection — it could be an alarm or timer event from the cloud that should be sent to the client.

  • I mean using the Server Sent Event function - is it possible to do this with HTTP2 in Netty, if so, how? Should I keep the http2 stream open by sending data frames with the final frame flag set to false? When I try to do this, I observe that the contents are buffered. The data frame does not reach the client when and when I write. I am using DefaultHttp2Encoder. I tried setting the "Transfer-Encoding" header to "chunked".

  • A related question is - allows HTTP2 to allow bidirectional data frames after the stream is in the "open" state? The idea is that the server should be able to request data from the client, and the client should be able to respond with data in one stream (canceling the client / server role after the stream has been established). Is it possible?

Thanks in advance for your help.

+4
source share
1 answer

I played with Netty a bit more. Here is what I found for 2 questions above.

  • , "", "endOfStream" false, /. , flowController.writePendingBytes(), ChannelHandlerContext.flush().

- https://github.com/skssfo/http2

  1. , .

Netty , . Netty team!

+2

Source: https://habr.com/ru/post/1606484/


All Articles