简体   繁体   中英

Why do we need SSE when we have http2 bidirectional streaming?

This may seem elementary but i didn't find any answers on internet.

My understanding of SSE (server sent events) is that data is sent from server to client on a TCP connection when the data is available on the server, if the connection is closed, a new connection is opened by the client.

In http2 bidirectional streaming we are streaming the data from server when it is available and connection is kept open. This does the same as SSE .

I am not referring to http2 server push.

In an HTTP/2 connection, you have individual streams. Those streams (except for the push promises) need to get opened by the client to send a HTTP request, then the server can send an answer.

So you still need a stream to be opened by a client, waiting for the server to send some data.

And then the whole connection might break down (just like a HTTP/1.1 connection, or a plain TCP one), which means the client still needs to open a new connection (and open a stream there).

So HTTP/2 doesn't solve anything here which would make SSE superfluous.

As mentioned by Yami Odymel in a comment, the SSE specification also specifies the exact format of the messages being sent.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM