简体   繁体   中英

how to maximize the server sent event open connections?

I am building a notification service for users to get notified about their activity. I need only server to client notification (One way). I have explored multiple options around it, such as polling, WebSocket, SSE. Since, SSE is less resource consuming and don't need other protocol other than HTTP itself for communication unlike Websocket. I have chosen the SSE. However, there is one limitation to it. It can support maximum 6 Open connections. I suppose it is related with the number of users concurrently accessing the notification. ie; Maximum 6 users can access the notification concurrently.

How do i manage to maximize the open connections? Or is it still better to use Websocket instead of SSE? Pardon me if i have misunderstood the concept. I would be very glad to know some info regarding this.

Your understanding of the max-connections is wrong. It is about the number of connections a client can open to a host (see this ). The number differs per browser (version).

So when using Chrome and you open a page on your website you can use max. 6 connections to retrieve data from the server.

There is no limitation on the server-side of SSE to send the same event to multiple users.

NOTE: If you still need to support IE, that doesn't support SSE out-of-the-box so you would need a polyfill or another solutions for that.

As mentioned by the other answers, most of the browsers can open around 6 HTTP/1.x connections to the same host. So, if you use 1 SSE connection, it will remain potentially 5 HTTP/1.x connections. This is only true with HTTP/1.x .

With HTTP 2.x, the connections to the same host are multiplexed : so, in theory, you can send as many HTTP requests at the same time as you wish or you can open as many SSE connections as you wish and thus, bypassing the limitation of the 6 connections.

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